Using NFS To Centralize Web Site Files For Distributed Web Node Workers
Now that I have multiple web servers, serving copies of the same content by synchronizing between a primary node to the rest of the worker nodes, I need to have a central point for the worker nodes to draw from. This will allow future nodes to be added more easily, at the cost of a little more administration. Currently the web nodes get user information and authentication from a LDAP/Kerberos server, so user information and passwords need to be managed at that server; and now web user files will be offloaded to the NAS. This means that SSH users for each web user must be added to the NAS to allow user file transfers. I also had to enable no_root_squash covered in Issue #243
Add SSH user to FreeNAS¶
From the web GUI, go to and add the web user information, making sure to add the proper home path relative to the location on the FreeNAS box.
Backup web site files¶
Once I had the NAS configured, I copied the original /var/www files to /var/www.orig and then removed the contents of /var/www:
sudo su mv /var/www /var/www.orig cd /var/www rm -rf .
Mount NFS share¶
After backing up and clearing /var/www, it is time to mount the NFS share. I did this by making a folder to mount the share to and then adding this line to /etc/fstab:
Then mounting the share:
192.168.1.100:/mnt/storage/var/www /mnt/nfs/var/www nfs defaults,auto,rw 0 0
- Note: I don't actually have the NFS share mounted on the LXC container, but rather the LXC host then remounted to the container in the containers configuration. This is to allow a direct gigabit connection from the LXC host to the NAS, instead of the LXC container traffic being sent through the router then to the NAS (choke point).
Updated by Daniel Curtis about 8 years ago
- % Done changed from 70 to 90
- Estimated time set to 4.00 h
I came across a permission denied problem on one of the nodes after mounting the share. I went into the web GUI for FreeNAS, then went to and the Number of Server field to 10, to allow more concurrent NFS connections. However I was still getting the permission denied errors when creating files after mounting the share (I could read the files, so I know NFS was working). I went into the and issued the command:
Once I issued the command, I was able to write on the web node in the manner expected.