Tricks to Running HAProxy on pfSense Embedded
HAProxy is available as an addon module for pfSense 1.2.3. This makes it really easy to have pfSense control the gateway and load balancing. There are a couple of tricks to getting it all up and running.
Although everything looked good in the webgui HAProxy just wouldn’t start. After logging in it seemed that there were 2 problems, firstly as mentioned in the forums the IP addresses must be an interface or CARP addresses not Virtual IPs for HAProxy to work and secondly the file descriptor limits have to be increased. To increase the file descriptor limits run the following commands from a shell on pfSense.
mount -o rw /dev/ufs/pfsense1 /
echo >> /etc/sysctl.conf
echo '# File descriptor limits for HAProxy' >> /etc/sysctl.conf
kern.maxfiles=2000011 >> /etc/sysctl.conf
kern.maxfilesperproc=2000011 >> /etc/sysctl.conf
sysctl kern.maxfiles=2000011
sysctl kern.maxfilesperproc=2000011
mount -o ro /dev/ufs/pfsense1 /
The mount commands are only needed if running on embedded pfSense to
make the CF card writeable while we make the changes then make it read
only again once we are done. The echo commands add the new limits to
/etc/sysctl.conf
so the settings persist and the sysctl commands make
them apply now.
I haven’t tested to see if the file descriptor issue effects the non embedded version of pfSense, feel free to let me (and others know) via the comments.