带有上下文(虚拟)路径的ngnix URL

时间:2017-09-29 20:59:29

标签: nginx nginx-reverse-proxy

我的ngix网站配置文件如下。我想将上传路径添加到我的网址

我可以通过http://localhost:8888访问网站,但我想为我的网站网址添加上下文路径,例如http://localhost:8888/MyApp

server {
    listen       8888;
    server_name  localhost;
   location{
        root    "C:/nginx/Share/dist";
    index  index.html index.htm;

   }

}

提前致谢

1 个答案:

答案 0 :(得分:0)

您需要更改此

的基本位置
server {
    listen       8888;
    server_name  localhost;
   location / {
     # since we have nothing on root we can redirect to /MyApp/ if we want
     return 302 /MyApp;
   }

   location /MyApp {
        root    "C:/nginx/Share/dist";
    index  index.html index.htm;

   }
}