Commit 63e7aa88 authored by Lukáš Lalinský's avatar Lukáš Lalinský

Handle domain:port in the Host header

parent fc88c3c8
Pipeline #20408 passed with stage
in 31 seconds
......@@ -117,14 +117,22 @@ frontend fe_proxy
use_backend be_letsencrypt if is_letsencrypt
{{range $site := .Sites}}
{{"\t"}}acl domain_{{.Name}} hdr(Host) -i {{.Domain}}
{{"\t"}}acl domain_{{.Name}}_80 hdr(Host) -i {{.Domain}}:80
{{"\t"}}acl domain_{{.Name}}_443 hdr(Host) -i {{.Domain}}:443
{{range $i, $domain := .AltDomains -}}
{{"\t"}}acl alt_domain_{{$site.Name}}_{{$i}} hdr(Host) -i {{.}}
{{"\t"}}acl alt_domain_{{$site.Name}}_{{$i}}_80 hdr(Host) -i {{.}}:80
{{"\t"}}acl alt_domain_{{$site.Name}}_{{$i}}_443 hdr(Host) -i {{.}}:443
{{end -}}
{{if .EnableAuth -}}
{{"\t"}}acl auth_{{$site.Name}} http_auth(users_{{$site.Name}})
{{"\t"}}http-request auth realm private if domain_{{$site.Name}} !auth_{{$site.Name}}
{{"\t"}}http-request auth realm private if domain_{{$site.Name}}_80 !auth_{{$site.Name}}
{{"\t"}}http-request auth realm private if domain_{{$site.Name}}_443 !auth_{{$site.Name}}
{{range $i, $domain := .AltDomains -}}
{{"\t"}}http-request auth realm private if alt_domain_{{$site.Name}}_{{$i}} !auth_{{$site.Name}}
{{"\t"}}http-request auth realm private if alt_domain_{{$site.Name}}_{{$i}}_80 !auth_{{$site.Name}}
{{"\t"}}http-request auth realm private if alt_domain_{{$site.Name}}_{{$i}}_443 !auth_{{$site.Name}}
{{end -}}
{{end -}}
{{range $i, $route := .Routes -}}
......@@ -132,8 +140,12 @@ frontend fe_proxy
{{end -}}
{{range $i, $route := $site.Routes -}}
{{"\t"}}use_backend be_{{$site.Name}}_{{.Backend}} if domain_{{$site.Name}} route_{{$site.Name}}_{{$i}}{{if $site.EnableAuth}} auth_{{$site.Name}}{{end}}
{{"\t"}}use_backend be_{{$site.Name}}_{{.Backend}} if domain_{{$site.Name}}_80 route_{{$site.Name}}_{{$i}}{{if $site.EnableAuth}} auth_{{$site.Name}}{{end}}
{{"\t"}}use_backend be_{{$site.Name}}_{{.Backend}} if domain_{{$site.Name}}_443 route_{{$site.Name}}_{{$i}}{{if $site.EnableAuth}} auth_{{$site.Name}}{{end}}
{{range $j, $domain := $site.AltDomains -}}
{{"\t"}}use_backend be_{{$site.Name}}_{{$route.Backend}} if alt_domain_{{$site.Name}}_{{$j}} route_{{$site.Name}}_{{$i}}{{if $site.EnableAuth}} auth_{{$site.Name}}{{end}}
{{"\t"}}use_backend be_{{$site.Name}}_{{$route.Backend}} if alt_domain_{{$site.Name}}_{{$j}}_80 route_{{$site.Name}}_{{$i}}{{if $site.EnableAuth}} auth_{{$site.Name}}{{end}}
{{"\t"}}use_backend be_{{$site.Name}}_{{$route.Backend}} if alt_domain_{{$site.Name}}_{{$j}}_443 route_{{$site.Name}}_{{$i}}{{if $site.EnableAuth}} auth_{{$site.Name}}{{end}}
{{end -}}
{{end}}
{{- end}}
......
......@@ -141,19 +141,37 @@ frontend fe_proxy
use_backend be_letsencrypt if is_letsencrypt
acl domain_example hdr(Host) -i example.com
acl domain_example_80 hdr(Host) -i example.com:80
acl domain_example_443 hdr(Host) -i example.com:443
acl alt_domain_example_0 hdr(Host) -i www.example.com
acl alt_domain_example_0_80 hdr(Host) -i www.example.com:80
acl alt_domain_example_0_443 hdr(Host) -i www.example.com:443
acl route_example_0 path_beg /api
acl route_example_1 path_beg /
use_backend be_example_api if domain_example route_example_0
use_backend be_example_api if domain_example_80 route_example_0
use_backend be_example_api if domain_example_443 route_example_0
use_backend be_example_api if alt_domain_example_0 route_example_0
use_backend be_example_api if alt_domain_example_0_80 route_example_0
use_backend be_example_api if alt_domain_example_0_443 route_example_0
use_backend be_example_web if domain_example route_example_1
use_backend be_example_web if domain_example_80 route_example_1
use_backend be_example_web if domain_example_443 route_example_1
use_backend be_example_web if alt_domain_example_0 route_example_1
use_backend be_example_web if alt_domain_example_0_80 route_example_1
use_backend be_example_web if alt_domain_example_0_443 route_example_1
acl domain_example2 hdr(Host) -i example2.com
acl domain_example2_80 hdr(Host) -i example2.com:80
acl domain_example2_443 hdr(Host) -i example2.com:443
acl auth_example2 http_auth(users_example2)
http-request auth realm private if domain_example2 !auth_example2
http-request auth realm private if domain_example2_80 !auth_example2
http-request auth realm private if domain_example2_443 !auth_example2
acl route_example2_0 path_beg /
use_backend be_example2_default if domain_example2 route_example2_0 auth_example2
use_backend be_example2_default if domain_example2_80 route_example2_0 auth_example2
use_backend be_example2_default if domain_example2_443 route_example2_0 auth_example2
backend be_utils
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment