mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-06-30 22:05:46 +00:00
Merge pull request #2222 from rot169/support-hostnet-containers
Support containers running --net=host (#1537)
This commit is contained in:
18
nginx.tmpl
18
nginx.tmpl
@ -67,6 +67,24 @@
|
||||
# {{ .Name }} (ignored)
|
||||
{{- continue }}
|
||||
{{- end }}
|
||||
{{- if eq .Name "host" }}
|
||||
{{- /* Handle containers in host nework mode */}}
|
||||
{{- if (index $.globals.networks "host") }}
|
||||
# both container and proxy are in host network mode, using localhost IP
|
||||
{{- $ip = "127.0.0.1" }}
|
||||
{{- continue }}
|
||||
{{- end }}
|
||||
{{- range sortObjectsByKeysAsc $.globals.CurrentContainer.Networks "Name" }}
|
||||
{{- if and . .Gateway }}
|
||||
# container is in host network mode, using {{ .Name }} gateway IP
|
||||
{{- $ip = .Gateway }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $ip }}
|
||||
{{- continue }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if and (not (index $.globals.networks .Name)) (not $.globals.networks.host) }}
|
||||
# {{ .Name }} (unreachable)
|
||||
{{- continue }}
|
||||
|
Reference in New Issue
Block a user