-
Notifications
You must be signed in to change notification settings - Fork 0
/
haproxy.cfg.tpl
33 lines (28 loc) · 916 Bytes
/
haproxy.cfg.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# generated by consul-template
## defaults
global
log stdout local0
stats socket /var/run/haproxy.sock mode 660 level admin expose-fd listeners
defaults
log global
mode http
timeout connect 5000
timeout client 5000
timeout server 5000
## frontend
frontend www
bind *:80
## acl
{{ range $service := services }}{{ range $tag := .Tags }}
acl host_{{ $service.Name }}_{{ $tag }} hdr_beg(host) -i {{ $tag }}.{{ $service.Name }}.service
use_backend backend_{{ $service.Name }}_{{ $tag }} if host_{{ $service.Name }}_{{ $tag }}
{{ end }}{{ end }}
default_backend no-match
## backends
{{ range $service := services }}{{ range $tag := .Tags }}
backend backend_{{ $service.Name }}_{{ $tag }}
{{ range service $service.Name }}{{ if .Tags | contains $tag }}
server {{ .ID }}-{{ .Node }} {{ .Address }}:{{ .Port }}
{{ end }}{{ end }}{{ end }}{{ end }}
backend no-match
http-request deny deny_status 400