I have two domains and I want to run them on single droplet. I have many other websites and I think the issue is with nginx sites-available vim default file. I already have uploaded two folders inside /var/www/domain1/html… and another /var/www/domain2/html/… I have already run npm run build and everything works fine and I believe that the issue is with nginx sites-available vim default file.
My sites-available default file:
server {
listen 80;
server_name domain1.com;
root /var/www/domain1/html/domain1.com/;
location / {
proxy_pass http://127.0.0.1:8080;
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;
}
}
server {
listen 80;
server_name domain2.co.in;
root /var/www/domain2/html/domain2.co.in/;
location / {
proxy_pass http://127.0.0.1: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;
}
}
When i open my domains, on both domains nginx shows # 502 Bad Gateway.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
The 502 error indicates that the port that you’ve specified in the proxy pass rule is not correct.
What is the exact error that you see in your Nginx error log:
Feel free to share the error here so I can advise you furhter!
Best,
Bobby