How to setup NGINX to deploy different Single Page Apps (SPA's... i.e static files) depending on location (under same server_name) with subroutes
Before anything, make sure that you don't have a default
configuration in sites-enabled
this sometimes may lead to unexpected behaviour.
EDIT: Final configuration below
server { listen [::]:80 default_server; listen 80; server_name localhost mydomain 127.0.0.1; location /app { alias /home/user/app/dist/; index index.html; try_files $uri $uri/ index.html =404; } location /auth { alias /home/user/auth/dist/; index index.html; try_files $uri $uri/ index.html =404; } location / { rewrite ^/(.*) /auth?$1 last; }}
It's also worth checking out this question and the nginx docs which explain a bit more the differences between root and alias.