You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: router/image/templates/nginx.conf
+23-1Lines changed: 23 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,17 @@ http {
69
69
''$scheme;
70
70
}
71
71
72
-
{{$enforceHTTPS := or (getv "/deis/router/enforceHTTPS")"false"}}
72
+
## HSTS instructs the browser to replace all HTTP links with HTTPS links for this domain until maxAge seconds from now
73
+
{{$enableHSTS := or (getv "/deis/router/hsts/enabled")"false"}}
74
+
{{$maxAgeHSTS := or (getv "/deis/router/hsts/maxAge")"10886400"}}
75
+
{{$includeSubdomainsHSTS := or (getv "/deis/router/hsts/includeSubDomains")"false"}}
76
+
{{$preloadHSTS := or (getv "/deis/router/hsts/preload")"false"}}
77
+
map$access_scheme$sts{
78
+
'https' 'max-age={{ $maxAgeHSTS }}{{ if eq $includeSubdomainsHSTS "true" }}; includeSubDomains{{ end }}{{ if eq $preloadHSTS "true" }}; preload{{ end }}';
79
+
}
80
+
81
+
## since HSTS headers are not permitted on HTTP requests, 301 redirects to HTTPS resources are also necessary
82
+
{{$enforceHTTPS := or (getv "/deis/router/enforceHTTPS")$enableHSTS"false"}}
73
83
74
84
## start deis-controller
75
85
{{if exists "/deis/controller/host"}}
@@ -115,6 +125,10 @@ http {
115
125
return301 https://$host$request_uri;
116
126
}
117
127
{{ end }}
128
+
129
+
{{if eq $enableHSTS"true"}}
130
+
add_header Strict-Transport-Security $sts always;
131
+
{{ end }}
118
132
}
119
133
## end deis-controller
120
134
@@ -230,6 +244,10 @@ http {
230
244
}
231
245
{{ end }}
232
246
247
+
{{if eq $enableHSTS"true"}}
248
+
add_header Strict-Transport-Security $sts always;
249
+
{{ end }}
250
+
233
251
## workaround for nginx hashing empty string bug http://trac.nginx.org/nginx/ticket/765
0 commit comments