直接访问 .php文件会被被代理服务器的enable-php.conf优先处理,enable-php.conf处理内容如下:
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
因为 .php 直接被代理服务器处理,导致 .php文件没有被代理到正确的服务器上,造成访问时404,解决办法只需要在代理服务器配置将include enable-php.conf注释即可。
# include enable-php.conf;
location / {
proxy_pass http://xxx.xxx.com/;
}