'nginx - route to application via path
I want to use nginx to route to different application via path. I use the following nginx config (minimal example):
server {
listen 80;
http://example.com;
location /myapp/ {
rewrite ^/myapp/(.*)$ /$1 break;
proxy_pass http://localhost:port;
}
}
The request is working but some application do route back the response to the root. Instead of
http://example.com/myapp/*
I end up again on
http://example.com/*
Is there a way, that nginx does route all request from /myapp/* to http://localhost:port/* (application root) and route back the response to /myapp/*
So far I didn't find a solution.
Thanks
Solution 1:[1]
location /myapp/ {
proxy_pass http://localhost:port/;
}
this will be enough to route all requests from http://example.com/myapp/* to http://localhost:port/*
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Makariy |
