I'm running into some issues with my nginx configuration and I'm hoping someone here might be able to help. I'm trying to set up a reverse proxy to redirect traffic from a subdomain to a different server, but I keep getting a 502 Bad Gateway error when I try to access the subdomain.
Here's my configuration file:
`
server {
listen 80;
server_name subdomain.example.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
`
I've checked and the server on localhost:3000 is running, so I'm not sure what the issue could be. Any ideas or suggestions would be greatly appreciated. Thanks in advance!
CodePudding user response:
If you just need to forward, there is no need for upgrade.
location / {
proxy_pass http://localhost:3000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}