Replace the following parts:
From:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
To:
###### Begin Custom Settings ######
# Phalcon PHP
location / {
try_files $uri $uri/ /index.php?_url=$uri&$args;
}
# Subdirectories
location /blog/ {
index index.php;
try_files $uri $uri/ /blog/index.php?$args;
}
location /cms/ {
index index.php;
try_files $uri $uri/ /cms/index.php?$args;
}
# Performance settings
location ~* \.(jpg|jpeg|png|gif|ico|css|js|eot|svg|ttf|woff|woff2)$ {
expires 365d;
}
###### End Custom Settings ######
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
# Wordpress theme requirements
fastcgi_param PHP_VALUE "memory_limit = 128M";
fastcgi_param PHP_VALUE "max_execution_time = 300";
fastcgi_param PHP_VALUE "max_input_time = 300";
fastcgi_param PHP_VALUE "max_input_vars = 5000";
fastcgi_param PHP_VALUE "upload_max_filesize = 32M";
fastcgi_param PHP_VALUE "post_max_size = 32M";
include fastcgi_params;
}