I have multiple single page applications running each in their own container under the home directoy which is quite straight forward.
Now I would like to route to those applications under the same dns entry using different paths, e.g.:
domain.com -> defaultAppContainer
domain.com/app1 -> container1
domain.com/app2 -> container2
I do not have the option to rewrite the paths during routing, so I would like for Nginx to listen to the path /app1
or /app2
respectively and serve the applications correctly from there. Currently everything I have tried results in an error.
I have considered two possibilities:
- Proxying the sub path to home using something like
But this does not seem to work for the frontend, I assume some paths are messed up in the request.location /app1 { proxy_pass $host/; }
- Serving all files under the sub route, e.g.:
Where the alias points to the base dir of the built web app. This gives me alocation /app1 { alias root /usr/share/nginx/html/; }
CONN_RESET
error.
Also simply redirecting with a 307 is not an option as that would lead to the client calling the base url without the path, which is then routed to the default app.