Question

Nginx not starting if /var/www is connected storage mountpoint

Last night I added some storage to my droplet and rsynced my entire /var/www directory to the new drive and then put all the proper info in /etc/fstab to mount it at /var/www. I rebooted and nginx would start but wouldn’t serve any pages. I checked all the permissions under /var/www and everything was 100% correct. I checked every little thing I can imagine and nginx just wouldn’t work. Then I changed /etc/fstab to mount the storage at /var/www2 and then I did a ln -s /var/www2 /var/www and it worked just fine. This suggests to me that either nginx doesn’t like the /var/www directory to be a mountpoint, or that something in how digitalocean is handling the VM and the storage is causing the problem. I’m betting on the former but it’s likely a mixture of the 2.

I need to point out that I checked that I hadn’t mounted in the wrong directory, that the file permissions were correct, etc. and comparing the 2 directories revealed zero differences but nginx still wouldn’t run correctly with the mountpoint. I haven’t tried seeing if I could(after moving files) mount at /var/www/html or the like as by the time I got to the point I am now, I just wanted my websites to work again.

I’ve seen other people have the same kind of problem here but there seemed to be issues with how they were mounted or the like whereas I mounted exactly as they were directed and still had the issues. All that said, this isn’t as much of a plea for help and more of a bug report.


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.

Hi there,

What is the exact error that you get when you try to access your page? And do you see any errors in the Nginx error log?

I’ve just tested this with a fresh new Droplet and a Block storage and it seems to be working as expected.

Also, can you verify if you’ve mounted the volume with read and write access? Example:

sudo mount -o defaults,nofail,discard,noatime /dev/disk/by-id/scsi-example /var/www/your_dir

These options include read/write access, executing programs, error suppression for nonexistent devices, and continuous TRIM. mount’s man page (man mount) explains these and all other mount options in detail.

Best,

Bobby

Try DigitalOcean for free

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

Sign up