1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2025-02-24 09:48:14 +00:00

feat: handle multiple proxy networks

This commit is contained in:
Nicolas Duchon 2023-05-09 00:58:05 +02:00
parent 882e9a3b3c
commit b88d33d2f3
No known key found for this signature in database
GPG Key ID: EA3151C66A4D79E7
2 changed files with 14 additions and 4 deletions

View File

@ -68,10 +68,17 @@
{{- continue }} {{- continue }}
{{- end }} {{- end }}
{{- if eq .Name "host" }} {{- if eq .Name "host" }}
# {{ .Name }} (host network; using {{ (index $.globals.CurrentContainer.Networks 0).Name }} gateway) {{- range sortObjectsByKeysAsc $.globals.CurrentContainer.Networks "Name" }}
{{- $ip = (index $.globals.CurrentContainer.Networks 0).Gateway }} {{- if and . .Gateway }}
# container is in host network mode, using {{ .Name }} gateway IP
{{- $ip = .Gateway }}
{{- break }}
{{- end }}
{{- end }}
{{- if $ip }}
{{- continue }} {{- continue }}
{{- end }} {{- end }}
{{- end }}
{{- if and (not (index $.globals.networks .Name)) (not $.globals.networks.host) }} {{- if and (not (index $.globals.networks .Name)) (not $.globals.networks.host) }}
# {{ .Name }} (unreachable) # {{ .Name }} (unreachable)
{{- continue }} {{- continue }}

View File

@ -2,6 +2,8 @@ version: "2"
networks: networks:
net1: net1:
internal: true
net2:
services: services:
bridge-network: bridge-network:
@ -10,7 +12,7 @@ services:
WEB_PORTS: "80" WEB_PORTS: "80"
VIRTUAL_HOST: "bridge-network.nginx-proxy.tld" VIRTUAL_HOST: "bridge-network.nginx-proxy.tld"
networks: networks:
- net1 - net2
host-network: host-network:
image: web image: web
@ -26,3 +28,4 @@ services:
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
networks: networks:
- net1 - net1
- net2