尝试仅通过端口80上的IP访问我的服务器时出现问题.
这是我的默认配置:
# You may add here your
# server {
# ...
# }
# statements for each of your virtual hosts to this file
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
# Document root
root /var/www/default;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file,then
# as directory,then fall back to index.html
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/Nginx/naxsi.rules
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}
# Only for Nginx-naxsi : process denied requests
#location /RequestDenied {
# For example,return an error code
#return 418;
#}
#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 /usr/share/Nginx/www;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.PHP${
# 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;
# include fastcgi_params;
#}
# deny access to .htaccess files,if Apache's document root
# concurs with Nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
在/ var / www / default里面有一个名为index.html的文件.现在到了奇怪的部分.如果我将listen端口更改为8888,则Nginx会正确地为index.html提供服务.我只有3个站点而其他站点是虚拟主机,因此它们没有listen指令.我现在将/ var / www / default文件夹设置为chmod 777,仍然在端口80上返回404.
编辑:
我检查了Nginx的错误日志,并说明了这一点:
2014/04/08 09:30:21 [错误] 3349#0:* 1“/etc/Nginx/html/index.html”未找到
然后问题是,这个配置在哪里说/etc/Nginx/html/index.html是默认的根?
最佳答案
原文链接:https://www.f2er.com/nginx/435636.html