Skip to content

Commit fca6cb0

Browse files
author
Maxime Jobin
committed
Added SSL support. More debugging. Test with newer version of Nginx and WP-Rocket.
1 parent 1d2def8 commit fca6cb0

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

rocket-nginx.conf

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
# Author: Maxime Jobin
88
# URL: https://github.com/maximejobin/rocket-nginx
99
#
10-
# Tested with WP-Rocket version: 2.5.6
11-
# Tested with NGINX: 1.6.3 (stable)
10+
# Tested with WP-Rocket version: 2.5.11
11+
# Tested with NGINX: 1.8.0 (stable)
1212
#
13-
# Version 0.3
13+
# Version 1.0
1414
#
1515
###################################################################################################
1616

@@ -24,6 +24,7 @@ set $rocket_encryption ""; # Is GZIP accepted by client ?
2424
set $rocket_file ""; # Filename to use
2525
set $rocket_is_bypassed "No"; # Header text added to check if the bypass worked or not. Header: X-Rocket-Nginx-Bypass
2626
set $rocket_reason ""; # Reason why cache file was not used. If cache file is used, what file was used
27+
set $https_prefix "";
2728

2829

2930
###################################################################################################
@@ -35,8 +36,13 @@ if ($http_accept_encoding ~ gzip) {
3536
set $rocket_encryption "_gzip";
3637
}
3738

39+
# Is SSL request ?
40+
if ($https = "on") {
41+
set $https_prefix "-https";
42+
}
43+
3844
# File/URL to return IF we must bypass WordPress
39-
set $rocket_url "/wp-content/cache/wp-rocket/$http_host/$request_uri/index.html$rocket_encryption";
45+
set $rocket_url "/wp-content/cache/wp-rocket/$http_host/$request_uri/index$https_prefix.html$rocket_encryption";
4046
set $rocket_file "$document_root$rocket_url";
4147

4248

@@ -82,19 +88,20 @@ if ($rocket_bypass = 1) {
8288
if ($rocket_debug = 0) {
8389
set $rocket_is_bypassed "";
8490
set $rocket_reason "";
91+
set $rocket_file "";
8592
}
8693

8794
# If the bypass token is still on, rewrite according to the file linked to the request
8895
if ($rocket_bypass = 1) {
8996
rewrite .* "$rocket_url" last;
9097
}
9198

92-
9399
# Add header to HTML cached files
94100
location ~ /wp-content/cache/wp-rocket/.*html$ {
95101
add_header Vary "Accept-Encoding, Cookie";
96102
add_header X-Rocket-Nginx-Bypass $rocket_is_bypassed;
97103
add_header X-Rocket-Nginx-Reason $rocket_reason;
104+
add_header X-Rocket-Nginx-File $rocket_file;
98105
expires 30d;
99106
}
100107

@@ -107,9 +114,15 @@ location ~ /wp-content/cache/wp-rocket/.*_gzip$ {
107114
add_header Vary "Accept-Encoding, Cookie";
108115
add_header X-Rocket-Nginx-Bypass $rocket_is_bypassed;
109116
add_header X-Rocket-Nginx-Reason $rocket_reason;
117+
add_header X-Rocket-Nginx-File $rocket_file;
110118
expires 30d;
111119
}
112120

121+
# Debug header (when file is not cached)
122+
add_header X-Rocket-Nginx-Bypass $rocket_is_bypassed;
123+
add_header X-Rocket-Nginx-Reason $rocket_reason;
124+
add_header X-Rocket-Nginx-File $rocket_file;
125+
113126

114127
###################################################################################################
115128
# BROWSER CSS CACHE
@@ -132,6 +145,6 @@ location ~ /wp-content/cache/min/.*\.js$ {
132145
###################################################################################################
133146
# BROWSER MEDIA CACHE
134147
#
135-
location ~* \.(ico|gif|jpe?g|png|svg|eot|otf|woff|ttf|ogg)$ {
148+
location ~* \.(ico|gif|jpe?g|png|svg|eot|otf|woff|woff2|ttf|ogg)$ {
136149
expires max;
137150
}

0 commit comments

Comments
 (0)