stoobly-agent 1.7.2__py3-none-any.whl → 1.8.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- stoobly_agent/__init__.py +1 -1
- stoobly_agent/app/cli/scaffold/constants.py +0 -3
- stoobly_agent/app/cli/scaffold/docker/constants.py +0 -1
- stoobly_agent/app/cli/scaffold/docker/service/builder.py +10 -4
- stoobly_agent/app/cli/scaffold/docker/service/configure_gateway.py +50 -23
- stoobly_agent/app/cli/scaffold/docker/workflow/decorators_factory.py +2 -2
- stoobly_agent/app/cli/scaffold/service_config.py +10 -0
- stoobly_agent/app/cli/scaffold/service_workflow_validate_command.py +0 -29
- stoobly_agent/app/cli/scaffold/templates/__init__.py +2 -2
- stoobly_agent/app/cli/scaffold/templates/app/gateway/.docker-compose.base.template.yml +5 -5
- stoobly_agent/app/cli/scaffold/templates/build/services/build/mock/.configure +6 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/build/record/.configure +6 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/build/test/.configure +6 -0
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/mock/.configure +0 -6
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/record/.configure +0 -6
- stoobly_agent/app/cli/scaffold/templates/build/services/entrypoint/test/.configure +0 -6
- stoobly_agent/app/cli/scaffold/templates/constants.py +5 -5
- stoobly_agent/app/cli/scaffold/templates/factory.py +5 -7
- stoobly_agent/app/cli/scaffold_cli.py +11 -0
- stoobly_agent/test/app/models/schemas/.stoobly/db/VERSION +1 -1
- {stoobly_agent-1.7.2.dist-info → stoobly_agent-1.8.0.dist-info}/METADATA +1 -1
- {stoobly_agent-1.7.2.dist-info → stoobly_agent-1.8.0.dist-info}/RECORD +25 -26
- stoobly_agent/app/cli/scaffold/templates/run/nginx.tmpl +0 -1060
- {stoobly_agent-1.7.2.dist-info → stoobly_agent-1.8.0.dist-info}/LICENSE +0 -0
- {stoobly_agent-1.7.2.dist-info → stoobly_agent-1.8.0.dist-info}/WHEEL +0 -0
- {stoobly_agent-1.7.2.dist-info → stoobly_agent-1.8.0.dist-info}/entry_points.txt +0 -0
@@ -1,1060 +0,0 @@
|
|
1
|
-
# nginx-proxy{{ if $.Env.NGINX_PROXY_VERSION }} version : {{ $.Env.NGINX_PROXY_VERSION }}{{ end }}
|
2
|
-
|
3
|
-
{{- /*
|
4
|
-
* Global values. Values are stored in this map rather than in individual
|
5
|
-
* global variables so that the values can be easily passed to embedded
|
6
|
-
* templates (Go templates cannot access variables outside of their own
|
7
|
-
* scope) and displayed in the debug endpoint output.
|
8
|
-
*/}}
|
9
|
-
{{- $globals := dict }}
|
10
|
-
{{- $_ := set $globals "containers" $ }}
|
11
|
-
{{- $_ := set $globals "Env" $.Env }}
|
12
|
-
{{- $_ := set $globals "Docker" $.Docker }}
|
13
|
-
{{- $_ := set $globals "CurrentContainer" (where $globals.containers "ID" $globals.Docker.CurrentContainerID | first) }}
|
14
|
-
|
15
|
-
{{- $config := dict }}
|
16
|
-
{{- $_ := set $config "nginx_proxy_version" $.Env.NGINX_PROXY_VERSION }}
|
17
|
-
{{- $_ := set $config "default_cert_ok" (and (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }}
|
18
|
-
{{- $_ := set $config "external_http_port" ($globals.Env.HTTP_PORT | default "80") }}
|
19
|
-
{{- $_ := set $config "external_https_port" ($globals.Env.HTTPS_PORT | default "443") }}
|
20
|
-
{{- $_ := set $config "sha1_upstream_name" ($globals.Env.SHA1_UPSTREAM_NAME | default "false" | parseBool) }}
|
21
|
-
{{- $_ := set $config "default_root_response" ($globals.Env.DEFAULT_ROOT | default "404") }}
|
22
|
-
{{- $_ := set $config "trust_default_cert" ($globals.Env.TRUST_DEFAULT_CERT | default "true") }}
|
23
|
-
{{- $_ := set $config "trust_downstream_proxy" ($globals.Env.TRUST_DOWNSTREAM_PROXY | default "true" | parseBool) }}
|
24
|
-
{{- $_ := set $config "enable_access_log" ($globals.Env.DISABLE_ACCESS_LOGS | default "false" | parseBool | not) }}
|
25
|
-
{{- $_ := set $config "enable_ipv6" ($globals.Env.ENABLE_IPV6 | default "false" | parseBool) }}
|
26
|
-
{{- $_ := set $config "prefer_ipv6_network" ($globals.Env.PREFER_IPV6_NETWORK | default "false" | parseBool) }}
|
27
|
-
{{- $_ := set $config "ssl_policy" ($globals.Env.SSL_POLICY | default "Mozilla-Intermediate") }}
|
28
|
-
{{- $_ := set $config "enable_debug_endpoint" ($globals.Env.DEBUG_ENDPOINT | default "false") }}
|
29
|
-
{{- $_ := set $config "hsts" ($globals.Env.HSTS | default "max-age=31536000") }}
|
30
|
-
{{- $_ := set $config "acme_http_challenge" ($globals.Env.ACME_HTTP_CHALLENGE_LOCATION | default "true") }}
|
31
|
-
{{- $_ := set $config "enable_http2" ($globals.Env.ENABLE_HTTP2 | default "true") }}
|
32
|
-
{{- $_ := set $config "enable_http3" ($globals.Env.ENABLE_HTTP3 | default "false") }}
|
33
|
-
{{- $_ := set $config "enable_http_on_missing_cert" ($globals.Env.ENABLE_HTTP_ON_MISSING_CERT | default "true") }}
|
34
|
-
{{- $_ := set $config "https_method" ($globals.Env.HTTPS_METHOD | default "redirect") }}
|
35
|
-
{{- $_ := set $config "non_get_redirect" ($globals.Env.NON_GET_REDIRECT | default "301") }}
|
36
|
-
{{- $_ := set $config "default_host" $globals.Env.DEFAULT_HOST }}
|
37
|
-
{{- $_ := set $config "resolvers" $globals.Env.RESOLVERS }}
|
38
|
-
{{- /* LOG_JSON is a shorthand that sets logging defaults to JSON format */}}
|
39
|
-
{{- $_ := set $config "enable_json_logs" ($globals.Env.LOG_JSON | default "false" | parseBool) }}
|
40
|
-
{{- $_ := set $config "log_format" $globals.Env.LOG_FORMAT }}
|
41
|
-
{{- $_ := set $config "log_format_escape" $globals.Env.LOG_FORMAT_ESCAPE }}
|
42
|
-
|
43
|
-
{{- $_ := set $globals "config" $config }}
|
44
|
-
|
45
|
-
{{- $_ := set $globals "vhosts" (dict) }}
|
46
|
-
{{- $_ := set $globals "networks" (dict) }}
|
47
|
-
# Networks available to the container running docker-gen (which are assumed to
|
48
|
-
# match the networks available to the container running nginx):
|
49
|
-
{{- /*
|
50
|
-
* Note: $globals.CurrentContainer may be nil in some circumstances due to
|
51
|
-
* <https://github.com/nginx-proxy/docker-gen/issues/458>. For more context
|
52
|
-
* see <https://github.com/nginx-proxy/nginx-proxy/issues/2189>.
|
53
|
-
*/}}
|
54
|
-
{{- if $globals.CurrentContainer }}
|
55
|
-
{{- range sortObjectsByKeysAsc $globals.CurrentContainer.Networks "Name" }}
|
56
|
-
{{- $_ := set $globals.networks .Name . }}
|
57
|
-
# {{ .Name }}
|
58
|
-
{{- else }}
|
59
|
-
# (none)
|
60
|
-
{{- end }}
|
61
|
-
{{- else }}
|
62
|
-
# /!\ WARNING: Failed to find the Docker container running docker-gen. All
|
63
|
-
# upstream (backend) application containers will appear to be
|
64
|
-
# unreachable. Try removing the -only-exposed and -only-published
|
65
|
-
# arguments to docker-gen if you pass either of those. See
|
66
|
-
# <https://github.com/nginx-proxy/docker-gen/issues/458>.
|
67
|
-
{{- end }}
|
68
|
-
|
69
|
-
{{- define "parseHost" -}}
|
70
|
-
{{- $vhost_data := get $.globals.vhosts $.hostname | default (dict) }}
|
71
|
-
{{- $paths := $vhost_data.paths | default (dict) }}
|
72
|
-
{{- $config := (index $paths "/") | default (dict) }}
|
73
|
-
|
74
|
-
{{- $_ := set $ "scheme" $config.proto }}
|
75
|
-
{{- range $k, $v := $config.ports }}
|
76
|
-
{{- $_ := set $ "port" $k }}
|
77
|
-
{{- break }}
|
78
|
-
{{- end }}
|
79
|
-
{{- end }}
|
80
|
-
|
81
|
-
{{- /*
|
82
|
-
* Template used as a function to get a container's IP address. This
|
83
|
-
* template only outputs debug comments; the IP address is "returned" by
|
84
|
-
* storing the value in the provided dot dict.
|
85
|
-
*
|
86
|
-
* The provided dot dict is expected to have the following entries:
|
87
|
-
* - "globals": Global values.
|
88
|
-
* - "container": The container's RuntimeContainer struct.
|
89
|
-
*
|
90
|
-
* The return value will be added to the dot dict with key "ip".
|
91
|
-
*/}}
|
92
|
-
{{- define "container_ip" }}
|
93
|
-
{{- $ipv4 := "" }}
|
94
|
-
{{- $ipv6 := "" }}
|
95
|
-
# networks:
|
96
|
-
{{- range sortObjectsByKeysAsc $.container.Networks "Name" }}
|
97
|
-
{{- /*
|
98
|
-
* TODO: Only ignore the "ingress" network for Swarm tasks (in case
|
99
|
-
* the user is not using Swarm mode and names a network "ingress").
|
100
|
-
*/}}
|
101
|
-
{{- if eq .Name "ingress" }}
|
102
|
-
# {{ .Name }} (ignored)
|
103
|
-
{{- continue }}
|
104
|
-
{{- end }}
|
105
|
-
{{- if eq .Name "host" }}
|
106
|
-
{{- /* Handle containers in host nework mode */}}
|
107
|
-
{{- if (index $.globals.networks "host") }}
|
108
|
-
# both container and proxy are in host network mode, using localhost IP
|
109
|
-
{{- $ipv4 = "127.0.0.1" }}
|
110
|
-
{{- continue }}
|
111
|
-
{{- end }}
|
112
|
-
{{- range sortObjectsByKeysAsc $.globals.CurrentContainer.Networks "Name" }}
|
113
|
-
{{- if and . .Gateway (not .Internal) }}
|
114
|
-
# container is in host network mode, using {{ .Name }} gateway IP
|
115
|
-
{{- $ipv4 = .Gateway }}
|
116
|
-
{{- break }}
|
117
|
-
{{- end }}
|
118
|
-
{{- end }}
|
119
|
-
{{- if $ipv4 }}
|
120
|
-
{{- continue }}
|
121
|
-
{{- end }}
|
122
|
-
{{- end }}
|
123
|
-
{{- if and (not (index $.globals.networks .Name)) (not $.globals.networks.host) }}
|
124
|
-
# {{ .Name }} (unreachable)
|
125
|
-
{{- continue }}
|
126
|
-
{{- end }}
|
127
|
-
{{- /*
|
128
|
-
* Do not emit multiple `server` directives for this container if it
|
129
|
-
* is reachable over multiple networks or multiple IP stacks. This avoids
|
130
|
-
* accidentally inflating the effective round-robin weight of a server due
|
131
|
-
* to the redundant upstream addresses that nginx sees as belonging to
|
132
|
-
* distinct servers.
|
133
|
-
*/}}
|
134
|
-
{{- if or $ipv4 $ipv6 }}
|
135
|
-
# {{ .Name }} (ignored; reachable but redundant)
|
136
|
-
{{- continue }}
|
137
|
-
{{- end }}
|
138
|
-
# {{ .Name }} (reachable)
|
139
|
-
{{- if and . .IP }}
|
140
|
-
{{- $ipv4 = .IP }}
|
141
|
-
{{- end }}
|
142
|
-
{{- if and . .GlobalIPv6Address }}
|
143
|
-
{{- $ipv6 = .GlobalIPv6Address }}
|
144
|
-
{{- end }}
|
145
|
-
{{- if and (empty $ipv4) (empty $ipv6) }}
|
146
|
-
# /!\ No IPv4 or IPv6 for this network!
|
147
|
-
{{- end }}
|
148
|
-
{{- else }}
|
149
|
-
# (none)
|
150
|
-
{{- end }}
|
151
|
-
{{ if and $ipv6 $.globals.config.prefer_ipv6_network }}
|
152
|
-
# IPv4 address: {{ if $ipv4 }}{{ $ipv4 }} (ignored; reachable but IPv6 prefered){{ else }}(none usable){{ end }}
|
153
|
-
# IPv6 address: {{ $ipv6 }}
|
154
|
-
{{- $_ := set $ "ip" (printf "[%s]" $ipv6) }}
|
155
|
-
{{- else }}
|
156
|
-
# IPv4 address: {{ if $ipv4 }}{{ $ipv4 }}{{ else }}(none usable){{ end }}
|
157
|
-
# IPv6 address: {{ if $ipv6 }}{{ $ipv6 }}{{ if $ipv4 }} (ignored; reachable but IPv4 prefered){{ end }}{{ else }}(none usable){{ end }}
|
158
|
-
{{- if $ipv4 }}
|
159
|
-
{{- $_ := set $ "ip" $ipv4 }}
|
160
|
-
{{- else if $ipv6}}
|
161
|
-
{{- $_ := set $ "ip" (printf "[%s]" $ipv6) }}
|
162
|
-
{{- end }}
|
163
|
-
{{- end }}
|
164
|
-
{{- end }}
|
165
|
-
|
166
|
-
{{- /*
|
167
|
-
* Template used as a function to get the port of the server in the given
|
168
|
-
* container. This template only outputs debug comments; the port is
|
169
|
-
* "returned" by storing the value in the provided dot dict.
|
170
|
-
*
|
171
|
-
* The provided dot dict is expected to have the following entries:
|
172
|
-
* - "container": The container's RuntimeContainer struct.
|
173
|
-
*
|
174
|
-
* The return value will be added to the dot dict with key "port".
|
175
|
-
*/}}
|
176
|
-
{{- define "container_port" }}
|
177
|
-
{{- /* If only 1 port exposed, use that as a default, else 80. */}}
|
178
|
-
# exposed ports (first ten):{{ range $index, $address := (sortObjectsByKeysAsc $.container.Addresses "Port") }}{{ if lt $index 10 }} {{ $address.Port }}/{{ $address.Proto }}{{ end }}{{ else }} (none){{ end }}
|
179
|
-
{{- $default_port := when (eq (len $.container.Addresses) 1) (first $.container.Addresses).Port "80" }}
|
180
|
-
# default port: {{ $default_port }}
|
181
|
-
{{- $port := eq $.port "default" | ternary $default_port $.port }}
|
182
|
-
# using port: {{ $port }}
|
183
|
-
{{- $addr_obj := where $.container.Addresses "Port" $port | first }}
|
184
|
-
{{- if and $addr_obj $addr_obj.HostPort }}
|
185
|
-
# /!\ WARNING: Virtual port published on host. Clients
|
186
|
-
# might be able to bypass nginx-proxy and
|
187
|
-
# access the container's server directly.
|
188
|
-
{{- end }}
|
189
|
-
{{- $_ := set $ "port" $port }}
|
190
|
-
{{- end }}
|
191
|
-
|
192
|
-
{{- define "ssl_policy" }}
|
193
|
-
{{- if eq .ssl_policy "Mozilla-Modern" }}
|
194
|
-
ssl_protocols TLSv1.3;
|
195
|
-
{{- /*
|
196
|
-
* This ssl_ciphers directive is not used but necessary to get TLSv1.3 only.
|
197
|
-
* see https://serverfault.com/questions/1023766/nginx-with-only-tls1-3-cipher-suites
|
198
|
-
*/}}
|
199
|
-
ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384;
|
200
|
-
ssl_conf_command Ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256;
|
201
|
-
ssl_prefer_server_ciphers off;
|
202
|
-
{{- else if eq .ssl_policy "Mozilla-Intermediate" }}
|
203
|
-
ssl_protocols TLSv1.2 TLSv1.3;
|
204
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305';
|
205
|
-
ssl_prefer_server_ciphers off;
|
206
|
-
{{- else if eq .ssl_policy "Mozilla-Old" }}
|
207
|
-
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
|
208
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:@SECLEVEL=0';
|
209
|
-
ssl_prefer_server_ciphers on;
|
210
|
-
{{- else if eq .ssl_policy "AWS-TLS13-1-3-2021-06" }}
|
211
|
-
ssl_protocols TLSv1.3;
|
212
|
-
{{- /*
|
213
|
-
* This ssl_ciphers directive is not used but necessary to get TLSv1.3 only.
|
214
|
-
* see https://serverfault.com/questions/1023766/nginx-with-only-tls1-3-cipher-suites
|
215
|
-
*/}}
|
216
|
-
ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384;
|
217
|
-
ssl_conf_command Ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256;
|
218
|
-
ssl_prefer_server_ciphers on;
|
219
|
-
{{- else if eq .ssl_policy "AWS-TLS13-1-2-2021-06" }}
|
220
|
-
ssl_protocols TLSv1.2 TLSv1.3;
|
221
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384';
|
222
|
-
ssl_prefer_server_ciphers on;
|
223
|
-
{{- else if eq .ssl_policy "AWS-TLS13-1-2-Res-2021-06" }}
|
224
|
-
ssl_protocols TLSv1.2 TLSv1.3;
|
225
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';
|
226
|
-
ssl_prefer_server_ciphers on;
|
227
|
-
{{- else if eq .ssl_policy "AWS-TLS13-1-2-Ext1-2021-06" }}
|
228
|
-
ssl_protocols TLSv1.2 TLSv1.3;
|
229
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES128-SHA256:AES256-GCM-SHA384:AES256-SHA256';
|
230
|
-
ssl_prefer_server_ciphers on;
|
231
|
-
{{- else if eq .ssl_policy "AWS-TLS13-1-2-Ext2-2021-06" }}
|
232
|
-
ssl_protocols TLSv1.2 TLSv1.3;
|
233
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA';
|
234
|
-
ssl_prefer_server_ciphers on;
|
235
|
-
{{- else if eq .ssl_policy "AWS-TLS13-1-1-2021-06" }}
|
236
|
-
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
|
237
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:@SECLEVEL=0';
|
238
|
-
ssl_prefer_server_ciphers on;
|
239
|
-
{{- else if eq .ssl_policy "AWS-TLS13-1-0-2021-06" }}
|
240
|
-
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
|
241
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:@SECLEVEL=0';
|
242
|
-
ssl_prefer_server_ciphers on;
|
243
|
-
{{- else if eq .ssl_policy "AWS-FS-1-2-Res-2020-10" }}
|
244
|
-
ssl_protocols TLSv1.2;
|
245
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';
|
246
|
-
ssl_prefer_server_ciphers on;
|
247
|
-
{{- else if eq .ssl_policy "AWS-FS-1-2-Res-2019-08" }}
|
248
|
-
ssl_protocols TLSv1.2;
|
249
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384';
|
250
|
-
ssl_prefer_server_ciphers on;
|
251
|
-
{{- else if eq .ssl_policy "AWS-FS-1-2-2019-08" }}
|
252
|
-
ssl_protocols TLSv1.2;
|
253
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA';
|
254
|
-
ssl_prefer_server_ciphers on;
|
255
|
-
{{- else if eq .ssl_policy "AWS-FS-1-1-2019-08" }}
|
256
|
-
ssl_protocols TLSv1.1 TLSv1.2;
|
257
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:@SECLEVEL=0';
|
258
|
-
ssl_prefer_server_ciphers on;
|
259
|
-
{{- else if eq .ssl_policy "AWS-FS-2018-06" }}
|
260
|
-
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
261
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:@SECLEVEL=0';
|
262
|
-
ssl_prefer_server_ciphers on;
|
263
|
-
{{- else if eq .ssl_policy "AWS-TLS-1-2-Ext-2018-06" }}
|
264
|
-
ssl_protocols TLSv1.2;
|
265
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA';
|
266
|
-
ssl_prefer_server_ciphers on;
|
267
|
-
{{- else if eq .ssl_policy "AWS-TLS-1-2-2017-01" }}
|
268
|
-
ssl_protocols TLSv1.2;
|
269
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES128-SHA256:AES256-GCM-SHA384:AES256-SHA256';
|
270
|
-
ssl_prefer_server_ciphers on;
|
271
|
-
{{- else if eq .ssl_policy "AWS-TLS-1-1-2017-01" }}
|
272
|
-
ssl_protocols TLSv1.1 TLSv1.2;
|
273
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:@SECLEVEL=0';
|
274
|
-
ssl_prefer_server_ciphers on;
|
275
|
-
{{- else if eq .ssl_policy "AWS-2016-08" }}
|
276
|
-
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
277
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:@SECLEVEL=0';
|
278
|
-
ssl_prefer_server_ciphers on;
|
279
|
-
{{- else if eq .ssl_policy "AWS-2015-05" }}
|
280
|
-
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
281
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DES-CBC3-SHA:@SECLEVEL=0';
|
282
|
-
ssl_prefer_server_ciphers on;
|
283
|
-
{{- else if eq .ssl_policy "AWS-2015-03" }}
|
284
|
-
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
285
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DHE-DSS-AES128-SHA:DES-CBC3-SHA:@SECLEVEL=0';
|
286
|
-
ssl_prefer_server_ciphers on;
|
287
|
-
{{- else if eq .ssl_policy "AWS-2015-02" }}
|
288
|
-
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
289
|
-
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DHE-DSS-AES128-SHA:@SECLEVEL=0';
|
290
|
-
ssl_prefer_server_ciphers on;
|
291
|
-
{{- end }}
|
292
|
-
{{- end }}
|
293
|
-
|
294
|
-
{{- define "location" }}
|
295
|
-
{{- $vpath := .VPath }}
|
296
|
-
{{- $override := printf "/etc/nginx/vhost.d/%s_%s_location_override" .Host (sha1 .Path) }}
|
297
|
-
{{- if and (eq .Path "/") (not (exists $override)) }}
|
298
|
-
{{- $override = printf "/etc/nginx/vhost.d/%s_location_override" .Host }}
|
299
|
-
{{- end }}
|
300
|
-
{{- if exists $override }}
|
301
|
-
include {{ $override }};
|
302
|
-
{{- else }}
|
303
|
-
{{- $keepalive := $vpath.keepalive }}
|
304
|
-
location {{ .Path }} {
|
305
|
-
{{- if eq $vpath.network_tag "internal" }}
|
306
|
-
# Only allow traffic from internal clients
|
307
|
-
include /etc/nginx/network_internal.conf;
|
308
|
-
{{- end }}
|
309
|
-
|
310
|
-
{{ $proto := $vpath.proto }}
|
311
|
-
{{ $upstream := $vpath.upstream }}
|
312
|
-
{{ $dest := $vpath.dest }}
|
313
|
-
{{- if eq $proto "uwsgi" }}
|
314
|
-
include uwsgi_params;
|
315
|
-
uwsgi_pass {{ trim $proto }}://{{ trim $upstream }};
|
316
|
-
{{- else if eq $proto "fastcgi" }}
|
317
|
-
{{- if (exists "/etc/nginx/fastcgi.conf") }}
|
318
|
-
include fastcgi.conf;
|
319
|
-
{{- else if (exists "/etc/nginx/fastcgi_params") }}
|
320
|
-
include fastcgi_params;
|
321
|
-
{{- else }}
|
322
|
-
# neither /etc/nginx/fastcgi.conf nor /etc/nginx/fastcgi_params found, fastcgi won't work
|
323
|
-
{{- end }}
|
324
|
-
root {{ trim .VhostRoot }};
|
325
|
-
fastcgi_pass {{ trim $upstream }};
|
326
|
-
{{- if ne $keepalive "disabled" }}
|
327
|
-
fastcgi_keep_conn on;
|
328
|
-
{{- end }}
|
329
|
-
{{- else if eq $proto "grpc" }}
|
330
|
-
grpc_pass {{ trim $proto }}://{{ trim $upstream }};
|
331
|
-
{{- else if eq $proto "grpcs" }}
|
332
|
-
grpc_pass {{ trim $proto }}://{{ trim $upstream }};
|
333
|
-
{{- else }}
|
334
|
-
proxy_pass {{ trim $proto }}://{{ trim $upstream }}{{ trim $dest }};
|
335
|
-
set $upstream_keepalive {{ if ne $keepalive "disabled" }}true{{ else }}false{{ end }};
|
336
|
-
{{- end }}
|
337
|
-
|
338
|
-
{{- if (exists (printf "/etc/nginx/htpasswd/%s_%s" .Host (sha1 .Path) )) }}
|
339
|
-
auth_basic "Restricted {{ .Host }}{{ .Path }}";
|
340
|
-
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s_%s" .Host (sha1 .Path)) }};
|
341
|
-
{{- else if (exists (printf "/etc/nginx/htpasswd/%s" .Host)) }}
|
342
|
-
auth_basic "Restricted {{ .HostIsRegexp | ternary "access" .Host }}";
|
343
|
-
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" .Host) }};
|
344
|
-
{{- end }}
|
345
|
-
|
346
|
-
{{- if (exists (printf "/etc/nginx/vhost.d/%s_%s_location" .Host (sha1 .Path) )) }}
|
347
|
-
include {{ printf "/etc/nginx/vhost.d/%s_%s_location" .Host (sha1 .Path) }};
|
348
|
-
{{- else if (exists (printf "/etc/nginx/vhost.d/%s_location" .Host)) }}
|
349
|
-
include {{ printf "/etc/nginx/vhost.d/%s_location" .Host}};
|
350
|
-
{{- else if (exists "/etc/nginx/vhost.d/default_location") }}
|
351
|
-
include /etc/nginx/vhost.d/default_location;
|
352
|
-
{{- end }}
|
353
|
-
}
|
354
|
-
{{- end }}
|
355
|
-
{{- end }}
|
356
|
-
|
357
|
-
{{- define "upstream" }}
|
358
|
-
{{- $path := .Path }}
|
359
|
-
{{- $vpath := .VPath }}
|
360
|
-
upstream {{ $vpath.upstream }} {
|
361
|
-
{{- $servers := 0 }}
|
362
|
-
{{- $loadbalance := $vpath.loadbalance }}
|
363
|
-
{{- if $loadbalance }}
|
364
|
-
# From the container's loadbalance label:
|
365
|
-
{{ $loadbalance }}
|
366
|
-
{{- end }}
|
367
|
-
{{- range $port, $containers := $vpath.ports }}
|
368
|
-
{{- range $container := $containers }}
|
369
|
-
# Container: {{ $container.Name }}
|
370
|
-
{{- $args := dict "globals" $.globals "container" $container }}
|
371
|
-
{{- template "container_ip" $args }}
|
372
|
-
{{- $ip := $args.ip }}
|
373
|
-
{{- $args = dict "container" $container "path" $path "port" $port }}
|
374
|
-
{{- template "container_port" $args }}
|
375
|
-
{{- if $ip }}
|
376
|
-
{{- $servers = add1 $servers }}
|
377
|
-
server {{ $ip }}:{{ $args.port }};
|
378
|
-
{{- end }}
|
379
|
-
{{- end }}
|
380
|
-
{{- end }}
|
381
|
-
{{- /* nginx-proxy/nginx-proxy#1105 */}}
|
382
|
-
{{- if lt $servers 1 }}
|
383
|
-
# Fallback entry
|
384
|
-
server 127.0.0.1 down;
|
385
|
-
{{- end }}
|
386
|
-
{{- $keepalive := $vpath.keepalive }}
|
387
|
-
{{- if and (ne $keepalive "disabled") (gt $servers 0) }}
|
388
|
-
{{- if eq $keepalive "auto" }}
|
389
|
-
keepalive {{ mul $servers 2 }};
|
390
|
-
{{- else }}
|
391
|
-
keepalive {{ $keepalive }};
|
392
|
-
{{- end }}
|
393
|
-
{{- end }}
|
394
|
-
}
|
395
|
-
{{- end }}
|
396
|
-
|
397
|
-
{{- /* debug "endpoint" location template */}}
|
398
|
-
{{- define "debug_location" }}
|
399
|
-
{{- $debug_paths := dict }}
|
400
|
-
{{- range $path, $vpath := .VHost.paths }}
|
401
|
-
{{- $tmp_ports := dict }}
|
402
|
-
{{- range $port, $containers := $vpath.ports }}
|
403
|
-
{{- $tmp_containers := list }}
|
404
|
-
{{- range $container := $containers }}
|
405
|
-
{{- $tmp_containers = dict "Name" $container.Name | append $tmp_containers }}
|
406
|
-
{{- end }}
|
407
|
-
{{- $_ := set $tmp_ports $port $tmp_containers }}
|
408
|
-
{{- end }}
|
409
|
-
{{- $debug_vpath := deepCopy $vpath | merge (dict "ports" $tmp_ports) }}
|
410
|
-
{{- $_ := set $debug_paths $path $debug_vpath }}
|
411
|
-
{{- end }}
|
412
|
-
|
413
|
-
{{- $debug_vhost := deepCopy .VHost }}
|
414
|
-
{{- /* If it's a regexp, do not render the Hostname to the response to avoid rendering config breaking characters */}}
|
415
|
-
{{- $_ := set $debug_vhost "hostname" (.VHost.is_regexp | ternary "Hostname is a regexp and unsafe to include in the debug response." .Hostname) }}
|
416
|
-
{{- $_ := set $debug_vhost "paths" $debug_paths }}
|
417
|
-
|
418
|
-
{{- $debug_response := dict
|
419
|
-
"global" .GlobalConfig
|
420
|
-
"request" (dict
|
421
|
-
"host" "$host"
|
422
|
-
"https" "$https"
|
423
|
-
"http2" "$http2"
|
424
|
-
"http3" "$http3"
|
425
|
-
"ssl_cipher" "$ssl_cipher"
|
426
|
-
"ssl_protocol" "$ssl_protocol"
|
427
|
-
)
|
428
|
-
"vhost" $debug_vhost
|
429
|
-
}}
|
430
|
-
|
431
|
-
{{- /*
|
432
|
-
* The maximum line length in an nginx config is 4096 characters.
|
433
|
-
* If we're nearing this limit (with headroom for the rest
|
434
|
-
* of the directive), strip vhost.paths from the response.
|
435
|
-
*/}}
|
436
|
-
{{- if gt (toJson $debug_response | len) 4000 }}
|
437
|
-
{{- $_ := unset $debug_vhost "paths" }}
|
438
|
-
{{- $_ := set $debug_response "warning" "Virtual paths configuration for this hostname is too large and has been stripped from response." }}
|
439
|
-
{{- end }}
|
440
|
-
|
441
|
-
location /nginx-proxy-debug {
|
442
|
-
default_type application/json;
|
443
|
-
return 200 '{{ toJson $debug_response }}{{ "\\n" }}';
|
444
|
-
}
|
445
|
-
{{- end }}
|
446
|
-
|
447
|
-
{{- define "access_log" }}
|
448
|
-
{{- when .Enable "access_log /var/log/nginx/access.log vhost;" "" }}
|
449
|
-
{{- end }}
|
450
|
-
|
451
|
-
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
|
452
|
-
# scheme used to connect to this server
|
453
|
-
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
|
454
|
-
default {{ if $globals.config.trust_downstream_proxy }}$http_x_forwarded_proto{{ else }}$scheme{{ end }};
|
455
|
-
'' $scheme;
|
456
|
-
}
|
457
|
-
|
458
|
-
map $http_x_forwarded_host $proxy_x_forwarded_host {
|
459
|
-
default {{ if $globals.config.trust_downstream_proxy }}$http_x_forwarded_host{{ else }}$host{{ end }};
|
460
|
-
'' $host;
|
461
|
-
}
|
462
|
-
|
463
|
-
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
|
464
|
-
# server port the client connected to
|
465
|
-
map $http_x_forwarded_port $proxy_x_forwarded_port {
|
466
|
-
default {{ if $globals.config.trust_downstream_proxy }}$http_x_forwarded_port{{ else }}$server_port{{ end }};
|
467
|
-
'' $server_port;
|
468
|
-
}
|
469
|
-
|
470
|
-
# Include the port in the Host header sent to the container if it is non-standard
|
471
|
-
map $server_port $host_port {
|
472
|
-
default :$server_port;
|
473
|
-
80 '';
|
474
|
-
443 '';
|
475
|
-
}
|
476
|
-
|
477
|
-
# If the request from the downstream client has an "Upgrade:" header (set to any
|
478
|
-
# non-empty value), pass "Connection: upgrade" to the upstream (backend) server.
|
479
|
-
# Otherwise, the value for the "Connection" header depends on whether the user
|
480
|
-
# has enabled keepalive to the upstream server.
|
481
|
-
map $http_upgrade $proxy_connection {
|
482
|
-
default upgrade;
|
483
|
-
'' $proxy_connection_noupgrade;
|
484
|
-
}
|
485
|
-
map $upstream_keepalive $proxy_connection_noupgrade {
|
486
|
-
# Preserve nginx's default behavior (send "Connection: close").
|
487
|
-
default close;
|
488
|
-
# Use an empty string to cancel nginx's default behavior.
|
489
|
-
true '';
|
490
|
-
}
|
491
|
-
# Abuse the map directive (see <https://stackoverflow.com/q/14433309>) to ensure
|
492
|
-
# that $upstream_keepalive is always defined. This is necessary because:
|
493
|
-
# - The $proxy_connection variable is indirectly derived from
|
494
|
-
# $upstream_keepalive, so $upstream_keepalive must be defined whenever
|
495
|
-
# $proxy_connection is resolved.
|
496
|
-
# - The $proxy_connection variable is used in a proxy_set_header directive in
|
497
|
-
# the http block, so it is always fully resolved for every request -- even
|
498
|
-
# those where proxy_pass is not used (e.g., unknown virtual host).
|
499
|
-
map "" $upstream_keepalive {
|
500
|
-
# The value here should not matter because it should always be overridden in
|
501
|
-
# a location block (see the "location" template) for all requests where the
|
502
|
-
# value actually matters.
|
503
|
-
default false;
|
504
|
-
}
|
505
|
-
|
506
|
-
# Apply fix for very long server names
|
507
|
-
server_names_hash_bucket_size 128;
|
508
|
-
|
509
|
-
# Default dhparam
|
510
|
-
{{- if (exists "/etc/nginx/dhparam/dhparam.pem") }}
|
511
|
-
ssl_dhparam /etc/nginx/dhparam/dhparam.pem;
|
512
|
-
{{- end }}
|
513
|
-
|
514
|
-
# Set appropriate X-Forwarded-Ssl header based on $proxy_x_forwarded_proto
|
515
|
-
map $proxy_x_forwarded_proto $proxy_x_forwarded_ssl {
|
516
|
-
default off;
|
517
|
-
https on;
|
518
|
-
}
|
519
|
-
|
520
|
-
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
521
|
-
|
522
|
-
|
523
|
-
{{- /* See https://nginx.org/en/docs/http/ngx_http_log_module.html#log_format for details and variables
|
524
|
-
* LOG_FORMAT_ESCAPE sets the escape part of the log format
|
525
|
-
* LOG_FORMAT sets the log format
|
526
|
-
*/}}
|
527
|
-
{{- $logEscape := $globals.config.log_format_escape | default "default" | printf "escape=%s" }}
|
528
|
-
{{- $logFormat := $globals.config.log_format | default `$host $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$upstream_addr"` }}
|
529
|
-
|
530
|
-
{{- if $globals.config.enable_json_logs }}
|
531
|
-
# JSON Logging enabled (via LOG_JSON env variable)
|
532
|
-
{{- $logEscape = $globals.config.log_format_escape | default "json" | printf "escape=%s" }}
|
533
|
-
{{- $logFormat = $globals.config.log_format | default `{"time_local":"$time_iso8601","client_ip":"$http_x_forwarded_for","remote_addr":"$remote_addr","request":"$request","status":"$status","body_bytes_sent":"$body_bytes_sent","request_time":"$request_time","upstream_response_time":"$upstream_response_time","upstream_addr":"$upstream_addr","http_referrer":"$http_referer","http_user_agent":"$http_user_agent","request_id":"$request_id"}` }}
|
534
|
-
{{- end }}
|
535
|
-
|
536
|
-
log_format vhost {{ $logEscape }} '{{ $logFormat }}';
|
537
|
-
|
538
|
-
access_log off;
|
539
|
-
|
540
|
-
{{- /* Lower the SSL policy of the http context
|
541
|
-
* if at least one vhost use a TLSv1 or TLSv1.1 policy
|
542
|
-
* so TLSv1 and TLSv1.1 can be enabled on those vhosts
|
543
|
-
*/}}
|
544
|
-
{{- $httpContextSslPolicy := $globals.config.ssl_policy }}
|
545
|
-
{{- $inUseSslPolicies := groupByKeys $globals.containers "Env.SSL_POLICY" }}
|
546
|
-
{{- range $tls1Policy := list "AWS-TLS13-1-1-2021-06" "AWS-TLS13-1-0-2021-06" "AWS-FS-1-1-2019-08" "AWS-FS-2018-06" "AWS-TLS-1-1-2017-01" "AWS-2016-08" "AWS-2015-05" "AWS-2015-03" "AWS-2015-02" "Mozilla-Old" }}
|
547
|
-
{{- if has $tls1Policy $inUseSslPolicies }}
|
548
|
-
# Using Mozilla-Old SSL policy on the http context to allow TLSv1 and TLSv1.1
|
549
|
-
{{- $httpContextSslPolicy = "Mozilla-Old" }}
|
550
|
-
{{- break }}
|
551
|
-
{{- end }}
|
552
|
-
{{- end }}
|
553
|
-
|
554
|
-
{{- template "ssl_policy" (dict "ssl_policy" $httpContextSslPolicy) }}
|
555
|
-
error_log /dev/stderr;
|
556
|
-
|
557
|
-
{{- if $globals.config.resolvers }}
|
558
|
-
resolver {{ $globals.config.resolvers }};
|
559
|
-
{{- end }}
|
560
|
-
|
561
|
-
{{- if (exists "/etc/nginx/proxy.conf") }}
|
562
|
-
include /etc/nginx/proxy.conf;
|
563
|
-
{{- else }}
|
564
|
-
# HTTP 1.1 support
|
565
|
-
proxy_http_version 1.1;
|
566
|
-
proxy_set_header Host $host$host_port;
|
567
|
-
proxy_set_header Upgrade $http_upgrade;
|
568
|
-
proxy_set_header Connection $proxy_connection;
|
569
|
-
proxy_set_header X-Real-IP $remote_addr;
|
570
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
571
|
-
proxy_set_header X-Forwarded-Host $proxy_x_forwarded_host;
|
572
|
-
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
|
573
|
-
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
|
574
|
-
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
|
575
|
-
proxy_set_header X-Original-URI $request_uri;
|
576
|
-
|
577
|
-
# Mitigate httpoxy attack (see README for details)
|
578
|
-
proxy_set_header Proxy "";
|
579
|
-
{{- end }}
|
580
|
-
|
581
|
-
{{- /* Precompute and store some information about vhost that use VIRTUAL_HOST_MULTIPORTS. */}}
|
582
|
-
{{- range $vhosts_yaml, $containers := groupBy $globals.containers "Env.VIRTUAL_HOST_MULTIPORTS" }}
|
583
|
-
{{- /* Print a warning in the config if VIRTUAL_HOST_MULTIPORTS can't be parsed. */}}
|
584
|
-
{{- $parsedVhosts := fromYaml $vhosts_yaml }}
|
585
|
-
{{- if (empty $parsedVhosts) }}
|
586
|
-
{{- $containerNames := list }}
|
587
|
-
{{- range $container := $containers }}
|
588
|
-
{{- $containerNames = append $containerNames $container.Name }}
|
589
|
-
{{- end }}
|
590
|
-
# /!\ WARNING: the VIRTUAL_HOST_MULTIPORTS environment variable used for {{ len $containerNames | plural "this container" "those containers" }} is not a valid YAML string:
|
591
|
-
# {{ $containerNames | join ", " }}
|
592
|
-
{{- continue }}
|
593
|
-
{{- end }}
|
594
|
-
|
595
|
-
{{- range $hostname, $vhost := $parsedVhosts }}
|
596
|
-
{{- $vhost_data := get $globals.vhosts $hostname | default (dict) }}
|
597
|
-
{{- $paths := $vhost_data.paths | default (dict) }}
|
598
|
-
|
599
|
-
{{- if (empty $vhost) }}
|
600
|
-
{{ $vhost = dict "/" (dict) }}
|
601
|
-
{{- end }}
|
602
|
-
|
603
|
-
{{- range $path, $vpath := $vhost }}
|
604
|
-
{{- if (empty $vpath) }}
|
605
|
-
{{- $vpath = dict
|
606
|
-
"dest" ""
|
607
|
-
"port" "default"
|
608
|
-
"proto" "http"
|
609
|
-
}}
|
610
|
-
{{- end }}
|
611
|
-
|
612
|
-
{{- $dest := $vpath.dest | default "" }}
|
613
|
-
{{- $port := $vpath.port | default "default" | toString }}
|
614
|
-
{{- $proto := $vpath.proto | default "http" }}
|
615
|
-
|
616
|
-
{{- $path_data := get $paths $path | default (dict) }}
|
617
|
-
{{- $path_ports := $path_data.ports | default (dict) }}
|
618
|
-
{{- $path_port_containers := get $path_ports $port | default (list) | concat $containers }}
|
619
|
-
{{- $_ := set $path_ports $port $path_port_containers }}
|
620
|
-
{{- $_ := set $path_data "ports" $path_ports }}
|
621
|
-
|
622
|
-
{{- if (not (hasKey $path_data "dest")) }}
|
623
|
-
{{- $_ := set $path_data "dest" $dest }}
|
624
|
-
{{- end }}
|
625
|
-
|
626
|
-
{{- if (not (hasKey $path_data "proto")) }}
|
627
|
-
{{- $_ := set $path_data "proto" $proto }}
|
628
|
-
{{- end }}
|
629
|
-
|
630
|
-
{{- $_ := set $paths $path $path_data }}
|
631
|
-
{{- end }}
|
632
|
-
{{- $_ := set $vhost_data "paths" $paths }}
|
633
|
-
{{- $_ := set $globals.vhosts $hostname $vhost_data }}
|
634
|
-
{{- end }}
|
635
|
-
{{- end }}
|
636
|
-
|
637
|
-
{{- /* Precompute and store some information about vhost that use VIRTUAL_HOST. */}}
|
638
|
-
{{- range $hostname, $containers := groupByMulti $globals.containers "Env.VIRTUAL_HOST" "," }}
|
639
|
-
{{- /* Ignore containers with VIRTUAL_HOST set to the empty string. */}}
|
640
|
-
{{- $hostname = trim $hostname }}
|
641
|
-
{{- if not $hostname }}
|
642
|
-
{{- continue }}
|
643
|
-
{{- end }}
|
644
|
-
|
645
|
-
{{- /* Drop containers with both VIRTUAL_HOST and VIRTUAL_HOST_MULTIPORTS set
|
646
|
-
* (VIRTUAL_HOST_MULTIPORTS takes precedence thanks to the previous loop).
|
647
|
-
*/}}
|
648
|
-
{{- range $_, $containers_to_drop := groupBy $containers "Env.VIRTUAL_HOST_MULTIPORTS" }}
|
649
|
-
{{- range $container := $containers_to_drop }}
|
650
|
-
{{- $containers = without $containers $container }}
|
651
|
-
{{- end }}
|
652
|
-
{{- end }}
|
653
|
-
{{- if (eq (len $containers) 0) }}
|
654
|
-
{{- continue }}
|
655
|
-
{{- end }}
|
656
|
-
|
657
|
-
{{- $vhost_data := get $globals.vhosts $hostname | default (dict) }}
|
658
|
-
{{- $paths := $vhost_data.paths | default (dict) }}
|
659
|
-
|
660
|
-
{{- $tmp_paths := groupByWithDefault $containers "Env.VIRTUAL_PATH" "/" }}
|
661
|
-
|
662
|
-
{{- range $path, $containers := $tmp_paths }}
|
663
|
-
{{- $dest := groupByKeys $containers "Env.VIRTUAL_DEST" | first | default "" }}
|
664
|
-
{{- $proto := groupByKeys $containers "Env.VIRTUAL_PROTO" | first | default "http" | trim }}
|
665
|
-
|
666
|
-
{{- $path_data := get $paths $path | default (dict) }}
|
667
|
-
{{- $path_ports := $path_data.ports | default (dict) }}
|
668
|
-
{{- range $port, $containers := groupByWithDefault $containers "Env.VIRTUAL_PORT" "default" }}
|
669
|
-
{{- $path_port_containers := get $path_ports $port | default (list) | concat $containers }}
|
670
|
-
{{- $_ := set $path_ports $port $path_port_containers }}
|
671
|
-
{{- end }}
|
672
|
-
{{- $_ := set $path_data "ports" $path_ports }}
|
673
|
-
|
674
|
-
{{- if (not (hasKey $path_data "dest")) }}
|
675
|
-
{{- $_ := set $path_data "dest" $dest }}
|
676
|
-
{{- end }}
|
677
|
-
|
678
|
-
{{- if (not (hasKey $path_data "proto")) }}
|
679
|
-
{{- $_ := set $path_data "proto" $proto }}
|
680
|
-
{{- end }}
|
681
|
-
|
682
|
-
{{- $_ := set $paths $path $path_data }}
|
683
|
-
{{- end }}
|
684
|
-
{{- $_ := set $vhost_data "paths" $paths }}
|
685
|
-
{{- $_ := set $globals.vhosts $hostname $vhost_data }}
|
686
|
-
{{- end }}
|
687
|
-
|
688
|
-
{{- /* Loop over $globals.vhosts and update it with the remaining informations about each vhost. */}}
|
689
|
-
{{- range $hostname, $vhost_data := $globals.vhosts }}
|
690
|
-
{{- $is_regexp := hasPrefix "~" $hostname }}
|
691
|
-
{{- $upstream_name := or $is_regexp $globals.config.sha1_upstream_name | ternary (sha1 $hostname) $hostname }}
|
692
|
-
|
693
|
-
{{- $vhost_containers := list }}
|
694
|
-
|
695
|
-
{{- range $path, $vpath_data := $vhost_data.paths }}
|
696
|
-
{{- $vpath_containers := list }}
|
697
|
-
{{- range $port, $vport_containers := $vpath_data.ports }}
|
698
|
-
{{ $vpath_containers = concat $vpath_containers $vport_containers }}
|
699
|
-
{{- end }}
|
700
|
-
|
701
|
-
{{- /* Get the NETWORK_ACCESS defined by containers w/ the same vhost, falling back to "external". */}}
|
702
|
-
{{- $network_tag := groupByKeys $vpath_containers "Env.NETWORK_ACCESS" | first | default "external" }}
|
703
|
-
|
704
|
-
{{- $loadbalance := groupByLabel $vpath_containers "com.github.nginx-proxy.nginx-proxy.loadbalance" | keys | first }}
|
705
|
-
{{- $keepalive := groupByLabel $vpath_containers "com.github.nginx-proxy.nginx-proxy.keepalive" | keys | first | default "auto" }}
|
706
|
-
|
707
|
-
{{- $upstream := $upstream_name }}
|
708
|
-
{{- if (not (eq $path "/")) }}
|
709
|
-
{{- $sum := sha1 $path }}
|
710
|
-
{{- $upstream = printf "%s-%s" $upstream $sum }}
|
711
|
-
{{- end }}
|
712
|
-
|
713
|
-
{{- $_ := set $vpath_data "network_tag" $network_tag }}
|
714
|
-
{{- $_ := set $vpath_data "upstream" $upstream }}
|
715
|
-
{{- $_ := set $vpath_data "loadbalance" $loadbalance }}
|
716
|
-
{{- $_ := set $vpath_data "keepalive" $keepalive }}
|
717
|
-
{{- $_ := set $vhost_data.paths $path $vpath_data }}
|
718
|
-
|
719
|
-
{{ $vhost_containers = concat $vhost_containers $vpath_containers }}
|
720
|
-
{{- end }}
|
721
|
-
|
722
|
-
{{- $userIdentifiedCert := groupByKeys $vhost_containers "Env.CERT_NAME" | first }}
|
723
|
-
|
724
|
-
{{- $vhostCert := "" }}
|
725
|
-
{{- if exists (printf "/etc/nginx/certs/%s.crt" $hostname) }}
|
726
|
-
{{- $vhostCert = $hostname }}
|
727
|
-
{{- end }}
|
728
|
-
|
729
|
-
{{- $parentVhostCert := "" }}
|
730
|
-
{{- if gt ($hostname | sprigSplit "." | len) 2 }}
|
731
|
-
{{- $parentHostname := ($hostname | sprigSplitn "." 2)._1 }}
|
732
|
-
{{- if exists (printf "/etc/nginx/certs/%s.crt" $parentHostname) }}
|
733
|
-
{{- $parentVhostCert = $parentHostname }}
|
734
|
-
{{- end }}
|
735
|
-
{{- end }}
|
736
|
-
|
737
|
-
{{- $trust_default_cert := groupByLabel $vhost_containers "com.github.nginx-proxy.nginx-proxy.trust-default-cert" | keys | first | default $globals.config.trust_default_cert | parseBool }}
|
738
|
-
{{- $defaultCert := and $trust_default_cert $globals.config.default_cert_ok | ternary "default" "" }}
|
739
|
-
|
740
|
-
{{- $cert := or $userIdentifiedCert $vhostCert $parentVhostCert $defaultCert }}
|
741
|
-
{{- $cert_ok := and (ne $cert "") (exists (printf "/etc/nginx/certs/%s.crt" $cert)) (exists (printf "/etc/nginx/certs/%s.key" $cert)) }}
|
742
|
-
|
743
|
-
{{- $enable_debug_endpoint := groupByLabel $vhost_containers "com.github.nginx-proxy.nginx-proxy.debug-endpoint" | keys | first | default $globals.config.enable_debug_endpoint | parseBool }}
|
744
|
-
{{- $default := eq $globals.config.default_host $hostname }}
|
745
|
-
{{- $https_method := groupByKeys $vhost_containers "Env.HTTPS_METHOD" | first | default $globals.config.https_method }}
|
746
|
-
{{- $enable_http_on_missing_cert := groupByKeys $vhost_containers "Env.ENABLE_HTTP_ON_MISSING_CERT" | first | default $globals.config.enable_http_on_missing_cert | parseBool }}
|
747
|
-
{{- /* When no trusted certs (default and/or vhost) are present we want to ensure that HTTP is enabled; hence switching from 'nohttp' or 'redirect' to 'noredirect' */}}
|
748
|
-
{{- $https_method_disable_http := list "nohttp" "redirect" | has $https_method }}
|
749
|
-
{{- if and $https_method_disable_http (not $cert_ok) $enable_http_on_missing_cert }}
|
750
|
-
{{- $https_method = "noredirect" }}
|
751
|
-
{{- end }}
|
752
|
-
{{- $non_get_redirect := groupByLabel $vhost_containers "com.github.nginx-proxy.nginx-proxy.non-get-redirect" | keys | first | default $globals.config.non_get_redirect }}
|
753
|
-
|
754
|
-
{{- $http2_enabled := groupByLabel $vhost_containers "com.github.nginx-proxy.nginx-proxy.http2.enable" | keys | first | default $globals.config.enable_http2 | parseBool }}
|
755
|
-
{{- $http3_enabled := groupByLabel $vhost_containers "com.github.nginx-proxy.nginx-proxy.http3.enable" | keys | first | default $globals.config.enable_http3 | parseBool }}
|
756
|
-
|
757
|
-
{{- $acme_http_challenge := groupByKeys $vhost_containers "Env.ACME_HTTP_CHALLENGE_LOCATION" | first | default $globals.config.acme_http_challenge }}
|
758
|
-
{{- $acme_http_challenge_legacy := eq $acme_http_challenge "legacy" }}
|
759
|
-
{{- $acme_http_challenge_enabled := false }}
|
760
|
-
{{- if (not $acme_http_challenge_legacy) }}
|
761
|
-
{{- $acme_http_challenge_enabled = parseBool $acme_http_challenge }}
|
762
|
-
{{- end }}
|
763
|
-
|
764
|
-
{{- /* Get the SERVER_TOKENS defined by containers w/ the same vhost, falling back to "". */}}
|
765
|
-
{{- $server_tokens := groupByKeys $vhost_containers "Env.SERVER_TOKENS" | first | default "" | trim }}
|
766
|
-
|
767
|
-
{{- /* Get the SSL_POLICY defined by containers w/ the same vhost, falling back to empty string (use default). */}}
|
768
|
-
{{- $ssl_policy := groupByKeys $vhost_containers "Env.SSL_POLICY" | first | default "" }}
|
769
|
-
|
770
|
-
{{- /* Get the HSTS defined by containers w/ the same vhost, falling back to "max-age=31536000". */}}
|
771
|
-
{{- $hsts := groupByKeys $vhost_containers "Env.HSTS" | first | default $globals.config.hsts }}
|
772
|
-
|
773
|
-
{{- /* Get the VIRTUAL_ROOT By containers w/ use fastcgi root */}}
|
774
|
-
{{- $vhost_root := groupByKeys $vhost_containers "Env.VIRTUAL_ROOT" | first | default "/var/www/public" }}
|
775
|
-
|
776
|
-
{{- $vhost_data = merge $vhost_data (dict
|
777
|
-
"cert" $cert
|
778
|
-
"cert_ok" $cert_ok
|
779
|
-
"enable_debug_endpoint" $enable_debug_endpoint
|
780
|
-
"default" $default
|
781
|
-
"hsts" $hsts
|
782
|
-
"https_method" $https_method
|
783
|
-
"non_get_redirect" $non_get_redirect
|
784
|
-
"http2_enabled" $http2_enabled
|
785
|
-
"http3_enabled" $http3_enabled
|
786
|
-
"is_regexp" $is_regexp
|
787
|
-
"acme_http_challenge_legacy" $acme_http_challenge_legacy
|
788
|
-
"acme_http_challenge_enabled" $acme_http_challenge_enabled
|
789
|
-
"server_tokens" $server_tokens
|
790
|
-
"ssl_policy" $ssl_policy
|
791
|
-
"trust_default_cert" $trust_default_cert
|
792
|
-
"upstream_name" $upstream_name
|
793
|
-
"vhost_root" $vhost_root
|
794
|
-
) }}
|
795
|
-
{{- $_ := set $globals.vhosts $hostname $vhost_data }}
|
796
|
-
{{- end }}
|
797
|
-
|
798
|
-
|
799
|
-
{{- /*
|
800
|
-
* If needed, create a catch-all fallback server to send an error code to
|
801
|
-
* clients that request something from an unknown vhost.
|
802
|
-
*
|
803
|
-
* This server must appear first in the generated config because nginx uses
|
804
|
-
* the first `server` directive to handle requests that don't match any of
|
805
|
-
* the other `server` directives. An alternative approach would be to add
|
806
|
-
* the `default_server` option to the `listen` directives inside this
|
807
|
-
* `server`, but some users inject a custom `server` directive that uses
|
808
|
-
* `default_server`. Using `default_server` here would cause nginx to fail
|
809
|
-
* to start for those users. See
|
810
|
-
* <https://github.com/nginx-proxy/nginx-proxy/issues/2212>.
|
811
|
-
*/}}
|
812
|
-
{{- block "fallback_server" $globals }}
|
813
|
-
{{- $globals := . }}
|
814
|
-
{{- $http_exists := false }}
|
815
|
-
{{- $https_exists := false }}
|
816
|
-
{{- $default_http_exists := false }}
|
817
|
-
{{- $default_https_exists := false }}
|
818
|
-
{{- $http3_enabled := false }}
|
819
|
-
{{- range $vhost := $globals.vhosts }}
|
820
|
-
{{- $http := ne $vhost.https_method "nohttp" }}
|
821
|
-
{{- $https := ne $vhost.https_method "nohttps" }}
|
822
|
-
{{- $http_exists = or $http_exists $http }}
|
823
|
-
{{- $https_exists = or $https_exists $https }}
|
824
|
-
{{- $default_http_exists = or $default_http_exists (and $http $vhost.default) }}
|
825
|
-
{{- $default_https_exists = or $default_https_exists (and $https $vhost.default) }}
|
826
|
-
{{- $http3_enabled = or $http3_enabled $vhost.http3_enabled }}
|
827
|
-
{{- end }}
|
828
|
-
{{- $fallback_http := not $default_http_exists }}
|
829
|
-
{{- $fallback_https := not $default_https_exists }}
|
830
|
-
{{- /*
|
831
|
-
* If there are no vhosts at all, create fallbacks for both plain http
|
832
|
-
* and https so that clients get something more useful than a connection
|
833
|
-
* refused error.
|
834
|
-
*/}}
|
835
|
-
{{- if and (not $http_exists) (not $https_exists) }}
|
836
|
-
{{- $fallback_https = true }}
|
837
|
-
{{- end }}
|
838
|
-
{{- if or $fallback_http $fallback_https }}
|
839
|
-
server {
|
840
|
-
server_name _; # This is just an invalid value which will never trigger on a real hostname.
|
841
|
-
server_tokens off;
|
842
|
-
{{ template "access_log" (dict "Enable" $globals.config.enable_access_log) }}
|
843
|
-
http2 on;
|
844
|
-
{{- if $fallback_http }}
|
845
|
-
listen {{ $globals.config.external_http_port }}; {{- /* Do not add `default_server` (see comment above). */}}
|
846
|
-
{{- if $globals.config.enable_ipv6 }}
|
847
|
-
listen [::]:{{ $globals.config.external_http_port }}; {{- /* Do not add `default_server` (see comment above). */}}
|
848
|
-
{{- end }}
|
849
|
-
{{- end }}
|
850
|
-
{{- if $fallback_https }}
|
851
|
-
listen {{ $globals.config.external_https_port }} ssl; {{- /* Do not add `default_server` (see comment above). */}}
|
852
|
-
{{- if $globals.config.enable_ipv6 }}
|
853
|
-
listen [::]:{{ $globals.config.external_https_port }} ssl; {{- /* Do not add `default_server` (see comment above). */}}
|
854
|
-
{{- end }}
|
855
|
-
{{- if $http3_enabled }}
|
856
|
-
http3 on;
|
857
|
-
listen {{ $globals.config.external_https_port }} quic reuseport; {{- /* Do not add `default_server` (see comment above). */}}
|
858
|
-
{{- if $globals.config.enable_ipv6 }}
|
859
|
-
listen [::]:{{ $globals.config.external_https_port }} quic reuseport; {{- /* Do not add `default_server` (see comment above). */}}
|
860
|
-
{{- end }}
|
861
|
-
{{- end }}
|
862
|
-
ssl_session_cache shared:SSL:50m;
|
863
|
-
ssl_session_tickets off;
|
864
|
-
{{- end }}
|
865
|
-
{{- if $globals.config.default_cert_ok }}
|
866
|
-
ssl_certificate /etc/nginx/certs/default.crt;
|
867
|
-
ssl_certificate_key /etc/nginx/certs/default.key;
|
868
|
-
{{- else }}
|
869
|
-
# No default certificate found, so reject SSL handshake;
|
870
|
-
ssl_reject_handshake on;
|
871
|
-
{{- end }}
|
872
|
-
|
873
|
-
{{- if (exists "/usr/share/nginx/html/errors/50x.html") }}
|
874
|
-
error_page 500 502 503 504 /50x.html;
|
875
|
-
location /50x.html {
|
876
|
-
root /usr/share/nginx/html/errors;
|
877
|
-
internal;
|
878
|
-
}
|
879
|
-
{{- end }}
|
880
|
-
location ^~ / {
|
881
|
-
return 503;
|
882
|
-
}
|
883
|
-
}
|
884
|
-
{{- end }}
|
885
|
-
{{- end }}
|
886
|
-
|
887
|
-
{{- range $hostname, $vhost := $globals.vhosts }}
|
888
|
-
{{- $default_server := when $vhost.default "default_server" "" }}
|
889
|
-
|
890
|
-
{{- range $path, $vpath := $vhost.paths }}
|
891
|
-
# {{ $hostname }}{{ $path }}
|
892
|
-
{{ template "upstream" (dict "globals" $globals "Path" $path "VPath" $vpath) }}
|
893
|
-
{{- end }}
|
894
|
-
|
895
|
-
{{- if (eq $vhost.https_method "redirect") }}
|
896
|
-
server {
|
897
|
-
server_name {{ $hostname }};
|
898
|
-
{{- if $vhost.server_tokens }}
|
899
|
-
server_tokens {{ $vhost.server_tokens }};
|
900
|
-
{{- end }}
|
901
|
-
{{ template "access_log" (dict "Enable" $globals.config.enable_access_log) }}
|
902
|
-
listen {{ $globals.config.external_http_port }} {{ $default_server }};
|
903
|
-
{{- if $globals.config.enable_ipv6 }}
|
904
|
-
listen [::]:{{ $globals.config.external_http_port }} {{ $default_server }};
|
905
|
-
{{- end }}
|
906
|
-
|
907
|
-
{{- if (or $vhost.acme_http_challenge_legacy $vhost.acme_http_challenge_enabled) }}
|
908
|
-
# Do not HTTPS redirect Let's Encrypt ACME challenge
|
909
|
-
location ^~ /.well-known/acme-challenge/ {
|
910
|
-
auth_basic off;
|
911
|
-
auth_request off;
|
912
|
-
allow all;
|
913
|
-
root /usr/share/nginx/html;
|
914
|
-
try_files $uri =404;
|
915
|
-
break;
|
916
|
-
}
|
917
|
-
{{- end }}
|
918
|
-
|
919
|
-
{{- if $vhost.enable_debug_endpoint }}
|
920
|
-
{{ template "debug_location" (dict "GlobalConfig" $globals.config "Hostname" $hostname "VHost" $vhost) }}
|
921
|
-
{{- end }}
|
922
|
-
|
923
|
-
location / {
|
924
|
-
{{- $redirect_uri := "https://$host$request_uri" }}
|
925
|
-
{{- if ne $globals.config.external_https_port "443" }}
|
926
|
-
{{- $redirect_uri = printf "https://$host:%s$request_uri" $globals.config.external_https_port }}
|
927
|
-
{{- end}}
|
928
|
-
if ($request_method ~ (OPTIONS|POST|PUT|PATCH|DELETE)) {
|
929
|
-
return {{ $vhost.non_get_redirect }} {{ $redirect_uri }};
|
930
|
-
}
|
931
|
-
return 301 {{ $redirect_uri }};
|
932
|
-
}
|
933
|
-
}
|
934
|
-
{{- end }}
|
935
|
-
|
936
|
-
server {
|
937
|
-
{{- if $vhost.is_regexp }}
|
938
|
-
{{- if or
|
939
|
-
(printf "/etc/nginx/vhost.d/%s" $hostname | exists)
|
940
|
-
(printf "/etc/nginx/vhost.d/%s_location" $hostname | exists)
|
941
|
-
(printf "/etc/nginx/vhost.d/%s_location_override" $hostname | exists)
|
942
|
-
(printf "/etc/nginx/htpasswd/%s" $hostname | exists)
|
943
|
-
}}
|
944
|
-
# https://github.com/nginx-proxy/nginx-proxy/issues/2529#issuecomment-2437609249
|
945
|
-
# Support for vhost config file(s) named like a regexp ({{ $hostname }}) has been removed from nginx-proxy.
|
946
|
-
# Please name your vhost config file(s) with the sha1 of the regexp instead ({{ $hostname }} -> {{ sha1 $hostname }}) :
|
947
|
-
# - /etc/nginx/vhost.d/{{ sha1 $hostname }}
|
948
|
-
# - /etc/nginx/vhost.d/{{ sha1 $hostname }}_location
|
949
|
-
# - /etc/nginx/vhost.d/{{ sha1 $hostname }}_location_override
|
950
|
-
# - /etc/nginx/htpasswd/{{ sha1 $hostname }}
|
951
|
-
{{- end }}
|
952
|
-
{{- end }}
|
953
|
-
|
954
|
-
server_name {{ $hostname }};
|
955
|
-
{{- if $vhost.server_tokens }}
|
956
|
-
server_tokens {{ $vhost.server_tokens }};
|
957
|
-
{{- end }}
|
958
|
-
{{ template "access_log" (dict "Enable" $globals.config.enable_access_log) }}
|
959
|
-
{{- if $vhost.http2_enabled }}
|
960
|
-
http2 on;
|
961
|
-
{{- end }}
|
962
|
-
|
963
|
-
{{- $args := dict "globals" $globals "hostname" $hostname }}
|
964
|
-
{{ template "parseHost" $args }}
|
965
|
-
{{- if eq ($args.scheme) "http" }}
|
966
|
-
listen {{ $args.port }} {{ $default_server }};
|
967
|
-
{{- if $globals.config.enable_ipv6 }}
|
968
|
-
listen [::]:{{ $args.port }} {{ $default_server }};
|
969
|
-
{{- end }}
|
970
|
-
|
971
|
-
{{- if (and (eq $vhost.https_method "noredirect") $vhost.acme_http_challenge_enabled) }}
|
972
|
-
location /.well-known/acme-challenge/ {
|
973
|
-
auth_basic off;
|
974
|
-
allow all;
|
975
|
-
root /usr/share/nginx/html;
|
976
|
-
try_files $uri =404;
|
977
|
-
break;
|
978
|
-
}
|
979
|
-
{{- end }}
|
980
|
-
{{- end }}
|
981
|
-
{{- if eq ($args.scheme) "https" }}
|
982
|
-
listen {{ $args.port }} ssl {{ $default_server }};
|
983
|
-
{{- if $globals.config.enable_ipv6 }}
|
984
|
-
listen [::]:{{ $args.port }} ssl {{ $default_server }};
|
985
|
-
{{- end }}
|
986
|
-
|
987
|
-
{{- if $vhost.http3_enabled }}
|
988
|
-
http3 on;
|
989
|
-
add_header alt-svc 'h3=":{{ $globals.config.external_https_port }}"; ma=86400;';
|
990
|
-
listen {{ $args.port }} quic {{ $default_server }};
|
991
|
-
{{- if $globals.config.enable_ipv6 }}
|
992
|
-
listen [::]:{{ $args.port }} quic {{ $default_server }};
|
993
|
-
{{- end }}
|
994
|
-
{{- end }}
|
995
|
-
|
996
|
-
{{- if $vhost.cert_ok }}
|
997
|
-
{{- template "ssl_policy" (dict "ssl_policy" $vhost.ssl_policy) }}
|
998
|
-
|
999
|
-
ssl_session_timeout 5m;
|
1000
|
-
ssl_session_cache shared:SSL:50m;
|
1001
|
-
ssl_session_tickets off;
|
1002
|
-
|
1003
|
-
ssl_certificate /etc/nginx/certs/{{ (printf "%s.crt" $vhost.cert) }};
|
1004
|
-
ssl_certificate_key /etc/nginx/certs/{{ (printf "%s.key" $vhost.cert) }};
|
1005
|
-
|
1006
|
-
{{- if (exists (printf "/etc/nginx/certs/%s.dhparam.pem" $vhost.cert)) }}
|
1007
|
-
ssl_dhparam {{ printf "/etc/nginx/certs/%s.dhparam.pem" $vhost.cert }};
|
1008
|
-
{{- end }}
|
1009
|
-
|
1010
|
-
{{- if (exists (printf "/etc/nginx/certs/%s.chain.pem" $vhost.cert)) }}
|
1011
|
-
ssl_stapling on;
|
1012
|
-
ssl_stapling_verify on;
|
1013
|
-
ssl_trusted_certificate {{ printf "/etc/nginx/certs/%s.chain.pem" $vhost.cert }};
|
1014
|
-
{{- end }}
|
1015
|
-
|
1016
|
-
{{- if (not (or (eq $vhost.https_method "noredirect") (eq $vhost.hsts "off"))) }}
|
1017
|
-
set $sts_header "";
|
1018
|
-
if ($https) {
|
1019
|
-
set $sts_header "{{ trim $vhost.hsts }}";
|
1020
|
-
}
|
1021
|
-
add_header Strict-Transport-Security $sts_header always;
|
1022
|
-
{{- end }}
|
1023
|
-
{{- else if not $vhost.trust_default_cert | and $globals.config.default_cert_ok }}
|
1024
|
-
# No certificate found for this vhost, and the default certificate isn't trusted, so reject SSL handshake.
|
1025
|
-
ssl_reject_handshake on;
|
1026
|
-
{{- else }}
|
1027
|
-
# No certificate for this vhost nor default certificate found, so reject SSL handshake.
|
1028
|
-
ssl_reject_handshake on;
|
1029
|
-
{{- end }}
|
1030
|
-
{{- end }}
|
1031
|
-
|
1032
|
-
{{- $vhostFileName := $vhost.is_regexp | ternary (sha1 $hostname) $hostname }}
|
1033
|
-
|
1034
|
-
{{- if (exists (printf "/etc/nginx/vhost.d/%s" $vhostFileName)) }}
|
1035
|
-
include {{ printf "/etc/nginx/vhost.d/%s" $vhostFileName }};
|
1036
|
-
{{- else if (exists "/etc/nginx/vhost.d/default") }}
|
1037
|
-
include /etc/nginx/vhost.d/default;
|
1038
|
-
{{- end }}
|
1039
|
-
|
1040
|
-
{{- if $vhost.enable_debug_endpoint }}
|
1041
|
-
{{ template "debug_location" (dict "GlobalConfig" $globals.config "Hostname" $hostname "VHost" $vhost) }}
|
1042
|
-
{{- end }}
|
1043
|
-
|
1044
|
-
{{- range $path, $vpath := $vhost.paths }}
|
1045
|
-
{{- template "location" (dict
|
1046
|
-
"Path" $path
|
1047
|
-
"Host" $vhostFileName
|
1048
|
-
"HostIsRegexp" $vhost.is_regexp
|
1049
|
-
"VhostRoot" $vhost.vhost_root
|
1050
|
-
"VPath" $vpath
|
1051
|
-
) }}
|
1052
|
-
{{- end }}
|
1053
|
-
|
1054
|
-
{{- if and (not (contains $vhost.paths "/")) (ne $globals.config.default_root_response "none")}}
|
1055
|
-
location / {
|
1056
|
-
return {{ $globals.config.default_root_response }};
|
1057
|
-
}
|
1058
|
-
{{- end }}
|
1059
|
-
}
|
1060
|
-
{{- end }}
|