From a01fd048ae6d5db323473d9fd8c574da18c45388 Mon Sep 17 00:00:00 2001 From: Monviech <79600909+Monviech@users.noreply.github.com> Date: Wed, 3 Jul 2024 14:24:31 +0200 Subject: [PATCH] www/caddy: Add HTTP version selection. Mark NTLM as deprecated. Theoretically, it only hard codes the transport http to versions 1.1. So, NTLM could be replaced by setting the http version to that value. At the same time, this also adds support for HTTP/3 to the upstream, which is included in the latest Caddy version 2.8.4 we have rolled out. (#4071) --- .../controllers/OPNsense/Caddy/forms/dialogHandle.xml | 9 ++++++++- .../src/opnsense/mvc/app/models/OPNsense/Caddy/Caddy.xml | 8 ++++++++ .../mvc/app/views/OPNsense/Caddy/reverse_proxy.volt | 1 + .../opnsense/service/templates/OPNsense/Caddy/Caddyfile | 8 +++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/dialogHandle.xml b/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/dialogHandle.xml index cbd484ae8..e8013cd00 100644 --- a/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/dialogHandle.xml +++ b/www/caddy/src/opnsense/mvc/app/controllers/OPNsense/Caddy/forms/dialogHandle.xml @@ -109,11 +109,18 @@ checkbox + + handle.HttpVersion + + dropdown + + handle.HttpNtlm checkbox - + + true handle.HttpTlsInsecureSkipVerify diff --git a/www/caddy/src/opnsense/mvc/app/models/OPNsense/Caddy/Caddy.xml b/www/caddy/src/opnsense/mvc/app/models/OPNsense/Caddy/Caddy.xml index db4388ee4..b44276dc2 100644 --- a/www/caddy/src/opnsense/mvc/app/models/OPNsense/Caddy/Caddy.xml +++ b/www/caddy/src/opnsense/mvc/app/models/OPNsense/Caddy/Caddy.xml @@ -327,6 +327,14 @@ + + HTTP/1.1, HTTP/2 + + HTTP/1.1 + HTTP/2 + HTTP/3 + + diff --git a/www/caddy/src/opnsense/mvc/app/views/OPNsense/Caddy/reverse_proxy.volt b/www/caddy/src/opnsense/mvc/app/views/OPNsense/Caddy/reverse_proxy.volt index e3b559237..41622bac3 100644 --- a/www/caddy/src/opnsense/mvc/app/views/OPNsense/Caddy/reverse_proxy.volt +++ b/www/caddy/src/opnsense/mvc/app/views/OPNsense/Caddy/reverse_proxy.volt @@ -336,6 +336,7 @@ {{ lang._('Fail Duration') }} {{ lang._('Forward Auth') }} {{ lang._('TLS') }} + {{ lang._('HTTP Version') }} {{ lang._('TLS CA') }} {{ lang._('TLS Server Name') }} {{ lang._('NTLM') }} diff --git a/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/Caddyfile b/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/Caddyfile index 795ba8f62..592f552d5 100644 --- a/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/Caddyfile +++ b/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/Caddyfile @@ -354,6 +354,7 @@ # - HttpTlsTrustedCaCerts (string, optional): The config extracted name of a CA certificate. # - HttpTlsServerName (string, optional): Specifies the server name for the TLS handshake. # - PassiveHealthFailDuration (integer, optional): Enables passive health checks when set > 0. +# - HttpVersion (string, optional): Choose HTTP version. Empty (default) is 1.1 and 2. #} {% macro reverse_proxy_configuration(handle) %} {{ handle.HandleType }} {{ handle.HandlePath|default("") }} { @@ -373,7 +374,7 @@ {% if handle.PassiveHealthFailDuration|default("") %} fail_duration {{ handle.PassiveHealthFailDuration }}s {% endif %} - {% if handle.HttpTls|default("0") == "1" or handle.HttpTlsInsecureSkipVerify|default("0") == "1" or handle.HttpTlsTrustedCaCerts|default("") != "" or handle.HttpTlsServerName|default("") != "" %} + {% if handle.HttpTls|default("0") == "1" or handle.HttpTlsInsecureSkipVerify|default("0") == "1" or handle.HttpTlsTrustedCaCerts or handle.HttpTlsServerName or handle.HttpVersion %} {% if handle.HttpNtlm|default("0") == "1" %} transport http_ntlm { {% if handle.HttpTls|default("0") == "1" %} @@ -391,6 +392,11 @@ } {% else %} transport http { + {# The model does not allow to set a single number as option directly, so we have to map them. #} + {% set version_map = {'http1': 1.1, 'http2': 2, 'http3': 3} %} + {% if handle.HttpVersion %} + versions {{ version_map[handle.HttpVersion] }} + {% endif %} {% if handle.HttpTls|default("0") == "1" %} tls {% endif %}