找不到您要查找的页面错误消息-Nginx

时间:2018-11-05 09:42:07

标签: nginx centos

我安装了nginx,它工作正常。 现在,我想创建一个目录并将文件放入其中:

myip/index/index.html

这是Nginx的配置文件:

 server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        location /index{
                root /home/sunyar/data/www;
                index index.html;
        }
        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

这是我的目录,可以通过以下命令找到它:

pwd

/home/sunyar/data/www

在其中有一个index.html文件。

但是当我输入http://192.168.15.9/index/index.html网址时,它会返回以下内容:

enter image description here

1 个答案:

答案 0 :(得分:1)

检查错误日志。在您当前的配置下,应该有一个描述问题的条目。

root指令通过将其值与URI串联来运行,因此可以在/home/sunyar/data/www/index/index.html处搜索文件。

要删除多余的/index/,您将需要使用alias

例如:

location /index {
    alias /home/sunyar/data/www;
}

有关详细信息,请参见this document