diff --git a/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/Caddyfile b/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/Caddyfile index 90543e2fd..320eb8619 100644 --- a/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/Caddyfile +++ b/www/caddy/src/opnsense/service/templates/OPNsense/Caddy/Caddyfile @@ -399,8 +399,13 @@ http://{{ domain }} { {% if handle.HandleDirective == "reverse_proxy" and handle.ToPath|default("") != "" %} rewrite * {{ handle.ToPath }}{uri} {% endif %} - {# http:// is the empty default #} - {% set protocol = 'https://' if handle.HttpTls == "1" else 'h2c://' if handle.HttpTls == "2" else '' -%} + {# http:// is the empty default for reverse_proxy #} + {% set protocol = ( + "http://" if handle.HttpTls == "0" and handle.HandleDirective == "redir" else + "https://" if handle.HttpTls == "1" else + "h2c://" if handle.HttpTls == "2" else + '' + ) %} {% set formatted_domains = [] -%} {% for domain in handle.ToDomain.split(',') -%} {% set is_ipv6 = (':' in domain and domain.count(':') >= 2) -%}