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
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!
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:
Another great tool for generating Nginx config files is ;
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.