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

feat: basic implementation of ipv6 for ipv6 docker networks

This commit is contained in:
Mehdi Zakaria Benadel 2024-05-03 17:41:07 +02:00 committed by Nicolas Duchon
parent 559ddc7d13
commit a4c694fefc

View File

@ -77,6 +77,7 @@
*/}} */}}
{{- define "container_ip" }} {{- define "container_ip" }}
{{- $ip := "" }} {{- $ip := "" }}
{{- $ipv6 := "" }}
# networks: # networks:
{{- range sortObjectsByKeysAsc $.container.Networks "Name" }} {{- range sortObjectsByKeysAsc $.container.Networks "Name" }}
{{- /* {{- /*
@ -124,13 +125,20 @@
{{- if and . .IP }} {{- if and . .IP }}
{{- $ip = .IP }} {{- $ip = .IP }}
{{- else }} {{- else }}
# /!\ No IP for this network! # /!\ No IPv4 for this network!
{{- end }}
{{- if and . .GlobalIPv6Address }}
{{- $ipv6 = .GlobalIPv6Address }}
{{- else }}
# /!\ No IPv6 for this network!
{{- end }} {{- end }}
{{- else }} {{- else }}
# (none) # (none)
{{- end }} {{- end }}
# IP address: {{ if $ip }}{{ $ip }}{{ else }}(none usable){{ end }} # IPv4 address: {{ if $ip }}{{ $ip }}{{ else }}(none usable){{ end }}
# IPv6 address: {{ if $ipv6 }}{{ $ipv6 }}{{ else }}(none usable){{ end }}
{{- $_ := set $ "ip" $ip }} {{- $_ := set $ "ip" $ip }}
{{- $_ := set $ "ipv6" $ipv6 }}
{{- end }} {{- end }}
{{- /* {{- /*
@ -340,12 +348,18 @@ upstream {{ $vpath.upstream }} {
{{- $args := dict "globals" $.globals "container" $container }} {{- $args := dict "globals" $.globals "container" $container }}
{{- template "container_ip" $args }} {{- template "container_ip" $args }}
{{- $ip := $args.ip }} {{- $ip := $args.ip }}
{{- $ipv6 := $args.ipv6 }}
{{- $args = dict "container" $container "path" $path "port" $port }} {{- $args = dict "container" $container "path" $path "port" $port }}
{{- template "container_port" $args }} {{- template "container_port" $args }}
{{- if $ip }} {{- if or $ip $ipv6 }}
{{- $servers = add1 $servers }} {{- $servers = add1 $servers }}
{{- end }}
{{- if $ip }}
server {{ $ip }}:{{ $args.port }}; server {{ $ip }}:{{ $args.port }};
{{- end }} {{- end }}
{{- if $ipv6 }}
server [{{ $ipv6 }}]:{{ $args.port }};
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- /* nginx-proxy/nginx-proxy#1105 */}} {{- /* nginx-proxy/nginx-proxy#1105 */}}