Skip to content

Commit

Permalink
feat: handle multiple proxy networks
Browse files Browse the repository at this point in the history
  • Loading branch information
buchdag committed May 8, 2023
1 parent 882e9a3 commit 604d6ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 10 additions & 3 deletions nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@
{{- continue }}
{{- end }}
{{- if eq .Name "host" }}
# {{ .Name }} (host network; using {{ (index $.globals.CurrentContainer.Networks 0).Name }} gateway)
{{- $ip = (index $.globals.CurrentContainer.Networks 0).Gateway }}
{{- continue }}
{{- range sortObjectsByKeysAsc $globals.CurrentContainer.Networks "Name" }}
{{- if .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)
Expand Down
5 changes: 4 additions & 1 deletion test/test_host-network-mode/test_host-network-mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ version: "2"

networks:
net1:
internal: true
net2:

services:
bridge-network:
Expand All @@ -10,7 +12,7 @@ services:
WEB_PORTS: "80"
VIRTUAL_HOST: "bridge-network.nginx-proxy.tld"
networks:
- net1
- net2

host-network:
image: web
Expand All @@ -26,3 +28,4 @@ services:
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
- net1
- net2

0 comments on commit 604d6ce

Please sign in to comment.