I have two nextjs apps running on port 3000 and 3001 and my Nginx config is as follows
events {
worker_connections 1024;
}
http {
server {
listen 8080;
server_name http://localhost:8080;
proxy_buffering off;
proxy_http_version 1.1;
location / {
proxy_pass http://localhost:3000/;
proxy_redirect off;
}
location ^~ /app {
proxy_pass http://localhost:3001/;
proxy_redirect off;
}
}
}
NextJS app on port 3000 works fine.
- When I visit localhost:8080 - it loads the app from port 3000 as expected.
But it is impossible to access the second app on Port 3001 through nginx URL
- When I visit localhost:8080/app - it loads the app from port 3000.
- When I visit localhost:8080/app/ - it changes the URL to localhost:8080 and loads the app from port 3000.
- When I visit localhost:8080/app/login - It changes the URL to localhost:8080/login and loads a 404 since app on port 3000 does not have a login route.
Is there something that I am missing in this configuration?