I want to forward two different routes internally with nginx. On the server running NGINX two other local servers are running on port 3000 and 4200.
All routes that start with api should be forwarded to the 3000 port. For example domain.com/api is routed internally to localhost:3000/api and domain.com/api/v1 is routed to localhost:3000/api/v1 and so on.
Everything that is not api is routed to 4200 including attachments. domain.com/ -> localhost:4200 domain.com/data -> localhost:4200/data
I don't understand yet how to define the location blocks. e.g. /data is always evaluated as 404, because it is neither / nor /api. The api route works completely though. Especially the routing of the / route is interesting. Otherwise I can keep the API as a subdomain.
Currently I have the following variant.
location /api {
proxy_pass http://127.0.0.1:3000;
}
location / {
proxy_pass http://127.0.0.1:4200;
}