Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Hosting 2 domains on one linode using nginx

$
0
0
I have 1 linode instance where I am hosting to websites.

I have an issue where if I do not input www.* then it seems I get redirected to the wrong website.

So the 2 domains I have are sustainablelife.tips and threadcache.com

If I go to www.threadcache.com I am correctly taken to the website. But if I enter threadcache.com then it takes me to sustainablelife.tips.

So here is my nginx server blocks (all within the same sites-available config):

threadcache.com:

server {
server_name threadcache.com www.threadcache.com;
return 301 https://www.threadcache.com/$request_uri;
}

server {
server_name threadcache.com www.threadcache.com;

listen 443 ssl;

ssl_certificate /etc/letsencrypt/live/threadcache.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/threadcache.com/privkey.pem; # managed by Certbot

location / {
proxy_pass http://localhost:3001;
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;
}
}



sustainablelife.tips:

server {
server_name sustainablelife.tips www.sustainablelife.tips;
return 301 https://www.sustainablelife.tips/$request_uri;
}

server {
server_name sustainablelife.tips www.sustainablelife.tips;

listen 443 ssl;

ssl_certificate /etc/letsencrypt/live/sustainablelife.tips-0001/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/sustainablelife.tips-0001/privkey.pem; # managed by Certbot

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;
}
}



Does anyone know why this happens?

Frontend: a Next.js react node application
Backend: PHP Lumen

Let me know if you need any more info.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>