在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Linux/ nginx 反向代理配置后,首頁404

nginx 反向代理配置后,首頁404

本地代理,開發(fā)線上接口。用了nginx反向代理。結(jié)果就是首頁必須帶index.html才能訪問,直接訪問斜杠/是404.

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile      on;
    keepalive_timeout 10;
    upstream serverip {
        server xx.xx.xx.xx;
    }

    server {
        listen  80;
        server_name  a.com;
        
        location =/ {
            add_header X-Frame-Options SAMEORIGIN;
            index index.html;
        }

        location ~* \.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|swf|woff|woff2|ttf|json|svg|cur|vue|otf|eot)$ {
            charset     utf-8;
            root        D:/WWW/app;
            expires     3d;
        }
        
        location / {
            proxy_pass   http://serverip;
        }
    }
}

hosts:

127.0.0.1 a.com

如果我吧配置改成下面的,兩種方式都能訪問了:http://a.com/和http://a.com/index.html

location =/ {
    add_header X-Frame-Options SAMEORIGIN;
    root        D:/WWW/app;
    index index.html;
}

location ~* \.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|swf|woff|woff2|ttf|json|svg|cur|vue|otf|eot)$ {
    charset     utf-8;
    root        D:/WWW/app;
    expires     3d;
}

看了一下日志
D:WWWappnginx/html/index.html" is not found (3: The system cannot find the path specified),

這里說明一下,我的項目目錄:
www/app/index.html
www/app/nginx/*

我想問,一定要配置兩個root么?能配置兩個root么?

回答
編輯回答
夏夕

一定要配置root,不然根本找不到文件

2017年5月15日 09:49