27.06.2025

How to Install and Configure HAProxy Load Balancer on pfSense Firewall

What is PfSense

pfSense is a powerful, open-source firewall and router platform based on FreeBSD. It is commonly used as a gateway, firewall, traffic shaper, proxy server, and VPN solution. Despite running on FreeBSD under the hood, pfSense offers a full-featured web-based interface that allows administrators to perform almost all management tasks directly from a browser—no command-line experience required. This combination of advanced functionality, ease of use, and deep customization has made pfSense a popular choice for both enterprise environments and home networks for many years.

What is HAProxy

HAProxy is well-known open source load balancer. Originally it was designed for installation on Linux server, but now HAProxy could be installed on much enterprise-level routers, virtual machines etc. In this article I will describe how to install HAProxy on PfSense firewall.

Infrastructure preparing

To show how HAProxy working you need to prepare at least three servers - two as "content contained" server, third as PfSense firewall and HAProxy balancer. So, to do this:

HAProxy installation

To install and configure HAProxy on PfSense server plis follow these steps:

Project files placing and HAProxy cheching

Just look at this article, and deploy the website as prepared in "Website deployment" paragraph. Then check as described in "Balancer checking" paragraph. Result should be similar.

Security tuning

To improve security, you could totally disable any traffic to the content servers via "public" interface, except traffic that comes from your own IP. Return back to the ServerSpace client area, then open each backend server's settings and add two firewall rules - allow traffic from your own IP and deny others. Be careful, to avoid access losing you should place "positive" rules before "negative".

Conclusion

After reading this material, you will have a clear understanding of what pfSense is, including its key features and use cases. Additionally, you will learn how to properly install, configure, and secure the HAProxy plugin on pfSense to enable efficient load balancing and enhance the performance and reliability of your network services.