|
2 | 2 | # | HTTP Strict Transport Security (HSTS) |
|
3 | 3 | # ----------------------------------------------------------------------
|
4 | 4 |
|
5 |
| -# Force client-side SSL redirection. |
| 5 | +# Force client-side TLS (Transport Layer Security) redirection. |
6 | 6 | #
|
7 | 7 | # If a user types `example.com` in their browser, even if the server
|
8 | 8 | # redirects them to the secure version of the website, that still leaves
|
9 | 9 | # a window of opportunity (the initial HTTP connection) for an attacker
|
10 | 10 | # to downgrade or redirect the request.
|
11 | 11 | #
|
12 |
| -# The following header ensures that browser will ONLY connect to your |
| 12 | +# The following header ensures that browser only connects to your |
13 | 13 | # server via HTTPS, regardless of what the users type in the browser's
|
14 | 14 | # address bar.
|
15 | 15 | #
|
16 |
| -# (!) Be aware that this, once published, is not revokable and you must ensure |
17 |
| -# being able to serve the site via SSL for the duration you've specified |
18 |
| -# in max-age. When you don't have a valid SSL connection (anymore) your |
19 |
| -# visitors will see a nasty error message even when attempting to connect |
20 |
| -# via simple HTTP. |
| 16 | +# (!) Be aware that Strict Transport Security is not revokable and you |
| 17 | +# must ensure being able to serve the site over HTTPS for the duration |
| 18 | +# you've specified in the `max-age` directive. When you don't have a |
| 19 | +# valid TLS connection anymore (e.g. due to an expired TLS cerfiticate) |
| 20 | +# your visitors will see a nasty error message even when attempting to |
| 21 | +# connect over HTTP. |
21 | 22 | #
|
22 |
| -# (!) Remove the `includeSubDomains` optional directive if the website's |
23 |
| -# subdomains are not using HTTPS. |
| 23 | +# (1) Preloading Strict Transport Security. |
| 24 | +# To submit your site for HSTS preloading, it is required that: |
| 25 | +# * the `includeSubDomains` directive is specified |
| 26 | +# * the `preload` directive is specified |
| 27 | +# * the `max-age` is specified with a value of at least 31536000 seconds (1 year). |
| 28 | +# See deployment recommendations: https://hstspreload.org/#deployment-recommendations |
24 | 29 | #
|
25 |
| -# (1) If you want to submit your site for HSTS preload (2) you must |
26 |
| -# * ensure the `includeSubDomains` directive to be present |
27 |
| -# * the `preload` directive to be specified |
28 |
| -# * the `max-age` to be at least 31536000 seconds (1 year) according to the current status. |
29 |
| -# |
30 |
| -# It is also advised (3) to only serve the HSTS header via a secure connection |
31 |
| -# which can be done with either `env=https` or `"expr=%{HTTPS} == 'on'"` (4). The |
32 |
| -# exact way depends on your environment and might just be tried. |
33 |
| -# |
34 |
| -# (2) https://hstspreload.org/ |
35 |
| -# (3) https://tools.ietf.org/html/rfc6797#section-7.2 |
36 |
| -# (4) https://stackoverflow.com/questions/24144552/how-to-set-hsts-header-from-htaccess-only-on-https/24145033#comment81632711_24145033 |
37 |
| -# |
38 |
| -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security |
39 | 30 | # https://tools.ietf.org/html/rfc6797#section-6.1
|
| 31 | +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security |
40 | 32 | # https://www.html5rocks.com/en/tutorials/security/transport-layer-security/
|
41 | 33 | # https://blogs.msdn.microsoft.com/ieinternals/2014/08/18/strict-transport-security/
|
| 34 | +# https://hstspreload.org/ |
42 | 35 |
|
43 | 36 | <IfModule mod_headers.c>
|
44 |
| - Header always set Strict-Transport-Security "max-age=16070400; includeSubDomains" |
45 |
| - # (1) or if HSTS preloading is desired (respect (2) for current requirements): |
46 |
| - # Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS |
47 |
| - # (4) respectively… (respect (2) for current requirements): |
| 37 | + Header always set Strict-Transport-Security "max-age=16070400; includeSubDomains" "expr=%{HTTPS} == 'on'" |
| 38 | + # (1) Enable your site for HSTS preload inclusion. |
48 | 39 | # Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" "expr=%{HTTPS} == 'on'"
|
49 | 40 | </IfModule>
|
0 commit comments