-
Notifications
You must be signed in to change notification settings - Fork 30
/
caddy.tmpl
36 lines (36 loc) · 1.17 KB
/
caddy.tmpl
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
{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
{{ $host }} {
{{ range $index, $value := $containers }}
{{ $addrLen := len $value.Addresses }}
{{ if eq $addrLen 1 }}
{{ with $address := index $value.Addresses 0 }}
proxy / {{ $address.IP }}:{{ $address.Port }} {
proxy_header Host {host}
proxy_header X-Real-IP {remote}
proxy_header X-Forwarded-Proto {scheme}
}
{{ end }}
{{ else if $value.Env.VIRTUAL_PORT }}
{{ range $i, $address := $value.Addresses }}
{{ if eq $address.Port $value.Env.VIRTUAL_PORT }}
proxy / {{ $address.IP }}:{{ $address.Port }} {
proxy_header Host {host}
proxy_header X-Real-IP {remote}
proxy_header X-Forwarded-Proto {scheme}
}
{{ end }}
{{ end }}
{{ else }}
{{ range $i, $address := $value.Addresses }}
{{ if eq $address.Port "80" }}
proxy / {{ $address.IP }}:{{ $address.Port }} {
proxy_header Host {host}
proxy_header X-Real-IP {remote}
proxy_header X-Forwarded-Proto {scheme}
}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
}
{{ end }}