net/haproxy: new option to specify the source address

This commit is contained in:
Frank Wall 2016-06-13 13:51:36 +02:00
parent ee82a139b4
commit 2efb30700a
4 changed files with 31 additions and 0 deletions

View file

@ -40,6 +40,13 @@
<help><![CDATA[Add servers to this backend. Use TAB key to complete typing.]]></help>
<hint>Type server name or choose from list.</hint>
</field>
<field>
<id>backend.source</id>
<label>Source address</label>
<type>text</type>
<help><![CDATA[Sets the source address which will be used when connecting to the server(s).]]></help>
<advanced>true</advanced>
</field>
<field>
<label>Health Checking</label>
<type>header</type>

View file

@ -58,4 +58,11 @@
<help><![CDATA[Provide the TCP communication port to use during check, i.e. 80 or 443.]]></help>
<advanced>true</advanced>
</field>
<field>
<id>server.source</id>
<label>Source address</label>
<type>text</type>
<help><![CDATA[Sets the source address which will be used when connecting to the server.]]></help>
<advanced>true</advanced>
</field>
</form>

View file

@ -408,6 +408,11 @@
<Multiple>Y</Multiple>
<Required>N</Required>
</linkedServers>
<source type="TextField">
<mask>/^((([0-9a-zA-Z._\-\*]+:[0-9]+(-[0-9]+)?)([,]){0,1}))*/u</mask>
<ValidationMessage>Please specify a valid source address, i.e. 10.0.0.1 or loadbalancer.example.com:50000. Port range as start-end, i.e. 10.0.0.1:50000-60000.</ValidationMessage>
<Required>N</Required>
</source>
<healthCheckEnabled type="BooleanField">
<default>1</default>
<Required>Y</Required>
@ -577,6 +582,11 @@
<ValidationMessage>Please specify a value between 500 and 100000.</ValidationMessage>
<Required>Y</Required>
</checkInterval>
<source type="TextField">
<mask>/^((([0-9a-zA-Z._\-\*]+:[0-9]+(-[0-9]+)?)([,]){0,1}))*/u</mask>
<ValidationMessage>Please specify a valid source address, i.e. 10.0.0.1 or loadbalancer.example.com:50000. Port range as start-end, i.e. 10.0.0.1:50000-60000.</ValidationMessage>
<Required>N</Required>
</source>
</server>
</servers>
<healthchecks>

View file

@ -779,6 +779,13 @@ backend {{backend.name}}
{% 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" %}
{# # source address #}
{% if backend.source|default("") != "" %}
{# # prefer backend configuration #}
{% do server_options.append('source ' ~ backend.source) %}
{% elif server_data.source|default("") != "" %}
{% do server_options.append('source ' ~ server_data.source) %}
{% endif %}
server {{server_data.name}} {{server_data.address}}:{% if backend.tuning_noport != '1' %}{{server_data.port}}{% endif %}{% if server_data.checkport|default("") != "" %} port {{server_data.checkport}}{% endif %} {{server_options|join(' ')}}
{% endfor %}