[#1421] Add support for multiple listening ports in server-stream configuration

This commit is contained in:
Théophile Diot 2025-01-01 11:56:28 +00:00
parent e5bef59d91
commit f0021701c0
No known key found for this signature in database
GPG key ID: FA995104A0BA376A
4 changed files with 27 additions and 20 deletions

View file

@ -15,6 +15,7 @@
- [FEATURE] Add configurable limit for SecRequestBodyNoFilesLimit in ModSecurity via the `MODSECURITY_REQ_BODY_NO_FILES_LIMIT` setting
- [FEATURE] Add multi-user support in `Auth basic` plugin
- [FEATURE] Add support for TCP toggle listening in server-stream configuration (now UDP doesn't replace TCP when activated)
- [FEATURE] Made `LISTEN_STREAM_PORT` and `LISTEN_STREAM_PORT_SSL` settings multiples to allow listening on multiple ports
- [DEPRECATION] Remove `X-XSS-Protection` header from the `header` plugin as it is deprecated
- [DEPS] Updated coreruleset-v4 version to v4.10.0

View file

@ -3,21 +3,21 @@ server {
server_name '{{ SERVER_NAME.split(" ")[0] }}';
# listen
{% if LISTEN_STREAM == "yes" +%}
{% if USE_TCP == "yes" %}
listen 0.0.0.0:{{ LISTEN_STREAM_PORT }} reuseport{% if USE_PROXY_PROTOCOL == "yes" %} proxy_protocol {% endif %};
{% endif %}
{% if USE_UDP == "yes" %}
listen 0.0.0.0:{{ LISTEN_STREAM_PORT }} udp reuseport{% if USE_PROXY_PROTOCOL == "yes" %} proxy_protocol {% endif %};
{% endif %}
{% endif %}
{% if USE_IPV6 == "yes" +%}
{% if USE_TCP == "yes" %}
listen [::]:{{ LISTEN_STREAM_PORT }} reuseport{% if USE_PROXY_PROTOCOL == "yes" %} proxy_protocol {% endif %};
{% endif %}
{% if USE_UDP == "yes" %}
listen [::]:{{ LISTEN_STREAM_PORT }} udp reuseport{% if USE_PROXY_PROTOCOL == "yes" %} proxy_protocol {% endif %};
{% endif %}
{% if LISTEN_STREAM == "yes" %}
{%- set protocols = [] %}
{%- if USE_TCP == "yes" %}{% if protocols.append("tcp") %}{% endif %}{% endif %}
{%- if USE_UDP == "yes" %}{% if protocols.append("udp") %}{% endif %}{% endif %}
{%- for k, listen_stream_port in all.items() if k.startswith("LISTEN_STREAM_PORT") and not k.startswith("LISTEN_STREAM_PORT_SSL") %}
{% for proto in protocols %}
{% set udp_directive = " udp" if proto == "udp" else "" %}
{% set proxy_directive = " proxy_protocol" if USE_PROXY_PROTOCOL == "yes" else "" %}
listen 0.0.0.0:{{ listen_stream_port }}{{ udp_directive }} reuseport{{ proxy_directive }};
{% if USE_IPV6 == "yes" %}
listen [::]:{{ listen_stream_port }}{{ udp_directive }} reuseport{{ proxy_directive }};
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
# custom config

View file

@ -14,9 +14,13 @@ ssl_dhparam /etc/nginx/dhparam;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
{% endif %}
listen 0.0.0.0:{{ LISTEN_STREAM_PORT_SSL }} ssl {% if USE_PROXY_PROTOCOL == "yes" %} proxy_protocol {% endif %};
{% if USE_IPV6 == "yes" +%}
listen [::]:{{ LISTEN_STREAM_PORT_SSL }} ssl {% if USE_PROXY_PROTOCOL == "yes" %} proxy_protocol {% endif %};
{% if LISTEN_STREAM == "yes" %}
{% for k, port in all.items() if k.startswith("LISTEN_STREAM_PORT_SSL") %}
listen 0.0.0.0:{{ port }} ssl{% if USE_PROXY_PROTOCOL == "yes" %} proxy_protocol{% endif %};
{% if USE_IPV6 == "yes" %}
listen [::]:{{ port }} ssl{% if USE_PROXY_PROTOCOL == "yes" %} proxy_protocol{% endif %};
{% endif %}
{% endfor %}
{% endif %}
ssl_certificate_by_lua_block {

View file

@ -269,7 +269,8 @@
"id": "listen-stream-port",
"label": "Listen stream port",
"regex": "^[0-9]+$",
"type": "text"
"type": "text",
"multiple": "listen-stream-ports"
},
"LISTEN_STREAM_PORT_SSL": {
"context": "multisite",
@ -278,7 +279,8 @@
"id": "listen-stream-port-ssl",
"label": "Listen stream port ssl",
"regex": "^[0-9]+$",
"type": "text"
"type": "text",
"multiple": "listen-stream-ports-ssl"
},
"USE_TCP": {
"context": "multisite",