Skip to content

Commit b9c83f5

Browse files
committed
Always include a Strict-Transport-Security, even on error responses
This consists of two configuration changes and will allow the Mozilla Observatory to see the HSTS header. Previously, if a client does not request an html content type then we return error JSON with a 404 on `/`. The first change is to add the `always` parameter which was added in nginx 1.7.5. This will include the header for all response status codes. The second change is to duplicate the add_header directive in both blocks. This surprised me, but the documentation states: "There could be several add_header directives. These directives are inherited from the previous level if and only if there are no add_header directives define on the current level."
1 parent 37797c4 commit b9c83f5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

config/nginx.conf.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ http {
3636
listen <%= ENV["PORT"] %>;
3737
server_name _;
3838
keepalive_timeout 5;
39-
add_header Strict-Transport-Security "max-age=31536000";
4039

4140
location ~ ^/assets/ {
41+
add_header Strict-Transport-Security "max-age=31536000" always;
4242
add_header Cache-Control public;
4343
root dist;
4444
expires max;
4545
}
4646

4747
location / {
48+
add_header Strict-Transport-Security "max-age=31536000" always;
4849
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
4950
proxy_set_header Host $http_host;
5051
proxy_redirect off;

0 commit comments

Comments
 (0)