|
1 | 1 | {{/* Template for CIDRS: Required for reuse in Http and Https frontends */}}
|
2 | 2 | {{define "CIDR_ACLS"}}{{if ls "/global/acls"}}{{ range $acl := gets "/global/acls/*/cidr/src" }}
|
3 |
| - acl {{$acl.Key | parent | parent | base}} src {{$acl.Value}} |
| 3 | + acl {{$acl.Key | dir | dir | base}} src {{$acl.Value}} |
4 | 4 | {{ end }}{{ end }}{{ end }}
|
5 | 5 |
|
6 | 6 | {{/* Global Black Listing */}}
|
|
14 | 14 | {{ end }}{{ end }}
|
15 | 15 |
|
16 | 16 | {{/* Template for use_backends. */}}
|
17 |
| -{{define "USE_BACKENDS"}}{{ range $host := ls "/hosts" }}{{if printf "/hosts/%s/locations" $host | ls }}{{ range $path := printf "/hosts/%s/locations/*/path" $host | gets}}{{ $pathName := $path.Key | parent | base }} |
| 17 | +{{define "USE_BACKENDS"}}{{ range $host := ls "/hosts" }}{{if printf "/hosts/%s/locations" $host | ls }}{{ range $path := printf "/hosts/%s/locations/*/path" $host | gets}}{{ $pathName := $path.Key | dir | base }} |
18 | 18 | {{/* Do not include backends if upstream is empty or if it does not exist */}}
|
19 | 19 | {{ $upstream := printf "/hosts/%s/locations/%s/upstream" $host $pathName | getv}}{{ $endpoints := printf "/upstreams/%s/endpoints" $upstream | ls}}
|
20 | 20 | {{if and $upstream $endpoints}}use_backend {{printf "/hosts/%s/locations/%s/upstream" $host $pathName | getv }} if __host-{{$host}} __path-{{$host}}-{{$pathName}}{{ end }}
|
21 | 21 | {{ end }}{{ end }}{{ end }}{{ end }}
|
22 | 22 |
|
23 | 23 | {{/* Template for force ssl */}}
|
24 |
| -{{define "FORCE_SSL"}}{{ range $host := ls "/hosts" }}{{if printf "/hosts/%s/locations" $host | ls }}{{ range $path := printf "/hosts/%s/locations/*/path" $host | gets}}{{ $pathName := $path.Key | parent | base }} |
| 24 | +{{define "FORCE_SSL"}}{{ range $host := ls "/hosts" }}{{if printf "/hosts/%s/locations" $host | ls }}{{ range $path := printf "/hosts/%s/locations/*/path" $host | gets}}{{ $pathName := $path.Key | dir | base }} |
25 | 25 | {{ if printf "/hosts/%s/locations/%s" $host $pathName | ls}}{{ if printf "/hosts/%s/locations/%s/force-ssl" $host $pathName | ls}}{{ if printf "/hosts/%s/locations/%s/force-ssl" $host $pathName | getv | eq "true"}}
|
26 | 26 | #Force SSL for $host/$pathName
|
27 | 27 | redirect scheme https code 301 if !{ ssl_fc } __host-{{$host}} __path-{{$host}}-{{$pathName}}
|
|
33 | 33 | {{ range $host := ls "/hosts" }}
|
34 | 34 | #Host ACL for host:{{$host}}
|
35 | 35 | acl __host-{{$host}} hdr_dom(host) -i -m str {{$host}} {{ if printf "/hosts/%s/aliases" $host | ls }}{{range $alias := printf "/hosts/%s/aliases/*" $host | getvs }}{{$alias}} {{ end }}{{ end }}
|
36 |
| - {{ range $path := printf "/hosts/%s/locations/*/path" $host | gets}}{{ $pathName := $path.Key | parent | base }} |
| 36 | + {{ range $path := printf "/hosts/%s/locations/*/path" $host | gets}}{{ $pathName := $path.Key | dir | base }} |
37 | 37 | #Path ACL for host:{{$host}} and path:{{$path}}
|
38 | 38 | acl __path-{{$host}}-{{$pathName}} path_beg {{$path.Value}}
|
39 | 39 | {{/* Deny Requests if host, path matches and any of cidrs matches */}}
|
|
56 | 56 | global
|
57 | 57 | log /dev/log local0
|
58 | 58 | log /dev/log local1 notice
|
| 59 | + log-tag {{getenv "LOG_IDENTIFIER"}} |
59 | 60 | chroot /var/lib/haproxy
|
60 | 61 | stats socket /run/haproxy/admin.sock mode 660 level admin
|
61 | 62 | stats timeout 30s
|
@@ -184,7 +185,7 @@ backend {{ $upstream }}
|
184 | 185 | {{ $health_interval := printf "%s/interval" $health }}
|
185 | 186 | {{ if $health_uri | ls }}option httpchk GET {{ $health_uri | getv }}{{ end }}
|
186 | 187 | {{ if $health_timeout | ls }}timeout check {{ $health_timeout | getv }}{{ end }}
|
187 |
| - {{ range $endpoint := printf "/upstreams/%s/endpoints/*" $upstream | gets }}{{ $endpointName := $endpoint.Key | parent | base }} |
| 188 | + {{ range $endpoint := printf "/upstreams/%s/endpoints/*" $upstream | gets }}{{ $endpointName := $endpoint.Key | dir | base }} |
188 | 189 | server {{ $endpointName }} {{ $endpoint.Value }} check inter {{ if $health_interval | ls }}{{$health_interval | getv}}{{ else }}2m{{ end }}
|
189 | 190 | {{ end }}
|
190 | 191 | {{ end }}{{ end }}
|
|
0 commit comments