default-server port 21 inter 10s downinter 15s rise 3 fall 2 slowstart 60s weight 100
server MyServerName 10.10.5.1: check
bind 31.9.36.15:20-21bind 31.9.36.15:49000-49500
bind 31.9.36.15:2222 name 31.9.36.15:2222 ssl crt /var/etc/haproxy/ssl/5752ccd0803c0.pem
bind 31.9.36.15:2222 name 31.9.36.15:2222
uid 80
{% if OPNsense.HAProxy.general.tuning.customOptions|default("") != "" %} # WARNING: pass through options below this line{% for customOpt in OPNsense.HAProxy.general.tuning.customOptions.split("\n") %} {{customOpt}}{% endfor %}{% endif %}
{# ############################### #}{# FRONTENDS #}{# ############################### #}{% if helpers.exists('OPNsense.HAProxy.frontends') %}{% for frontend in helpers.toList('OPNsense.HAProxy.frontends.frontend') %}{% if frontend.enabled == '1' %}# Frontend: {{frontend.name}} ({{frontend.description}})frontend {{frontend.name}}{% if frontend.ssl_enabled == '1' %}{# # collect ssl certs (if configured) #}{% if frontend.ssl_certificates|default("") != "" %}{% set ssl_certs = [] %}{% for cert in frontend.ssl_certificates.split(",") %}{% do ssl_certs.append('crt /var/etc/haproxy/ssl/' ~ cert ~ '.pem') %}{% endfor %}{% endif %}{# # advanced ssl options #}{% if frontend.ssl_customOptions|default("") != "" %}{# # add a space to separate it from other ssl params #}{% set ssl_options = frontend.ssl_customOptions ~ ' ' %}{% endif %}{% endif %}{# # bind/listen configuration #}{% if frontend.bind|default("") != "" %}{% for bind in frontend.bind.split(",") %} bind {{bind}} name {{bind}} {% if frontend.ssl_enabled == '1' and ssl_certs|default("") != "" %}ssl {{ ssl_options }}{{ssl_certs|join(' ')}}{%endif %}{% endfor %}{% endif %}
{% for server in backend.linkedServers.split(",") %}{% set server_data = helpers.getUUID(server) %}{# # collect optional server parameters #}{% set server_options = [] %}{# if# check if health check is enabled #}("") != "" %}{% if healthcheck_enabled == '1' %}{% do server_options.append('check') %}{% do server_options.append('inter ' ~ server_data.checkInterval) %}{# # add all additions from healthchecks here #}{% do server_options.append(healthcheck_additions|join(' ')) if healthcheck_additions.length != '0' %}{% endif %}{# # server weight #}{% do server_options.append('weight ' ~ server_data.weight) if server_data.weight|default("") != "" %}{# # server role/mode #}{% do server_options.append(server_data.mode) if server_data.mode|default("") != "active" %} server {{server_data.name}} {{server_data.address}}:{{server_data.port}} {{server_options|join(' ')}}{% endfor %}{% else %}# Backend (DISABLED): {{backend.description}}{% endif %}{% endfor %}{% endif %}
{% if backend.tuning_defaultserver|default("") != "" %} default-server {{backend.tuning_defaultserver}}{% endif %}
<tuning_defaultserver type="TextField"> <Required>N</Required> </tuning_defaultserver>
<field> <id>backend.tuning_defaultserver</id> <label>Default for server</label> <type>text</type> <help><![CDATA[Default option for all server entries.]]></help> </field>
<bind type="CSVListField"> <Required>Y</Required> <multiple>Y</multiple> <!-- <default>localhost:8080</default> --> <mask>/^((([0-9a-zA-Z._\-\*]+:[0-9]+(-[0-9]+)?)([,]){0,1}))*/u</mask> <ChangeCase>lower</ChangeCase> <ValidationMessage>Please provide a valid listen address, i.e. 127.0.0.1:8080 or www.example.com:443. Portrange as 1210-1220.</ValidationMessage> </bind>
table 66 flushtable 66 add 10.10.12.1/32table 66 add 10.10.12.2/32table 66 add 10.10.12.3/32table 66 add 10.10.12.4/32table 66 listlistadd 10 fwd localhost tcp from table(66) 4480 to any in recv vmx1add 11 fwd localhost tcp from table(66) 22 to any in recv vmx1add 11 fwd localhost tcp from table(66) 21 to any in recv vmx1add 11 fwd localhost tcp from table(66) 49000-49500 to any in recv vmx1list
{% if (helpers.exists('OPNsense.HAProxy.general') and OPNsense.HAProxy.general.enabled|default("0") == "1") %}{% set haproxy_enable = 1 %}{% endif %}firewall_enable="{% if shapers or cp_zones or haproxy_enable %}YES{% else %}NO{% endif %}"
# reload ipfw rules/sbin/ipfw -f /usr/local/etc/ipfw.rulesif [ -f /usr/local/etc/ipfw_custom.rules ]; then /sbin/ipfw -f /usr/local/etc/ipfw_custom.rulesfi
We need to enable IPFW to use some custom rules for HAProxy, for exemple I need that for my backend server: [...]So, I modified /usr/local/opnsense/service/templates/OPNsense/IPFW/rc.conf.d: [...]And /usr/local/etc/rc.ipfw: [...]