Feature #245

Using NFS To Centralize Web Site Files For Distributed Web Node Workers

Added by Daniel Curtis almost 7 years ago. Updated over 5 years ago.

Network Attached Storage
Target version:
Start date:
Due date:
% Done:


Estimated time:
4.00 h
Spent time:


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: /mnt/nfs/var/www nfs defaults,auto,rw 0 0

Then mounting the share:
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).


#1 Updated by Daniel Curtis almost 7 years ago

  • % Done changed from 70 to 90
  • Estimated time set to 4.00

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 Services -> NFS 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 Shell and issued the command:

/etc/rc.d/nfsd restart

Once I issued the command, I was able to write on the web node in the manner expected.

#2 Updated by Daniel Curtis almost 7 years ago

I was also getting error 500 codes when testing the connections of each server. I found that I needed to restart the web services on each web node using:

sudo service apache2 restart

#3 Updated by Daniel Curtis almost 7 years ago

  • Status changed from New to Closed
  • % Done changed from 90 to 100

#4 Updated by Daniel Curtis over 5 years ago

  • Project changed from 38 to GNU/Linux Administration
  • Subject changed from Centralizing Web Site Files For Distributed Web Node Workers to Using NFS To Centralize Web Site Files For Distributed Web Node Workers
  • Category set to Network Attached Storage

Also available in: Atom PDF