15
15
###################################################################################################
16
16
17
17
set $rocket_debug 0; # Add debug information into header
18
+ set $rocket_hsts_value ""; # HTTP Strict Transport Security (if you want overwrite default)
18
19
19
20
###################################################################################################
20
21
# Do not alter theses values
21
22
#
22
23
set $rocket_bypass 1; # Should NGINX bypass WordPress and call cache file directly ?
23
24
set $rocket_encryption ""; # Is GZIP accepted by client ?
24
25
set $rocket_file ""; # Filename to use
25
- set $rocket_is_bypassed "No"; # Header text added to check if the bypass worked or not. Header: X-Rocket-Nginx-Bypass
26
+ set $rocket_is_bypassed "No"; # Header text added to check if the bypass worked or not. Header: X-Rocket-Nginx-Bypass
26
27
set $rocket_reason ""; # Reason why cache file was not used. If cache file is used, what file was used
27
- set $rocket_https_prefix ""; # HTTPS prefix to use when cached files are using HTTPS
28
+ set $rocket_https_prefix ""; # HTTPS prefix to use when cached files are using HTTPS
29
+ set $rocket_hsts 0; # Is HSTS is off (0) by default. Will be turned on (1) if request is HTTPS
30
+ set $rocket_hsts_value_default "max-age=31536000; includeSubDomains";
28
31
29
32
30
33
###################################################################################################
@@ -39,6 +42,17 @@ if ($http_accept_encoding ~ gzip) {
39
42
# Is SSL request ?
40
43
if ($https = "on") {
41
44
set $rocket_https_prefix "-https";
45
+ set $rocket_hsts 1;
46
+ }
47
+
48
+ # If HSTS value is not set, use default value
49
+ if ($rocket_hsts_value = "") {
50
+ set $rocket_hsts_value "$rocket_hsts_value_default";
51
+ }
52
+
53
+ # If HSTS is disabled, unset HSTS set for Rocket-Nginx configuration
54
+ if ($rocket_hsts = "0") {
55
+ set $rocket_hsts_value "";
42
56
}
43
57
44
58
# File/URL to return IF we must bypass WordPress
@@ -101,6 +115,7 @@ location ~ /wp-content/cache/wp-rocket/.*html$ {
101
115
add_header X-Rocket-Nginx-Bypass $rocket_is_bypassed;
102
116
add_header X-Rocket-Nginx-Reason $rocket_reason;
103
117
add_header X-Rocket-Nginx-File $rocket_file;
118
+ add_header Strict-Transport-Security "$rocket_hsts_value";
104
119
expires 30d;
105
120
}
106
121
@@ -114,6 +129,7 @@ location ~ /wp-content/cache/wp-rocket/.*_gzip$ {
114
129
add_header X-Rocket-Nginx-Bypass $rocket_is_bypassed;
115
130
add_header X-Rocket-Nginx-Reason $rocket_reason;
116
131
add_header X-Rocket-Nginx-File $rocket_file;
132
+ add_header Strict-Transport-Security "$rocket_hsts_value";
117
133
expires 30d;
118
134
}
119
135
@@ -122,6 +138,8 @@ add_header X-Rocket-Nginx-Bypass $rocket_is_bypassed;
122
138
add_header X-Rocket-Nginx-Reason $rocket_reason;
123
139
add_header X-Rocket-Nginx-File $rocket_file;
124
140
141
+ # No HSTS header added here. We suppose it's correctly added in the site configuration
142
+
125
143
126
144
###################################################################################################
127
145
# BROWSER CSS CACHE
0 commit comments