Skip to content

Commit

Permalink
Add custom-frontend to snippet to http:80 frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmoraisjr committed Sep 24, 2019
1 parent 410fa9f commit bcc124b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/haproxy/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,16 @@ backend d1_app_8080
mode http
server s1 172.17.0.11:8080 weight 100
<<backends-default>>
<<frontend-http>>
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-headers>>
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
Expand Down
7 changes: 7 additions & 0 deletions rootfs/etc/haproxy/template/haproxy.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit bcc124b

Please sign in to comment.