nginx在根目录中附加文件名

时间:2017-08-29 17:42:50

标签: angular nginx

您好我在尝试使用nginx

提供静态内容时获得404

这是我的nginx conf文件

server {
    listen       80;
    server_name  uat.mygymchum.com;
    root /home/rc/gymchum-uat/dist;
    index index.html index.htm;
    location / {
        try_files $uri $uri/ index.html;
    }
    error_page 404 =200 index.html;

    # redirect server error pages to the static page /50x.html
    #error_page   500 502 503 504  /50x.html;
    #location = /50x.html {
     #   root   html;
    #}
}

当我看到error.log文件时,我可以看到此错误。

2017/08/29 17:38:24 [error] 19404#19404: *2 open() "/home/rc/gymchum-uat/distindex.html" failed (2: No such file or directory), client: 123.201.181.85, server: uat.mygymchum.com, request: "GET / HTTP/1.1", host: "uat.mygymchum.com"

1 个答案:

答案 0 :(得分:0)

尝试更改

location / {
    try_files $uri $uri/ index.html;
}

location / {
    try_files $uri $uri/ /index.html;
}

您的默认路径以/开头。所以不要错过静态文件路径