Php Nginx经常返回404
我在Ubuntu14.04中有一台带有Nginx1.4的服务器,它运行的是PHP5 fpm。服务器在私有云服务器中有多个域和子域。服务器从流量中获得一致的点击率,这是非常重要的。一切都很好,但Nginx经常返回404,而实际情况并非如此,经过几次尝试后,它返回的是实际输出,而不是404。下面是nginx配置中服务器块之一的示例Php Nginx经常返回404,php,nginx,http-status-code-404,ubuntu-14.04,Php,Nginx,Http Status Code 404,Ubuntu 14.04,我在Ubuntu14.04中有一台带有Nginx1.4的服务器,它运行的是PHP5 fpm。服务器在私有云服务器中有多个域和子域。服务器从流量中获得一致的点击率,这是非常重要的。一切都很好,但Nginx经常返回404,而实际情况并非如此,经过几次尝试后,它返回的是实际输出,而不是404。下面是nginx配置中服务器块之一的示例 server { listen 80; #listen [::]:80; root /var/www/appfolder; in
server {
listen 80;
#listen [::]:80;
root /var/www/appfolder;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name domain-name;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/appfolder;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
请帮助我,我已经搜索了很多,但从来没有得到一个正确的解决方案。
提前感谢您是否有一台或多台服务器提供此内容?既然你说它在多次试用后都能工作,我认为集群中的一台服务器而不是nginx配置有问题。您确定池中的所有服务器都有相同的数据吗。您可能需要一个接一个地测试它们,以查看哪一个具有不一致性只有一台服务器,只是我在nginx config中有多个服务器块,并且此问题将发生在所有域和子域中。