nginx怎么部署多个多页面应用

我有一个网站www.eee.com,还有两个单页面应用.一个react,一个vue的.
我想把其中一个单页面应用挂载到根目录,也就是wwww.eee.com下,把另外一个挂载到www.eee.com/admin下.

目前conf.d目录里的default.conf配置如下

server {
    listen 80;
    server_name localhost;
    location / {
        root /home/workspace/vue;
        index index.html;
        try_files $uri /index.html;
    }
    location /admin {
        root /home/wordspace/admin;
        index index.html;
        try_files $uri /index.html;
    }
}

根目录下的能正常访问,但是wwww.eee.com/admin下的无法访问.求解决之道

阅读 17.4k
3 个回答
server {
    listen 80;
    server_name localhost;
    location /admin {
        root /home/wordspace/admin;
        index index.html;
        try_files $uri /index.html;
    }
    location / {
        root /home/workspace/vue;
        index index.html;
        try_files $uri /index.html;
    }
}

server {

listen 80;
server_name localhost;
location /admin {
    alias/home/wordspace/admin;
    index index.html;
}
location /test {
    alias /home/workspace/test;
    index index.html;
}

}

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题