Question

Welcome to nginx message after moving site to new subdomain

Posted January 29, 2021 412 views
NginxUbuntuDigitalOcean

I changed the DNS of my sites to point towards a different app and moved my old site to a different subdomain.

However, whenever I try and load the old site on the new subdomain I get the Welcome to Ngix home page. When I move the old site back it its original domain, the site loads perfectly.

Read a bit on this and trying to update my /etc/nginx/sites-available/default to include a link to my subdomain

I opened the default file using:

sudo nano /etc/nginx/sites-available/default

Not sure where exactly to include a link to my subdomain.

This is what I see:

server {
        listen 80;
        listen [::]:80;
        server_name_example.com;
        root /var/www/example.com;
        index index.html
        location / {
           try_fules $uri $uri/ =404;
    }
}

My subdomain is dashboard.site.com

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.

×
Submit an Answer
2 answers

Hi there,

It is possible that the Nginx user does not have permission to access the /var/www/example.com directory. To verify that you could check your Nginx error log:

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

If this is the case make sure to change the owner of the files to the Nginx user.

Let me know how it goes.
Regards,
Bobby

Hi @emmanuelAngler,

Usually, if you want to host multiple domains on one Nginx service, I would recommend using different .conf files in the directory. Having said that, what you can do to make your subdomain load is to add it next to your examle.com domain on your server_name variable line:

server_name subdomain.example.com;

So it should look like this

server {
        listen 80;
        listen [::]:80;
        server_name subdomain.example.com example.com;
        root /var/www/example.com;
        index index.html
        location / {
           try_fules $uri $uri/ =404;
    }
}

If you want to optimize your Nginx app, I would suggest checking out the following DigitalOcean tutorial:

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04#step-5-%E2%80%93-setting-up-server-blocks-(recommended)

Another great tool for generating Nginx config files is ;

https://www.digitalocean.com/community/tools/nginx

by Erin Glass
Nginx is one of the most popular web servers in the world and is responsible for hosting some of the largest and highest-traffic sites on the internet. In this guide, we'll discuss how to get Nginx installed on your Ubuntu 20.04 server.