I have a NGINX server with proxy to apache. Wp-Rocket making all cache job, and store cache files to wp-content/cache/wp-rocket/mysite.com/ Each index file saved as index-https.html The idea is to prevent proxying if the index file already exists. Each time I refresh the page, I see GET requests in Apache logs. Can you please point me what I'm doing wrong?
root /var/www/html;
location ~ \.php$ {
error_page 420 = @apache;
return 420;
}
location / {
index index.html index-https.html;
error_page 420 = @apache;
error_page 405 = @apache;
if ($request_method = POST ) {
return 420;
}
if ( $query_string ){
return 420;
}
if ( $http_cookie ~ "wordpress_logged_in" ){
return 420;
}
expires 365d;
add_header Cache-Control "public, no-transform";
gzip_static on;
try_files $uri wp-content/cache/wp-rocket/mysite.com/$uri/ @apache;
}
location @apache {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_hide_header Upgrade;
}
Tried to specify index files (index-https.html) but no luck also tried:
try_files $uri wp-content/cache/wp-rocket/mysite.com/$uri/ @apache;
try_files $uri /wp-content/cache/wp-rocket/mysite.com/$uri/ @apache;
try_files $uri /wp-content/cache/wp-rocket/mysite.com/$uri @apache;
try_files $uri /wp-content/cache/wp-rocket/mysite.com/$uri/index-https.html @apache;
CodePudding user response:
The URI /resumes/marina-7/
should point to the file /var/www/html/wp-content/cache/wp-rocket/mysite.com/resumes/marina-7/index-https.html
The value of $uri
is exactly /resumes/marina-7/
, so take care you do not insert extra /
s before or after the variable.
Use:
try_files $uri /wp-content/cache/wp-rocket/mysite.com${uri}index-https.html @apache;
Notice that the term must begin with a /
and that braces are used to delimit the variable name.