Skip to content

Commit

Permalink
upstream part
Browse files Browse the repository at this point in the history
  • Loading branch information
kulikov-a committed Apr 3, 2023
1 parent 41d7b74 commit 59ea607
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@
<advanced>true</advanced>
<help>If you enable the proxy protocol, an upstream proxy or server will get the client IP and the server port before the real traffic is sent.</help>
</field>
<field>
<id>upstream.keepalive</id>
<label>Keepalive</label>
<type>text</type>
<help>Activates the connections cache for upstream server and sets the max number of idle connections that are preserved in the cache of each worker process. Leave blank or set to 0 to disable. Keepalive support should be enabled at Location settings also.</help>
</field>
<field>
<id>upstream.keepalive_requests</id>
<label>Keepalive requests</label>
<type>text</type>
<advanced>true</advanced>
<help>Sets the maximum number of requests that can be served through one keepalive connection.</help>
</field>
<field>
<id>upstream.keepalive_timeout</id>
<label>Keepalive timeout</label>
<type>text</type>
<advanced>true</advanced>
<help>Sets a timeout in seconds during which an idle keepalive connection to an upstream server will stay open.</help>
</field>
<field>
<id>upstream.host_port</id>
<label>Host headers port</label>
Expand Down
12 changes: 12 additions & 0 deletions www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@
<BlankDesc>Weighted Round Robin</BlankDesc>
<Required>N</Required>
</load_balancing_algorithm>
<keepalive type="IntegerField">
<MinimumValue>0</MinimumValue>
<Required>N</Required>
</keepalive>
<keepalive_requests type="IntegerField">
<MinimumValue>1</MinimumValue>
<Required>N</Required>
</keepalive_requests>
<keepalive_timeout type="IntegerField">
<MinimumValue>1</MinimumValue>
<Required>N</Required>
</keepalive_timeout>
<host_port type="IntegerField">
<MinimumValue>1</MinimumValue>
<Required>N</Required>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ upstream upstream{{ upstream_uuid.replace('-','') }} {
ip_hash;
{% endif %}
{% endif %}
{% if upstream.keepalive is defined and upstream.keepalive|int > 0 %}
keepalive {{ upstream.keepalive }};
{% if upstream.keepalive_requests is defined and upstream.keepalive_requests != '' %}
keepalive_requests {{ upstream.keepalive_requests }};
{% endif %}
{% if upstream.keepalive_timeout is defined and upstream.keepalive_timeout != '' %}
keepalive_timeout {{ upstream.keepalive_timeout }}s;
{% endif %}
{% endif %}
{% for upstream_serveruuid in upstream.serverentries.split(',') %}
{% set upstream_server = helpers.getUUID(upstream_serveruuid) %}
server {% if ':' in upstream_server.server %}[{% endif %}{{ upstream_server.server }}{% if ':' in upstream_server.server %}]{% endif
Expand All @@ -22,6 +31,6 @@ server {% if ':' in upstream_server.server %}[{% endif %}{{ upstream_server.serv
%}{% if upstream_server.fail_timeout is defined %} fail_timeout={{ upstream_server.fail_timeout }}{% endif
%}{% if upstream_server.no_use is defined %} {{ upstream_server.no_use }}{% endif %};
{% endfor %}

}

{% endfor %}

0 comments on commit 59ea607

Please sign in to comment.