Nginx Angular2/Angular routes

喜你入骨 提交于 2019-12-05 00:16:58

Here is my nginx sites-available/myapp

server {
    listen 80;
    listen 80 [::]:80;
    root /my/root/path;
    server_name www.mysite.com mysite.com;

    location /app1/ {
        alias /my/root/path/app1/;
        try_files $uri$args $uri$args/ $uri/ /app1/index.html;
    }

    location /app2/ {
         ...
    }    
}

After setting up the config you want to make your site enabled, run:

sudo ln -s /pathtonginx/sites-available/myapp /pathtonginx/sites-enabled/myapp

The basehref on my index.html

<base href="./">

Hope this helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!