Feature #245
Using NFS To Centralize Web Site Files For Distributed Web Node Workers
Description
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 Account -> User -> Add User 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
mount /mnt/nfs/var/www
- 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).