I have a series of local services all running on different ports. I'd like to expose these services via a nginx reverse proxy. The routing patterns should follow the pattern:
0.0.0.0/app -> locahost:3000
0.0.0.0/api -> locahost:3001
0.0.0.0/db -> locahost:3002
I've tried the following:
http {
sendfile on;
upstream app {
server localhost:3000;
}
upstream api {
server localhost:3001;
}
upstream db {
server localhost:3002;
}
server {
listen 80;
server_name 0.0.0.0
location / {
proxy_pass http://app
}
location /api {
proxy_pass http://api
}
location /db {
proxy_pass http://db
}
}
}
The main issue I'm encountering at the moment is that the location is appended to the final path resulting in:
0.0.0.0/db
->localhost:3002/db
I'm guessing I could use a rewrite rule, but I'm having trouble getting it right.