-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhaproxy.ctmpl
38 lines (34 loc) · 1.23 KB
/
haproxy.ctmpl
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
34
35
36
37
38
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
debug
stats timeout 30s
maxconn {{with $maxconn:=key "service/haproxy/maxconn"}}{{$maxconn}}{{else}}4096{{end}}
defaults
log global
option httplog
option dontlognull
mode http{{range ls "service/haproxy/timeouts"}}
timeout {{.Key}} {{.Value}}{{else}}
timeout connect 5000
timeout client 50000
timeout server 50000{{end}}
frontend http-in
bind *:80{{range $i,$a:=services}}{{$path:=.Name}}{{range .Tags}}{{if eq . "rest"}}
acl app{{$i}} path_beg -i /{{$path}}{{end}}{{end}}{{end}}
{{range $i,$a:=services}}{{range .Tags}}{{if eq . "rest"}}
use_backend srvs_app{{$i}} if app{{$i}}{{end}}{{end}}{{end}}
{{range $i,$a:=services}}{{$path:=.Name}}{{range .Tags}}{{if eq . "rest"}}
backend srvs_app{{$i}}
mode http
balance roundrobin
option forwardfor
option httpchk HEAD / HTTP/1.1\r\nHost:localhost
reqrep ^([^\ ]*\ /){{$path}}[/]?(.*) \1\2{{range $c,$d:=service $a.Name}}
server host{{$c}} {{.Address}}:{{.Port}} check{{end}}{{end}}{{end}}{{end}}
listen stats
bind *:1936
stats enable
stats uri /
stats hide-version
stats auth {{env "HAPROXY_USERNAME"}}:{{env "HAPROXY_PASSWORD"}}