Question

Nginx always opening default file in /var/www/html for Domain

I am not able to change the directory for the domain. it is working for IP but not for domain linked via DNS. when i open the domain, it is always loading default file in /var/www/html. i tried steps from below URL.

https://www.digitalocean.com/community/tutorials/how-to-move-an-nginx-web-root-to-a-new-location-on-ubuntu-18-04

any help would be appreciated.

TIA :)


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.

KFSys
Site Moderator
Site Moderator badge
August 8, 2023

Heya @09c265c50be54e97be17bc554e6068,

Have you created a separate nginx config for your Domain? In that config you need to specify a server_name which would be your Domain:

server_name your_domain www.your_domain
root /var/www/your_domain/html;

After having a separate config for your Domain with the above, then loading your Domain should point you to the right directory.

You can check more here:

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

Try DigitalOcean for free

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

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

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

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

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