Nginx скачивает файл PHP вместо запуска

Панель - ISPManager 5. Со стандартным конфигом всё работает, но после изменения, появилась такая проблема. Стандартный конфиг:

server {
    server_name site.ru www.site.ru;
    charset UTF-8;
    index index.php;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/site.ru/*.conf;
    access_log /var/www/httpd-logs/site.ru.access.log;
    error_log /var/www/httpd-logs/site.ru.error.log notice;
    ssi on;
    set $root_path /var/www/site/data/www/site.ru;
    root $root_path;
    location / {
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/site.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
    return 301 https://$host:443$request_uri;
    listen 127.0.0.1:80;
}

server {
    server_name site.ru www.site.ru;
    ssl_certificate "/var/www/httpd-cert/site/site.ru.crtca";
    ssl_certificate_key "/var/www/httpd-cert/site/site.ru.key";
    ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
    ssl_prefer_server_ciphers on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
    add_header Strict-Transport-Security "max-age=31536000;";
    ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
    charset UTF-8;
    index index.php;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/site.ru/*.conf;
    access_log /var/www/httpd-logs/site.ru.access.log;
    error_log /var/www/httpd-logs/site.ru.error.log notice;
    ssi on;
    set $root_path /var/www/site/data/www/site.ru;
    root $root_path;
    listen 127.0.0.1:443 ssl;
    location / {
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/site.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
}

Мой конфиг:

server {
    server_name site.ru www.site.ru;
    charset UTF-8;
    index index.php;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/site.ru/*.conf;
    access_log /var/www/httpd-logs/site.ru.access.log;
    error_log /var/www/httpd-logs/site.ru.error.log notice;
    ssi on;
    set $root_path /var/www/site/data/www/site.ru;
    root $root_path;
    error_page 500 /e/500/;
    error_page 404 /e/404/;
    error_page 403 /e/403/;
    location / {
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
      if ($http_referer ~* "^https?://([^.]+\.)*buttons-for-website\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*semalt\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*simple-share-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*free-share-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*bestwebsitesawards\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*best-seo-offer\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*best-seo-solution\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*makemoneyonline\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*blackhatworth\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*hulfingtonpost\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*bestwebsitesawards\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*o-o-6-o-o\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*ilovevitaly\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*econom\.co"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*humanorightswatch\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*4webmasters\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*Get-Free-Traffic-Now\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://(site[0-9]+\.)?social-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://(www[0-9]+\.)?free-social-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Darodar\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Priceg\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*7makemoneyonline\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*webmonetizer\.net"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*dailyrank\.net"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Blackhatworth\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Iskalko\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Lomb\.co"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Lombia\.co"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*hulfingtonpost\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*cenoval\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*o\-o\-6\-o\-o\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*sharebutton\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*s\.click\.aliexpress\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*social\-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*anticrawler\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*site12\.social\-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*adcash\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*adviceforum\.info"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*anticrawler\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*blackhatworth\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*cenokos\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*cityadspix\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*edakgfvwql\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*gobongo\.info"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*iskalko\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*kambasoft\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*luxup\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*myftpupload\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*prodvigator\.ua"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*resellerclub\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*savetubevideo\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*screentoolkit\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*seoexperimenty\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*slftsdybbg\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*socialseet\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*superiends\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*vodkoved\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*websocial\.me"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*ykecwqlixx\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*76brighton\.co\.uk"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*paparazzistudios\.com\.au"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*powitania\.pl"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*sharebutton\.net"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*tasteidea\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*descargar\-musica\-gratis\.net"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*torontoplumbinggroup\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*cyprusbuyproperties\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*4webmasters\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*ranksonic\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*best\-seo\-solution\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*get\-free\-traffic\-now\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*googlsucks\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Buttons\-for\-your\-website\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Best\-seo\-offer\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*offers\.bycontext\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*www1\.social\-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*website\-errors\-scanner\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*free\-share\-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*theguardlan\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*buy\-cheap\-online\.info"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*netvibes\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*guardlink\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*trafficmonetize\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*securesuite\.co\.uk"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*securesuite\.net"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*trafficmonetize\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*free-social-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "100dollars-seo\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*forum20\.smailik\.org"){
        return 403;
      }
      if ($http_host ~* "^www\.(.*)$"){
        set $http_host_1 $1;
        rewrite ^(.*)$ https://$http_host_1/$1 redirect;
      }
      rewrite "^/([a-z]{2})/action/logout/?$" /index.php?action=logout&lng=$1 break;
      rewrite "^/([a-z]{2})/?$" /index.php?lng=$1 break;
      rewrite "^/([a-z]{2})?/?e/?$" /index.php?lng=$1&module=errors break;
      rewrite "^/([a-z]{2})?/?e/([0-9]+)/?$" /index.php?lng=$1&module=errors&code=$2 break;
      rewrite "^/([a-z]{2})?/?pages/?$" /index.php?lng=$1&module=static break;
      rewrite "^/([a-z]{2})?/?pages/page/([0-9]+)/?$" /index.php?lng=$1&module=static&page=$2 break;
      rewrite "^/([a-z]{2})?/?pages/(.*).html/*$" /index.php?lng=$1&module=static&altname=$2 break;
      rewrite "^/([a-z]{2})?/?pages/([^/]*)/*$" /index.php?lng=$1&module=static&cat_altname=$2 break;
      rewrite "^/([a-z]{2})?/?pages/([0-9]+)-([^/]*)/page/([0-9]+)/?$" /index.php?lng=$1&module=static&cat_join=$2&cat_altname=$3&page=$4 break;
      rewrite "^/([a-z]{2})?/?pages/([^/]*)/(.*).html/*$" /index.php?lng=$1&module=static&category=$2&altname=$3 break;
      rewrite "^/([a-z]{2})?/?blog/?$" /index.php?lng=$1&module=news break;
      rewrite "^/([a-z]{2})?/?blog/page/([0-9]+)/?$" /index.php?lng=$1&module=news&page=$2 break;
      rewrite "^/([a-z]{2})?/?page/([0-9]+)?$" /index.php?lng=$1&module=news&page=$2 break;
      rewrite "^/([a-z]{2})?/?blog/([0-9]+)-(.*).html/*$" /index.php?lng=$1&module=news&altname=$3&join=$2 break;
      rewrite "^/([a-z]{2})?/?blog/([^/]*)/*$" /index.php?lng=$1&module=news&category=$2 break;
      rewrite "^/([a-z]{2})?/?blog/([^/]*)/page/([0-9]+)/?$" /index.php?lng=$1&module=news&category=$2&page=$3 break;
      rewrite "^/([a-z]{2})?/?blog/([^.]+)/([0-9]+)-(.*).html/*$" /index.php?lng=$1&module=news&category=$2&altname=$4&join=$3 break;
      rewrite "^/([a-z]{2})?/?support/?$" /index.php?lng=$1&module=feedback break;
      rewrite "^/([a-z]{2})?/?premium/?$" /index.php?lng=$1&module=premium break;
      rewrite "^/([a-z]{2})?/?donate/?$" /index.php?lng=$1&module=donate break;
      rewrite "^/([a-z]{2})?/?token/([^/]*)/*$" /index.php?lng=$1&module=tokens&code=$2 break;
      rewrite "^/([a-z]{2})?/?n/([^/]*)/*$" /index.php?lng=$1&module=note&note=$2 break;
      rewrite "^/([a-z]{2})?/?payment/?$" /index.php?lng=$1&module=payment break;
      rewrite "^/([a-z]{2})?/?payment/([^/]*)/*$" /index.php?lng=$1&module=payment&service=$2;
      rewrite "^/([a-z]{2})?/?payment/([^/]*)/go/?$" /index.php?lng=$1&module=payment&service=$2&action=go break;
      rewrite "^/([a-z]{2})?/?payment/([^/]*)/([^/]*)/*$" /index.php?lng=$1&module=payment&service=$2&act=$3;
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/site.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
    return 301 https://$host:443$request_uri;
    listen 127.0.0.1:80;
}

server {
    server_name site.ru www.site.ru;
    ssl_certificate "/var/www/httpd-cert/site/site.ru.crtca";
    ssl_certificate_key "/var/www/httpd-cert/site/site.ru.key";
    ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
    ssl_prefer_server_ciphers on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
    add_header Strict-Transport-Security "max-age=31536000;";
    ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
    charset UTF-8;
    index index.php;
    disable_symlinks if_not_owner from=$root_path;
    include /etc/nginx/vhosts-includes/*.conf;
    include /etc/nginx/vhosts-resources/site.ru/*.conf;
    access_log /var/www/httpd-logs/site.ru.access.log;
    error_log /var/www/httpd-logs/site.ru.error.log notice;
    ssi on;
    set $root_path /var/www/site/data/www/site.ru;
    root $root_path;
    listen 127.0.0.1:443 ssl;
    error_page 500 /e/500/;
    error_page 404 /e/404/;
    error_page 403 /e/403/;
    location / {
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
      if ($http_referer ~* "^https?://([^.]+\.)*buttons-for-website\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*semalt\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*simple-share-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*free-share-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*bestwebsitesawards\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*best-seo-offer\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*best-seo-solution\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*makemoneyonline\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*blackhatworth\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*hulfingtonpost\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*bestwebsitesawards\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*o-o-6-o-o\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*ilovevitaly\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*econom\.co"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*humanorightswatch\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*4webmasters\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?://([^.]+\.)*Get-Free-Traffic-Now\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://(site[0-9]+\.)?social-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?://(www[0-9]+\.)?free-social-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Darodar\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Priceg\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*7makemoneyonline\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*webmonetizer\.net"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*dailyrank\.net"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Blackhatworth\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Iskalko\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Lomb\.co"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Lombia\.co"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*hulfingtonpost\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*cenoval\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*o\-o\-6\-o\-o\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*sharebutton\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*s\.click\.aliexpress\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*social\-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*anticrawler\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*site12\.social\-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*adcash\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*adviceforum\.info"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*anticrawler\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*blackhatworth\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*cenokos\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*cityadspix\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*edakgfvwql\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*gobongo\.info"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*iskalko\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*kambasoft\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*luxup\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*myftpupload\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*prodvigator\.ua"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*resellerclub\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*savetubevideo\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*screentoolkit\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*seoexperimenty\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*slftsdybbg\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*socialseet\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*superiends\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*vodkoved\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*websocial\.me"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*ykecwqlixx\.ru"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*76brighton\.co\.uk"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*paparazzistudios\.com\.au"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*powitania\.pl"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*sharebutton\.net"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*tasteidea\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*descargar\-musica\-gratis\.net"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*torontoplumbinggroup\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*cyprusbuyproperties\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*4webmasters\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*ranksonic\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*best\-seo\-solution\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*get\-free\-traffic\-now\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*googlsucks\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Buttons\-for\-your\-website\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*Best\-seo\-offer\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*offers\.bycontext\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*www1\.social\-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*website\-errors\-scanner\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*free\-share\-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*theguardlan\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*buy\-cheap\-online\.info"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*netvibes\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*guardlink\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*trafficmonetize\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*securesuite\.co\.uk"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*securesuite\.net"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*trafficmonetize\.org"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*free-social-buttons\.com"){
        return 403;
      }
      if ($http_referer ~* "100dollars-seo\.com"){
        return 403;
      }
      if ($http_referer ~* "^https?:\/\/([^.]+\.)*forum20\.smailik\.org"){
        return 403;
      }
      if ($http_host ~* "^www\.(.*)$"){
        set $http_host_1 $1;
        rewrite ^(.*)$ https://$http_host_1/$1 redirect;
      }
      rewrite "^/([a-z]{2})/action/logout/?$" /index.php?action=logout&lng=$1 break;
      rewrite "^/([a-z]{2})/?$" /index.php?lng=$1 break;
      rewrite "^/([a-z]{2})?/?e/?$" /index.php?lng=$1&module=errors break;
      rewrite "^/([a-z]{2})?/?e/([0-9]+)/?$" /index.php?lng=$1&module=errors&code=$2 break;
      rewrite "^/([a-z]{2})?/?pages/?$" /index.php?lng=$1&module=static break;
      rewrite "^/([a-z]{2})?/?pages/page/([0-9]+)/?$" /index.php?lng=$1&module=static&page=$2 break;
      rewrite "^/([a-z]{2})?/?pages/(.*).html/*$" /index.php?lng=$1&module=static&altname=$2 break;
      rewrite "^/([a-z]{2})?/?pages/([^/]*)/*$" /index.php?lng=$1&module=static&cat_altname=$2 break;
      rewrite "^/([a-z]{2})?/?pages/([0-9]+)-([^/]*)/page/([0-9]+)/?$" /index.php?lng=$1&module=static&cat_join=$2&cat_altname=$3&page=$4 break;
      rewrite "^/([a-z]{2})?/?pages/([^/]*)/(.*).html/*$" /index.php?lng=$1&module=static&category=$2&altname=$3 break;
      rewrite "^/([a-z]{2})?/?blog/?$" /index.php?lng=$1&module=news break;
      rewrite "^/([a-z]{2})?/?blog/page/([0-9]+)/?$" /index.php?lng=$1&module=news&page=$2 break;
      rewrite "^/([a-z]{2})?/?page/([0-9]+)?$" /index.php?lng=$1&module=news&page=$2 break;
      rewrite "^/([a-z]{2})?/?blog/([0-9]+)-(.*).html/*$" /index.php?lng=$1&module=news&altname=$3&join=$2 break;
      rewrite "^/([a-z]{2})?/?blog/([^/]*)/*$" /index.php?lng=$1&module=news&category=$2 break;
      rewrite "^/([a-z]{2})?/?blog/([^/]*)/page/([0-9]+)/?$" /index.php?lng=$1&module=news&category=$2&page=$3 break;
      rewrite "^/([a-z]{2})?/?blog/([^.]+)/([0-9]+)-(.*).html/*$" /index.php?lng=$1&module=news&category=$2&altname=$4&join=$3 break;
      rewrite "^/([a-z]{2})?/?support/?$" /index.php?lng=$1&module=feedback break;
      rewrite "^/([a-z]{2})?/?premium/?$" /index.php?lng=$1&module=premium break;
      rewrite "^/([a-z]{2})?/?donate/?$" /index.php?lng=$1&module=donate break;
      rewrite "^/([a-z]{2})?/?token/([^/]*)/*$" /index.php?lng=$1&module=tokens&code=$2 break;
      rewrite "^/([a-z]{2})?/?n/([^/]*)/*$" /index.php?lng=$1&module=note&note=$2 break;
      rewrite "^/([a-z]{2})?/?payment/?$" /index.php?lng=$1&module=payment break;
      rewrite "^/([a-z]{2})?/?payment/([^/]*)/*$" /index.php?lng=$1&module=payment&service=$2;
      rewrite "^/([a-z]{2})?/?payment/([^/]*)/go/?$" /index.php?lng=$1&module=payment&service=$2&action=go break;
      rewrite "^/([a-z]{2})?/?payment/([^/]*)/([^/]*)/*$" /index.php?lng=$1&module=payment&service=$2&act=$3;
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/site.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
}

Ответы (1 шт):

Автор решения: Pavel Mayorov

Команда break, используемая вами в директивах rewrite, завершает обработку всех директив модуля ngx_http_rewrite_module, продолжая выполнение запроса в текущем location. А поскольку всё это происходило в том location, который обслуживает статические файлы - вот nginx и отдаёт вам "статический" php-файл.

Видимо, вместо break вам нужно использовать last - эта команда завершает обработку директив модуля ngx_http_rewrite_module, после чего заново вычисляет нужный location.

Кстати, чтобы избежать раскрытия своих исходных кодов в будущем - файл index.php лучше бы убрать за пределы document root.


Но, вообще говоря, использовать rewrite для подобных маршрутов - дурная практика. Зачем серверу формировать строку запроса к файлу index.php, а потом её обратно разбирать - если можно сразу передать управление куда требуется?

Для этих целей лучше использовать инструкцию location. Возьмём для примера вот такую строчку:

rewrite "^/([a-z]{2})?/?blog/page/([0-9]+)/?$" /index.php?lng=$1&module=news&page=$2 break;

Вместо неё можно написать вот так:

location ~ ^/([a-z]{2})?/?blog/page/([0-9]+)/?$ {
    fastcgi_param QUERY_STRING lng=$1&module=news&page=$2
    include php_gateway
}

При этом понадобится конфигурационный файл php_gateway примерно такого содержания:

fastcgi_pass unix:/var/www/php-fpm/site.sock;

fastcgi_param   PHP_ADMIN_VALUE         "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";

fastcgi_param   REQUEST_METHOD          $request_method;
fastcgi_param   CONTENT_TYPE            $content_type;
fastcgi_param   CONTENT_LENGTH          $content_length;

fastcgi_param   SCRIPT_FILENAME         $document_root/index.php; # Путь к скрипту, может быть другим
fastcgi_param   SCRIPT_NAME             /index.php;
fastcgi_param   REQUEST_URI             $request_uri;
fastcgi_param   DOCUMENT_URI            $document_uri;
fastcgi_param   DOCUMENT_ROOT           $document_root;
fastcgi_param   SERVER_PROTOCOL         $server_protocol;

fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;

fastcgi_param   REMOTE_ADDR             $remote_addr;
fastcgi_param   REMOTE_PORT             $remote_port;
fastcgi_param   SERVER_ADDR             $server_addr;
fastcgi_param   SERVER_PORT             $server_port;
fastcgi_param   SERVER_NAME             $server_name;

fastcgi_param   HTTPS                   $https;
fastcgi_param   REDIRECT_STATUS         200;

Ещё лучше, если URI страницы будет разбирать сам index.php (на основе DOCUMENT_URI или REQUEST_URI), тогда конфиг совсем упростится:

location / {
    try_files $uri @php;
}
location /static {
    try_files $uri =404; # мы знаем, что по пути /static может находиться заведомо статическое содержимое, поэтому нет смысла передавать запрос php
}
location @php {
    fastcgi_param QUERY_STRING $query_string;
    include php_gateway
}
→ Ссылка