diff --git a/pkg/haproxy/instance_test.go b/pkg/haproxy/instance_test.go index 22af13e6c..7e47adc7d 100644 --- a/pkg/haproxy/instance_test.go +++ b/pkg/haproxy/instance_test.go @@ -1462,7 +1462,16 @@ backend d1_app_8080 mode http server s1 172.17.0.11:8080 weight 100 <> -<> +frontend _front_http + mode http + bind :80 + http-request set-var(req.base) base,regsub(:[0-9]+/,/) + http-request redirect scheme https if { var(req.base),map_beg(/etc/haproxy/maps/_global_https_redir.map,_nomatch) yes } + <> + http-request set-var(req.backend) var(req.base),map_beg(/etc/haproxy/maps/_global_http_front.map,_nomatch) + # new header + http-response set-header X-Server HAProxy + use_backend %[var(req.backend)] unless { var(req.backend) _nomatch } default_backend _error404 frontend _front001 mode http diff --git a/rootfs/etc/haproxy/template/haproxy.tmpl b/rootfs/etc/haproxy/template/haproxy.tmpl index 4540f1886..80c46e64f 100644 --- a/rootfs/etc/haproxy/template/haproxy.tmpl +++ b/rootfs/etc/haproxy/template/haproxy.tmpl @@ -674,6 +674,13 @@ frontend _front_http {{- "" }} var(req.base),map_reg({{ $fgroup.HTTPFrontsMap.RegexFile }},_nomatch) {{- "" }} if { var(req.backend) _nomatch } {{- end }} + +{{- /*------------------------------------*/}} +{{- range $snippet := $global.CustomFrontend }} + {{ $snippet }} +{{- end }} + +{{- /*------------------------------------*/}} use_backend %[var(req.backend)] unless { var(req.backend) _nomatch } {{- template "defaultbackend" map $cfg }}