By kloster555
I’m running Nginx on Ubuntu 14.04. I have my website installed in the default /usr/share/nginx/html directory. My website works fine for several days and then the system automatically overwrites my websites index.html file with the default Nginx “Welcome to nginx!” index.html file. I have to go back and copy my website’s index.html file again in order for my website to work. I’ve had my website up for a couple of weeks now and this has happened three times. My website will work for a few days and then my index.html file will get overwritten. There is no method to the madness. Does anyone know what might be causing this to happen?
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!
By chance are you running automatic updates or any other automated process on your droplet? Hearing this, my first thought would be that the nginx index.html file is being cached somewhere causing you to see it in the browser but if you’re able to confirm that the file itself has changed via ssh then that would not be the case. Updates should not change the file but /usr/share is not always a location that apt packages will respect changes in. You may want to try copying your files to a different location and updating your configuration in /etc/nginx/sites-enabled/default to point to the new location.
The issue you’re encountering, where the custom index.html file in your Nginx server is getting overwritten by the default Nginx “Welcome to nginx!” page, is unusual and certainly not standard behavior. Here are a few potential causes and steps you can take to troubleshoot and resolve the issue:
Ubuntu systems sometimes have unattended upgrades enabled by default, which could update Nginx and overwrite your index.html file:
Check Unattended Upgrades: Review the configuration of unattended upgrades on your system. The configuration can usually be found in /etc/apt/apt.conf.d/50unattended-upgrades or similar files.
Manual Update Checks: You might have inadvertently updated Nginx through routine system updates that included a new version of Nginx, which could overwrite the file.
Check if there are any cron jobs set up that might be executing a script or command which overwrites your index.html:
/etc/crontab and /etc/cron.*/*) and user-specific ones (crontab -l).If you have any automated deployment scripts, continuous integration, or continuous deployment processes, ensure they’re not overwriting the file:
If you use any web server management software or control panels (like Plesk, cPanel, etc.), ensure they are not set to reset or overwrite files:
Ensure that no external parties have access to your server:
Rare filesystem issues or disk errors could potentially cause file overwrites or loss:
fsck for Linux filesystems) to ensure there are no underlying issues.As a preventive measure, set up a regular backup strategy for your website files:
rsync or backup software to regularly back up your website files.Monitor: After checking the above, closely monitor your system to identify when the overwrite happens. This might help in correlating with any specific system events or cron jobs.
Change File Location: Consider serving your website from a different directory instead of the default Nginx directory. Update the Nginx configuration file to point to the new location. This might prevent overwriting if it’s related to Nginx defaults.
Consult Logs: System logs (/var/log/syslog, /var/log/auth.log, etc.) and Nginx logs (/var/log/nginx/error.log and /var/log/nginx/access.log) can provide clues.
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.