Question

Use two domains on single droplet on website developed with nuxt.js

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.


Submit an answer


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!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
March 22, 2023

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:

tail -100 /var/log/nginx/error.log

Feel free to share the error here so I can advise you furhter!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel