Welcome! Log In Create A New Profile

Advanced

Hosting 2 domains on one linode using nginx

Posted by truetaurus 
Hosting 2 domains on one linode using nginx
March 23, 2020 06:11PM
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.



Edited 1 time(s). Last edit at 03/23/2020 06:12PM by truetaurus.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 195
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready