From 6b7098c1839f2723718e795572638714ef0efa36 Mon Sep 17 00:00:00 2001 From: Fabian Franz BSc Date: Mon, 10 Dec 2018 16:49:32 +0100 Subject: [PATCH] www/nginx: add proxy protocol support and improve whitelist handling of WAF (#1051) * www/nginx: add proxy protocol support and improve whitelist handling of WAF * www/nginx: fix a defined test * www/nginx: add entry to release note * www/nginx: add entry to release note, simplify existence check --- www/nginx/pkg-descr | 4 ++ .../OPNsense/Nginx/forms/httpserver.xml | 24 +++++++ .../OPNsense/Nginx/forms/streamserver.xml | 15 +++++ .../OPNsense/Nginx/forms/upstream.xml | 7 ++ .../mvc/app/models/OPNsense/Nginx/Nginx.xml | 66 ++++++++++++++++++- .../templates/OPNsense/Nginx/http.conf | 14 +++- .../templates/OPNsense/Nginx/naxsirule.conf | 4 ++ .../templates/OPNsense/Nginx/streams.conf | 10 ++- 8 files changed, 137 insertions(+), 7 deletions(-) diff --git a/www/nginx/pkg-descr b/www/nginx/pkg-descr index f77fac368..958626fdd 100644 --- a/www/nginx/pkg-descr +++ b/www/nginx/pkg-descr @@ -13,6 +13,10 @@ Plugin Changelog * Add proxy options for ignore client abort and disabling buffering * Add logviewer support for streams * Fix charset is not defined bug (contributed by ccesario [1]) +* Add an existence check for locations +* Add PROXY protocol for HTTP and Streams frontend +* Add PROXY backend support for Streams +* Add support for better whitelist rules in the WAF [1] https://github.com/opnsense/plugins/pull/1035 diff --git a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/httpserver.xml b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/httpserver.xml index 5c5c9a4e8..50282f3d5 100644 --- a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/httpserver.xml +++ b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/httpserver.xml @@ -9,6 +9,30 @@ text + + httpserver.proxy_protocol + + checkbox + true + If you enable the proxy protocol, a downstream proxy can send the client IP and port before the real traffic is set. + + + httpserver.trusted_proxies + + true + + select_multiple + true + Enter a list of IP addresses or CIDR networks which are allowed to override the source IP address using the specified header. + + + httpserver.real_ip_source + + + true + X-Real-IP and X-Forwarded-For are HTTP headers, while PROXY protocol is a protocol which needs to be enabled. + dropdown + httpserver.servername diff --git a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/streamserver.xml b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/streamserver.xml index 23a264d94..e2f6044b0 100644 --- a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/streamserver.xml +++ b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/streamserver.xml @@ -9,6 +9,21 @@ checkbox + + streamserver.proxy_protocol + + checkbox + If you enable the proxy protocol, a downstream proxy can send the client IP and port before the real traffic is set. + + + httpserver.trusted_proxies + + true + + select_multiple + true + Enter a list of IP addresses or CIDR networks which are allowed to override the source IP address using the specified header. + streamserver.certificate diff --git a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/upstream.xml b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/upstream.xml index f2303d759..091431302 100644 --- a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/upstream.xml +++ b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/forms/upstream.xml @@ -10,6 +10,13 @@ select_multiple + + upstream.proxy_protocol + + checkbox + true + 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. + upstream.tls_enable diff --git a/www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml b/www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml index 8458931bc..8b7e3b827 100644 --- a/www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml +++ b/www/nginx/src/opnsense/mvc/app/models/OPNsense/Nginx/Nginx.xml @@ -74,6 +74,10 @@ Y Y + + 0 + Y + Y 0 @@ -439,8 +443,16 @@ Y - Y + N /^[^"]+$/ + + + This field must be set. + SetIfConstraint + match_type + id + + Y @@ -455,8 +467,16 @@ /^[^"]+$/ - Y + N /^[^"]+$/ + + + This field must be set. + SetIfConstraint + match_type + id + + Y @@ -470,8 +490,16 @@ Y - Y + N 8 + + + This field must be set. + SetIfConstraint + match_type + id + + Y @@ -514,6 +542,23 @@ N 443 + + 0 + Y + + + N + /^((?:\d+\.){3,3}\d+|[a-f0-9\:]+)(?:\/\d+)?(,?(?:(?:(\d+\.){3,3}\d+|[a-f0-9\:]+)(?:\/\d+)?))*$/i + Y + + + + X-Real-IP (default) + X-Forwarded-For + PROXY Protocol + + N +