Why Is Nginx Randomly Switching My Homepage Back to the "Welcome to Nginx!" Page?

Posted April 22, 2020 272 views

First, a bit of context:

I’ve set up multiple droplets with Nginx and the same application code, under /var/www/, while the public folder is /var/www/html.

I’m load balancing between these droplets using HA Proxy.

I have a maintenance script that needs to run continuously and can be quite resource-intensive at times.

The Issue

I’ve noticed that, sometimes, after running that script, my homepage is switched from the normal application page to the default “Welcome to Nginx!” page.

I find this behavior quite strange and my immediate reaction was to rebuild all these droplets from backup, which immediately solves the problem, which gives me quite a bit of confidence that it’s not a configuration issue, but rather a combination that results in this behavior from Nginx.

The Question

Do you, guys, know any circumstances under which Nginx would switch to the default page and stop serving my index.php page? I don’t have any clues and I also lost all the possible error logs when rebuilding the droplets (note to self: check the logs first next time this happens).

Any clues?


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

Hello, @abgionescu

Could you please let me know if you have examined the Nginx virtual hosts when the issue occurred and also if you’ve found some changes made in the Nginx configuration files as well? This will be your best way to check what’s going on.

The only reason that this will happen if there is a change in the virtual host file for a particular domain name like changing the default document root. If the virtual host is somehow modified or you can see if the file is missing or with wrong content you can then further investigate what caused this in order to find the culprit of the issue.

I will recommend you to check the virtual host configuration if this issue occurs again. You can also simply create a backup for the nginx configuration files so if you ever experience the same problem you can simply revert the change by deleting the default conf and upload the ones you’ve previously saved somewhere safe.

Hope this helps!


@alexdo This happened again last night, so this time I’ve reverted all droplets except one, keeping it intact for investigation.

The interesting part is that I’m only getting the “Welcome to nginx!” screen when accessing the root, like:

However, accessing a deeper path works just fine, for example:

Now, I have compared the
files and they are identical

However, the problem seems to be caused by this file that “magically” appeared in my /var/www/html folder:

Do you have any idea how this can happen?

This is a personal project and I’m the only user of this machine.

edited by MattIPv4