Add caddy proxy
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
[[config]]
|
||||
template = "/code/docker-gen/templates/Caddyfile.tmpl"
|
||||
dest = "/etc/caddy/Caddyfile"
|
||||
onlyexposed = false
|
||||
watch = true
|
||||
wait = "500ms:2s"
|
||||
@@ -0,0 +1,47 @@
|
||||
{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
|
||||
|
||||
{{ $hosts := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
|
||||
|
||||
{{ if not $hosts }}
|
||||
|
||||
127.0.0.1:2015
|
||||
log stdout
|
||||
errors stderr
|
||||
|
||||
{{ else }}
|
||||
|
||||
{{ range $host, $containers := $hosts }}
|
||||
{{ $c := first $containers }}
|
||||
{{ $tlsOff := trim (index $c.Env "VIRTUAL_DISABLE_TLS") }}
|
||||
{{ $port := coalesce $c.Env.VIRTUAL_PORT "80" }}
|
||||
|
||||
http://{{ $host }}, https://{{ $host }} {
|
||||
tls self_signed
|
||||
|
||||
proxy / {
|
||||
policy round_robin
|
||||
transparent
|
||||
header_upstream Host {host}
|
||||
header_upstream X-Real-IP {remote}
|
||||
header_upstream X-Forwarded-For {remote}
|
||||
header_upstream X-Forwarded-Proto {scheme}
|
||||
{{ range $i, $container := $containers }}
|
||||
{{ $addrLen := len $container.Addresses }}
|
||||
{{ range $knownNetwork := $CurrentContainer.Networks }}
|
||||
{{ range $containerNetwork := $container.Networks }}
|
||||
{{ if (and (and (ne $containerNetwork.Name "ingress") (ne $containerNetwork.Name "bridge")) (or (eq $knownNetwork.Name $containerNetwork.Name) (eq $knownNetwork.Name "host"))) }}
|
||||
## Can be connected with "{{ $containerNetwork.Name }}" network
|
||||
upstream {{ $containerNetwork.IP }}:{{ $port }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
}
|
||||
|
||||
gzip
|
||||
log stdout
|
||||
errors stderr
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
Reference in New Issue
Block a user