Ubuntu 16.04
nginx 版本:nginx/1.16.0
pHp7.2,带池配置
有没有一种正确的方法来对代理后面的 nginx Web 服务器的 FastCGI 部分进行排序?fastcgi_param 行应该放在包含行之前还是之后。这有关系吗?
#-- Pass The PHP Scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
#-- Get REal Ips from proxy
set_real_ip_from 172.16.0.1;
fastcgi_param REMOTE_ADDR $http_x_real_ip;
include denyips.conf;
try_files $uri $uri/ /index.php?$args;
fastcgi_param HTTPS on;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm-mcfilez.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "auto_prepend_file=/home/.sites/mcfilez/httpdocs/zecurity/anti-hammer.php";
fastcgi_read_timeout 600s;
include fastcgi_params;
}
感谢您的帮助。
更新订单
location ~ \.php$ {
set_real_ip_from 172.16.0.1;
include denyips.conf;
include fastcgi_params;
fastcgi_param REMOTE_ADDR $http_x_real_ip;
fastcgi_param PHP_VALUE "auto_prepend_file=/home/.sites/mcfilez/httpdocs/zecurity/anti-hammer.php";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php7.2-fpm-mcfilez.sock;
try_files $uri $uri/ /index.php?$args;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_read_timeout 600s;
}
答案1
大多数 Nginx 语句不受顺序的影响,但也有少数例外。
具体影响 FastCGI 部分的是该fastcgi_param
指令将默默地覆盖参数的值,例如:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $request_filename;
上述操作将保留 的值SCRIPT_FILENAME
,$request_filename
但不会生成任何错误或警告。
使用该指令时,参数的静默覆盖可能会成为一个问题include
,因为重复项可能隐藏在另一个文件中。
作为一般规则,将具体fastcgi_param
陈述后该include
声明。