mirror of
https://github.com/opnsense/plugins.git
synced 2026-05-28 04:34:15 -04:00
net/haproxy: implement session sync for #165
This commit is contained in:
parent
198c0f7d79
commit
ea600da8fc
4 changed files with 115 additions and 2 deletions
|
|
@ -20,6 +20,58 @@
|
|||
<help><![CDATA[Uncheck to hide all additional introduction pages. Requires a manual page reload for the change to take effect.]]></help>
|
||||
</field>
|
||||
</subtab>
|
||||
<subtab id="haproxy-general-peers" description="Peers / Session Sync">
|
||||
<field>
|
||||
<id>haproxy.general.peers.enabled</id>
|
||||
<label>Enable peers</label>
|
||||
<type>checkbox</type>
|
||||
<help><![CDATA[Enable or disable HAProxy peers. This will propagate entries of any data-types in stick-tables between several HAProxy instances over TCP connections in a multi-master fashion.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<label>Peer 1</label>
|
||||
<type>header</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>haproxy.general.peers.name1</id>
|
||||
<label>Peer name (FQDN)</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[The name of the peer. This is usually the full hostname to make it possible for HAProxy to recognize the local peer. If HAProxy is unable to find the local peer it will fail to start.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>haproxy.general.peers.listen1</id>
|
||||
<label>Listen address (IP)</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[The listen address of the local peer or the address of the remote peer.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>haproxy.general.peers.port1</id>
|
||||
<label>TCP Port</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[The TCP port that should be used for connections to this peer. It must not be used by any other service.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<label>Peer 2</label>
|
||||
<type>header</type>
|
||||
</field>
|
||||
<field>
|
||||
<id>haproxy.general.peers.name2</id>
|
||||
<label>Peer name (FQDN)</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[The name of the peer. This is usually the full hostname to make it possible for HAProxy to recognize the local peer. If HAProxy is unable to find the local peer it will fail to start.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>haproxy.general.peers.listen2</id>
|
||||
<label>Listen address (IP)</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[The listen address of the local peer or the address of the remote peer.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>haproxy.general.peers.port2</id>
|
||||
<label>TCP Port</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[The TCP port that should be used for connections to this peer. It must not be used by any other service.]]></help>
|
||||
</field>
|
||||
</subtab>
|
||||
<subtab id="haproxy-general-global" description="Global Parameters">
|
||||
<field>
|
||||
<label>NOTE: Define global parameters for the HAProxy service. They cannot be overriden.</label>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,38 @@
|
|||
<showIntro type="BooleanField">
|
||||
<default>1</default>
|
||||
</showIntro>
|
||||
<peers>
|
||||
<enabled type="BooleanField">
|
||||
<default>0</default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<name1 type="HostnameField">
|
||||
<Required>N</Required>
|
||||
</name1>
|
||||
<listen1 type="HostnameField">
|
||||
<Required>N</Required>
|
||||
</listen1>
|
||||
<port1 type="IntegerField">
|
||||
<default>1024</default>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
<ValidationMessage>Please specify a value between 1 and 65535.</ValidationMessage>
|
||||
<Required>N</Required>
|
||||
</port1>
|
||||
<name2 type="HostnameField">
|
||||
<Required>N</Required>
|
||||
</name2>
|
||||
<listen2 type="HostnameField">
|
||||
<Required>N</Required>
|
||||
</listen2>
|
||||
<port2 type="IntegerField">
|
||||
<default>1024</default>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
<ValidationMessage>Please specify a value between 1 and 65535.</ValidationMessage>
|
||||
<Required>N</Required>
|
||||
</port2>
|
||||
</peers>
|
||||
<tuning>
|
||||
<root type="BooleanField">
|
||||
<default>0</default>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
<HAProxy VisibleName="HAProxy" cssClass="fa fa-truck fa-fw">
|
||||
<Settings order="10" url="/ui/haproxy/">
|
||||
<GeneralSettings VisibleName="Service Settings" url="/ui/haproxy/#subtab_haproxy-general-settings"/>
|
||||
<PeerSync VisibleName="Peers / Session Sync" url="/ui/haproxy/#subtab_haproxy-general-peers"/>
|
||||
<GlobalParameters VisibleName="Global Parameters" url="/ui/haproxy/#subtab_haproxy-general-global"/>
|
||||
<DefaultParameters VisibleName="Detault Parameters" url="/ui/haproxy/#subtab_haproxy-general-defaults"/>
|
||||
<LoggingConfiguration VisibleName="Logging Configuration" url="/ui/haproxy/#subtab_haproxy-general-logging"/>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,15 @@
|
|||
# Do not edit this file manually.
|
||||
{% if helpers.exists('OPNsense.HAProxy') %}
|
||||
|
||||
{# ############################### #}
|
||||
{# GLOBAL VARIABLES #}
|
||||
{# ############################### #}
|
||||
|
||||
{%- if helpers.exists('OPNsense.HAProxy.general.peers') and OPNsense.HAProxy.general.peers.enabled|default("") == "1" -%}
|
||||
{% set peers_enabled = True %}
|
||||
{% set peers_name = 'opnsense-haproxy-peers' %}
|
||||
{%- endif -%}
|
||||
|
||||
{# ############################### #}
|
||||
{# MACROS #}
|
||||
{# ############################### #}
|
||||
|
|
@ -540,7 +549,8 @@
|
|||
{% endif %}
|
||||
{# # add stick-table #}
|
||||
{% if table_type is defined %}
|
||||
stick-table type {{table_type}} {%if add_length is defined %}len {{data_length}} {% endif %}size {{proxy.stickiness_size}} expire {{proxy.stickiness_expire}} {{stickiness_store}}
|
||||
stick-table type {{table_type}} {%if add_length is defined %}len {{data_length}} {% endif %}size {{proxy.stickiness_size}} expire {{proxy.stickiness_expire}} {{stickiness_store}} {% if peers_enabled is defined %}{{'peers ' ~ peers_name}}{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{# # sticky counters (frontends only) #}
|
||||
{%- if backend == False -%}
|
||||
|
|
@ -558,7 +568,7 @@
|
|||
{%- elif proxy.stickiness_pattern != '' %}
|
||||
stick on src
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
# ERROR: StickTableConfig called with empty data
|
||||
|
|
@ -1058,6 +1068,24 @@ backend {{backend.name}}
|
|||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{# ############################### #}
|
||||
{# PEERS #}
|
||||
{# ############################### #}
|
||||
|
||||
{% if helpers.exists('OPNsense.HAProxy.general.peers') and OPNsense.HAProxy.general.peers.enabled|default("") == "1" %}
|
||||
{# # ensure that no value is missing #}
|
||||
{% if OPNsense.HAProxy.general.peers.name1|default("") != '' and
|
||||
OPNsense.HAProxy.general.peers.listen1|default("") != '' and
|
||||
OPNsense.HAProxy.general.peers.port1|default("") != '' and
|
||||
OPNsense.HAProxy.general.peers.name2|default("") != '' and
|
||||
OPNsense.HAProxy.general.peers.listen2|default("") != '' and
|
||||
OPNsense.HAProxy.general.peers.port2|default("") != '' %}
|
||||
peers {{peers_name}}
|
||||
peer {{OPNsense.HAProxy.general.peers.name1}} {{OPNsense.HAProxy.general.peers.listen1}}:{{OPNsense.HAProxy.general.peers.port1}}
|
||||
peer {{OPNsense.HAProxy.general.peers.name2}} {{OPNsense.HAProxy.general.peers.listen2}}:{{OPNsense.HAProxy.general.peers.port2}}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{# ############################### #}
|
||||
{# STATISTICS #}
|
||||
{# ############################### #}
|
||||
|
|
|
|||
Loading…
Reference in a new issue