Skip to content

Commit b0c6c9f

Browse files
authored
Merge pull request #1386 from juliushaertl/enh/hsts-https-method-fallback
Add fallback to the proxy containers env for HTTPS_METHOD and HSTS
2 parents 5b46989 + f8b4553 commit b0c6c9f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ a 500.
285285
To serve traffic in both SSL and non-SSL modes without redirecting to SSL, you can include the
286286
environment variable `HTTPS_METHOD=noredirect` (the default is `HTTPS_METHOD=redirect`). You can also
287287
disable the non-SSL site entirely with `HTTPS_METHOD=nohttp`, or disable the HTTPS site with
288-
`HTTPS_METHOD=nohttps`. `HTTPS_METHOD` must be specified on each container for which you want to
289-
override the default behavior. If `HTTPS_METHOD=noredirect` is used, Strict Transport Security (HSTS)
288+
`HTTPS_METHOD=nohttps`. `HTTPS_METHOD` can be specified on each container for which you want to
289+
override the default behavior or on the proxy container to set it globally. If `HTTPS_METHOD=noredirect` is used, Strict Transport Security (HSTS)
290290
is disabled to prevent HTTPS users from being redirected by the client. If you cannot get to the HTTP
291291
site after changing this setting, your browser has probably cached the HSTS policy and is automatically
292292
redirecting you back to HTTPS. You will need to clear your browser's HSTS cache or use an incognito

nginx.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,13 @@ upstream {{ $upstream_name }} {
214214
{{ $network_tag := or (first (groupByKeys $containers "Env.NETWORK_ACCESS")) "external" }}
215215

216216
{{/* Get the HTTPS_METHOD defined by containers w/ the same vhost, falling back to "redirect" */}}
217-
{{ $https_method := or (first (groupByKeys $containers "Env.HTTPS_METHOD")) "redirect" }}
217+
{{ $https_method := or (first (groupByKeys $containers "Env.HTTPS_METHOD")) (or $.Env.HTTPS_METHOD "redirect") }}
218218

219219
{{/* Get the SSL_POLICY defined by containers w/ the same vhost, falling back to empty string (use default) */}}
220220
{{ $ssl_policy := or (first (groupByKeys $containers "Env.SSL_POLICY")) "" }}
221221

222222
{{/* Get the HSTS defined by containers w/ the same vhost, falling back to "max-age=31536000" */}}
223-
{{ $hsts := or (first (groupByKeys $containers "Env.HSTS")) "max-age=31536000" }}
223+
{{ $hsts := or (first (groupByKeys $containers "Env.HSTS")) (or $.Env.HSTS "max-age=31536000") }}
224224

225225
{{/* Get the VIRTUAL_ROOT By containers w/ use fastcgi root */}}
226226
{{ $vhost_root := or (first (groupByKeys $containers "Env.VIRTUAL_ROOT")) "/var/www/public" }}

0 commit comments

Comments
 (0)