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

refactor: rename VIRTUAL_HOST_YAML -> VIRTUAL_HOST_MULTIPORTS

This commit is contained in:
Nicolas Duchon 2024-05-03 00:12:14 +02:00
parent 216eae9f70
commit 47e2838e61
No known key found for this signature in database
GPG Key ID: EA3151C66A4D79E7
2 changed files with 12 additions and 9 deletions

View File

@ -495,8 +495,8 @@ proxy_set_header X-Original-URI $request_uri;
proxy_set_header Proxy ""; proxy_set_header Proxy "";
{{- end }} {{- end }}
{{- /* Precompute some information about vhost that use VIRTUAL_HOST_YAML. */}} {{- /* Precompute and store some information about vhost that use VIRTUAL_HOST_MULTIPORTS. */}}
{{- range $vhosts_yaml, $containers := groupBy $globals.containers "Env.VIRTUAL_HOST_YAML" }} {{- range $vhosts_yaml, $containers := groupBy $globals.containers "Env.VIRTUAL_HOST_MULTIPORTS" }}
{{- range $hostname, $vhost := (fromYaml $vhosts_yaml) }} {{- range $hostname, $vhost := (fromYaml $vhosts_yaml) }}
{{- $vhost_data := when (hasKey $globals.vhosts $hostname) (get $globals.vhosts $hostname) (dict) }} {{- $vhost_data := when (hasKey $globals.vhosts $hostname) (get $globals.vhosts $hostname) (dict) }}
{{- $paths := coalesce $vhost_data.paths (dict) }} {{- $paths := coalesce $vhost_data.paths (dict) }}
@ -529,7 +529,7 @@ proxy_set_header Proxy "";
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- /* Precompute some information about vhost that use VIRTUAL_HOST. */}} {{- /* Precompute and store some information about vhost that use VIRTUAL_HOST. */}}
{{- range $hostname, $containers := groupByMulti $globals.containers "Env.VIRTUAL_HOST" "," }} {{- range $hostname, $containers := groupByMulti $globals.containers "Env.VIRTUAL_HOST" "," }}
{{- /* Ignore containers with VIRTUAL_HOST set to the empty string. */}} {{- /* Ignore containers with VIRTUAL_HOST set to the empty string. */}}
{{- $hostname = trim $hostname }} {{- $hostname = trim $hostname }}
@ -537,8 +537,10 @@ proxy_set_header Proxy "";
{{- continue }} {{- continue }}
{{- end }} {{- end }}
{{/* Drop containers with VIRTUAL_HOST_YAML set (VIRTUAL_HOST_YAML takes precedence). */}} {{- /* Drop containers with both VIRTUAL_HOST and VIRTUAL_HOST_MULTIPORTS set
{{- range $_, $containers_to_drop := groupBy $containers "Env.VIRTUAL_HOST_YAML" }} * (VIRTUAL_HOST_MULTIPORTS takes precedence thanks to the previous loop).
*/}}
{{- range $_, $containers_to_drop := groupBy $containers "Env.VIRTUAL_HOST_MULTIPORTS" }}
{{- range $container := $containers_to_drop }} {{- range $container := $containers_to_drop }}
{{- $containers = without $containers $container }} {{- $containers = without $containers $container }}
{{- end }} {{- end }}
@ -575,6 +577,7 @@ proxy_set_header Proxy "";
{{- $_ := set $globals.vhosts $hostname $vhost_data }} {{- $_ := set $globals.vhosts $hostname $vhost_data }}
{{- end }} {{- end }}
{{- /* Loop over $globals.vhosts and update it with the remaining informations about each vhost. */}}
{{- range $hostname, $vhost_data := $globals.vhosts }} {{- range $hostname, $vhost_data := $globals.vhosts }}
{{- $vhost_containers := list }} {{- $vhost_containers := list }}
{{- range $path, $vpath_data := $vhost_data.paths }} {{- range $path, $vpath_data := $vhost_data.paths }}

View File

@ -8,7 +8,7 @@ services:
environment: environment:
WEB_PORTS: "81" WEB_PORTS: "81"
VIRTUAL_HOST: skipped.nginx-proxy.tld VIRTUAL_HOST: skipped.nginx-proxy.tld
VIRTUAL_HOST_YAML: |- VIRTUAL_HOST_MULTIPORTS: |-
notskipped.nginx-proxy.tld: notskipped.nginx-proxy.tld:
defaultport: defaultport:
@ -18,7 +18,7 @@ services:
- "8080" - "8080"
environment: environment:
WEB_PORTS: "80 8080" WEB_PORTS: "80 8080"
VIRTUAL_HOST_YAML: |- VIRTUAL_HOST_MULTIPORTS: |-
port80.a.nginx-proxy.tld: port80.a.nginx-proxy.tld:
port80.b.nginx-proxy.tld: port80.b.nginx-proxy.tld:
port80.c.nginx-proxy.tld: port80.c.nginx-proxy.tld:
@ -31,7 +31,7 @@ services:
- "9000" - "9000"
environment: environment:
WEB_PORTS: "8080 9000" WEB_PORTS: "8080 9000"
VIRTUAL_HOST_YAML: |- VIRTUAL_HOST_MULTIPORTS: |-
port8080.nginx-proxy.tld: port8080.nginx-proxy.tld:
"/": "/":
port: 8080 port: 8080
@ -46,7 +46,7 @@ services:
- "10002" - "10002"
environment: environment:
WEB_PORTS: "10001 10002" WEB_PORTS: "10001 10002"
VIRTUAL_HOST_YAML: |- VIRTUAL_HOST_MULTIPORTS: |-
virtualpaths.nginx-proxy.tld: virtualpaths.nginx-proxy.tld:
"/rootdest": "/rootdest":
port: 10001 port: 10001