Configuring HAProxy
Configuring HAProxy in pfSense is extremely simple. Below is the simplest configuration
By default HAProxy is not installed in pfSense you need to install the package, to do this go to System --> Package Manager-->Available Packages
and in the search bar type haproxy
, click search.
and in the search bar type haproxy
, click search.
Next, click install
for the haproxy
package, click confirm
and wait for the installation to complete.
Now we are ready to configure HAProxy
Customization
We start with the backend configuration.
Go to Services --> HAProxy --> Backend
.
Edit HAProxy Backend server pool
Name
- name at your discretion
Server list
- Add server(s) to which traffic will be proxied.
Loadbalancing options (when multiple servers are defined)
Only used when you have multiple backends and need to perform balancing between them
The rest of the settings should be based on your needs, once finalized
Next let’s configure the frontend for HAProxy, go to Services --> HAProxy --> Frontend
.
Click add
and fill out the form.
Name
- As you wish
Status
- Active
External address
- Choose Listen address, you can specify any if you want.
If you want to proxy based on dns name, then you need to configure ACL.
Go to the Default backend, access control lists and actions
section.
Customize Access Control lists
and add a new rule.
Name
- as you wish
Expression
- Host matches
if you want a full match, be careful, if you use name and port, it should be written in the rule. For example demo.example.com:8080
.
Next we customize Actions
, that is what we are going to do. We add a new one with the values.
Action
- Use backend and select your backend
Condition acl names
- here you need to write the name of your ACL.
The rest of the settings are as you wish and need. Click save
Go to Services --> HAProxy --> Settings
, select Enable HAProxy
, set the value for Maximum connections
.
If you need statistics, then customize the Stats tab, 'internal' stats port
section.
Click save and Apply changes
After configuring HAProxy, don’t forget to configure the firewall