SatelliteWP/rocket-nginx

Headers indicating Rocket-nginx not sent

Florjan2digit opened this issue · 1 comments

Hi,
first of all thank you for providing us with this service!

Can you help me in finding out what could possibly be wrong, why the headers are not sent?

Nginx config:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# configuration file /etc/nginx/nginx.conf:

#user  nginx;
worker_processes  1;

#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

#pid        /var/run/nginx.pid;

include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections  4096; ## Default: 1024
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay        on;

    #gzip  on;
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server_tokens off;

    include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

# configuration file /etc/nginx/modules.conf.d/brotli.conf:

        load_module nginx/modules/ngx_http_brotli_filter_module.so;
        load_module nginx/modules/ngx_http_brotli_static_module.so;
    

# configuration file /etc/nginx/mime.types:

types {
    text/html                                        html htm shtml;
    text/css                                         css;
    text/xml                                         xml;
    image/gif                                        gif;
    image/jpeg                                       jpeg jpg;
    application/javascript                           js;
    application/atom+xml                             atom;
    application/rss+xml                              rss;

    text/mathml                                      mml;
    text/plain                                       txt;
    text/vnd.sun.j2me.app-descriptor                 jad;
    text/vnd.wap.wml                                 wml;
    text/x-component                                 htc;

    image/avif                                       avif;
    image/png                                        png;
    image/svg+xml                                    svg svgz;
    image/tiff                                       tif tiff;
    image/vnd.wap.wbmp                               wbmp;
    image/webp                                       webp;
    image/x-icon                                     ico;
    image/x-jng                                      jng;
    image/x-ms-bmp                                   bmp;

    font/woff                                        woff;
    font/woff2                                       woff2;

    application/java-archive                         jar war ear;
    application/json                                 json;
    application/mac-binhex40                         hqx;
    application/msword                               doc;
    application/pdf                                  pdf;
    application/postscript                           ps eps ai;
    application/rtf                                  rtf;
    application/vnd.apple.mpegurl                    m3u8;
    application/vnd.google-earth.kml+xml             kml;
    application/vnd.google-earth.kmz                 kmz;
    application/vnd.ms-excel                         xls;
    application/vnd.ms-fontobject                    eot;
    application/vnd.ms-powerpoint                    ppt;
    application/vnd.oasis.opendocument.graphics      odg;
    application/vnd.oasis.opendocument.presentation  odp;
    application/vnd.oasis.opendocument.spreadsheet   ods;
    application/vnd.oasis.opendocument.text          odt;
    application/vnd.openxmlformats-officedocument.presentationml.presentation
                                                     pptx;
    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
                                                     xlsx;
    application/vnd.openxmlformats-officedocument.wordprocessingml.document
                                                     docx;
    application/vnd.wap.wmlc                         wmlc;
    application/wasm                                 wasm;
    application/x-7z-compressed                      7z;
    application/x-cocoa                              cco;
    application/x-java-archive-diff                  jardiff;
    application/x-java-jnlp-file                     jnlp;
    application/x-makeself                           run;
    application/x-perl                               pl pm;
    application/x-pilot                              prc pdb;
    application/x-rar-compressed                     rar;
    application/x-redhat-package-manager             rpm;
    application/x-sea                                sea;
    application/x-shockwave-flash                    swf;
    application/x-stuffit                            sit;
    application/x-tcl                                tcl tk;
    application/x-x509-ca-cert                       der pem crt;
    application/x-xpinstall                          xpi;
    application/xhtml+xml                            xhtml;
    application/xspf+xml                             xspf;
    application/zip                                  zip;

    application/octet-stream                         bin exe dll;
    application/octet-stream                         deb;
    application/octet-stream                         dmg;
    application/octet-stream                         iso img;
    application/octet-stream                         msi msp msm;

    audio/midi                                       mid midi kar;
    audio/mpeg                                       mp3;
    audio/ogg                                        ogg;
    audio/x-m4a                                      m4a;
    audio/x-realaudio                                ra;

    video/3gpp                                       3gpp 3gp;
    video/mp2t                                       ts;
    video/mp4                                        mp4;
    video/mpeg                                       mpeg mpg;
    video/quicktime                                  mov;
    video/webm                                       webm;
    video/x-flv                                      flv;
    video/x-m4v                                      m4v;
    video/x-mng                                      mng;
    video/x-ms-asf                                   asx asf;
    video/x-ms-wmv                                   wmv;
    video/x-msvideo                                  avi;
}

# configuration file /etc/nginx/conf.d/brotli.conf:
brotli on;
brotli_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

# configuration file /etc/nginx/conf.d/directives.conf:
server {
  # Rocket-Nginx configuration
  include rocket-nginx/conf.d/default.conf;
}

# configuration file /etc/nginx/rocket-nginx/conf.d/default.conf:
###################################################################################################
# Rocket-Nginx
#
# Rocket-Nginx is a NGINX configuration to speedup your WordPress
# website with the cache plugin WP-Rocket (http://wp-rocket.me)
#
# Author: Maxime Jobin
# Maintainer: SatelliteWP.com
# URL: https://github.com/satellitewp/rocket-nginx
#
# Tested with WP-Rocket version: 3.13.3
# Tested with NGINX: 1.25.0 (mainline)
#
# Version 3.0.1
#
###################################################################################################

# Add debug information into header
set $rocket_debug 0;


###################################################################################################
# Do not alter theses values
#
set $rocket_bypass          1;      # Should NGINX bypass WordPress and call cache file directly ?
set $rocket_encryption      "";     # Is GZIP accepted by client ?
set $rocket_file            "";     # Filename to look for
set $rocket_is_bypassed     "MISS"; # Header text added to check if the bypass worked or not. Header: X-Rocket-Nginx-Serving-Static
set $rocket_reason          "";     # Reason why cache file was not used. If cache file is used, what file was used
set $rocket_https_prefix    "";		# HTTPS prefix to use when cached files are using HTTPS
set $rocket_has_query_cache 0;		# Checks if a query string from URL is found from the cached query string
set $rocket_is_https        0;		# Checks if the request is HTTPS
set $rocket_support_webp    0;		# Checks if the request supports WebP
set $rocket_dynamic         "";		# Dynamic value to add to cached filename

###################################################################################################
# PAGE CACHE
#

include /etc/nginx/rocket-nginx/conf.d/default/start.*.conf;

# Define Rocket-Nginx $is_args
set $rocket_is_args $is_args;

set $rocket_uri_path "";
if ($request_uri ~ "^([^?]*)(\?.*)?$") {
	set $rocket_uri_path $1;
}

# Is GZIP accepted by client ?
if ($http_accept_encoding ~ gzip) {
	set $rocket_encryption "_gzip";
}

# Is Brotli accepted by client ?
if ($http_accept_encoding ~ br) {
	set $rocket_encryption "";
}

# Is HTTPS request ?
if ($https = "on") { set $rocket_is_https 1; }
if ($http_x_forwarded_proto = "https") { set $rocket_is_https 1; }
if ($http_front_end_https = "on") { set $rocket_is_https 1; }
if ($http_x_forwarded_protocol = "https") { set $rocket_is_https 1; }
if ($http_x_forwarded_ssl = "on") { set $rocket_is_https 1; }
if ($http_x_url_scheme = "https") { set $rocket_is_https 1; }
if ($http_forwarded ~ /proto=https/) { set $rocket_is_https 1; }

if ($rocket_is_https = "1") {
	set $rocket_https_prefix "-https";
}

# Check if request supports WebP ?
if ($http_accept ~* "webp") {
	set $rocket_support_webp "1";
}

# Set mobile detection file path
set $rocket_mobile_detection "$document_root/wp-content/cache/wp-rocket/$http_host/$request_uri/.mobile-active";

# Query strings to ignore
set $rocket_args $args;
if ($rocket_args ~ (.*)(?:&|^)utm_source=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)utm_campaign=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)utm_medium=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)utm_expid=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)utm_term=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)utm_content=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)_ga=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)gclid=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)campaignid=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)adgroupid=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)adid=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)gbraid=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)wbraid=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)gclsrc=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)ef_id=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)fb_action_ids=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)fb_action_types=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)fb_source=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)fbclid=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)mc_cid=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)mc_eid=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)_ke=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)age-verified=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)ao_noptimize=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)usqp=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)cn-reloaded=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)sscid=[^&]*(.*)) { set $rocket_args $1$2; }
if ($rocket_args ~ (.*)(?:&|^)msclkid=[^&]*(.*)) { set $rocket_args $1$2; }

# Remove & at the beginning (if needed)
if ($rocket_args ~ ^&(.*)) { set $rocket_args $1;  }


# Do not count arguments if part of caching arguments
if ($rocket_args ~ ^\?$) {
	set $rocket_is_args "";
}


if ($rocket_args = "") {
	set $rocket_is_args "";
}

# Query string to cache


# File/URL to return IF we must bypass WordPress
# Desktop: index.html
# Gzip:    index.html_gzip
# HTTPS:   index-https.html
# Mobile:  index-mobile-https.html

set $rocket_file_start "index$rocket_https_prefix";

set $rocket_pre_url "/wp-content/cache/wp-rocket/$http_host/$rocket_uri_path/$rocket_args/";
set $rocket_pre_file "$document_root/wp-content/cache/wp-rocket/$http_host/$rocket_uri_path/$rocket_args/";

# Standard cache file format
set $rocket_url "$rocket_pre_url$rocket_file_start$rocket_dynamic.html";
set $rocket_file "$rocket_pre_file$rocket_file_start$rocket_dynamic.html";

# Check if gzip version cached file is available
if (-f "$rocket_file$rocket_encryption") {
	set $rocket_file "$rocket_file$rocket_encryption";
	set $rocket_url  "$rocket_url$rocket_encryption";
}

# Do not bypass if the cached file does not exist
if (!-f "$rocket_file") {
	set $rocket_bypass 0;
	set $rocket_is_bypassed "MISS";
	set $rocket_reason "File not cached";
}

# Do not bypass if it's a POST request
if ($request_method = POST) {
	set $rocket_bypass 0;
	set $rocket_is_bypassed "BYPASS";
	set $rocket_reason "POST request";
}

# Do not bypass if arguments are found (e.g. ?page=2)
if ($rocket_is_args) {
	set $rocket_bypass 0;
	set $rocket_is_bypassed "BYPASS";
	set $rocket_reason "Arguments found";
}

# Do not bypass if the site is in maintenance mode
if (-f "$document_root/.maintenance") {
	set $rocket_bypass 0;
	set $rocket_is_bypassed "BYPASS";
	set $rocket_reason "Maintenance mode";
}

# Do not bypass if one of those cookie if found
# wordpress_logged_in_[hash] : When a user is logged in, this cookie is created (we'd rather let WP-Rocket handle that)
# wp-postpass_[hash] : When a protected post requires a password, this cookie is created.
if ($http_cookie ~* "(wordpress_logged_in_|wp\-postpass_|woocommerce_items_in_cart|woocommerce_cart_hash|wptouch_switch_toogle|comment_author_|comment_author_email_)") {
	set $rocket_bypass 0;
	set $rocket_is_bypassed "BYPASS";
	set $rocket_reason "Cookie";
}

if (-f "$rocket_mobile_detection") {
	set $rocket_bypass 0;
	set $rocket_is_bypassed "BYPASS";
	set $rocket_reason "Specific mobile cache activated";	
}

# If the bypass token is still on, let's bypass WordPress with the cached URL
if ($rocket_bypass = 1) {
	set $rocket_is_bypassed "HIT";
	set $rocket_reason "$rocket_url";
}

# Clear variables if debug is not needed
if ($rocket_debug = 0) {
	set $rocket_reason "";
	set $rocket_file "";
}

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

# Add header to HTML cached files
location ~ /wp-content/cache/wp-rocket/.*html$ {
	etag on;
	add_header Vary "Accept-Encoding, Cookie";
	add_header Cache-Control "no-cache, no-store, must-revalidate";
	add_header X-Rocket-Nginx-Serving-Static $rocket_is_bypassed;
	add_header X-Rocket-Nginx-Reason $rocket_reason;
	add_header X-Rocket-Nginx-File $rocket_file;
	include /etc/nginx/rocket-nginx/conf.d/default/global.*.conf;
	include /etc/nginx/rocket-nginx/conf.d/default/http.*.conf;
}

# Do not gzip cached files that are already gzipped
location ~ /wp-content/cache/wp-rocket/.*_gzip$ {
	etag on;
	gzip off;
	types {}
	default_type text/html;
	add_header Content-Encoding gzip;
	add_header Vary "Accept-Encoding, Cookie";
	add_header Cache-Control "no-cache, no-store, must-revalidate";
	add_header X-Rocket-Nginx-Serving-Static $rocket_is_bypassed;
	add_header X-Rocket-Nginx-Reason $rocket_reason;
	add_header X-Rocket-Nginx-File $rocket_file;
	include /etc/nginx/rocket-nginx/conf.d/default/global.*.conf;
	include /etc/nginx/rocket-nginx/conf.d/default/http.*.conf;
}

# Debug header (when file is not cached)
add_header X-Rocket-Nginx-Serving-Static $rocket_is_bypassed;
add_header X-Rocket-Nginx-Reason $rocket_reason;
add_header X-Rocket-Nginx-File $rocket_file;
include /etc/nginx/rocket-nginx/conf.d/default/global.*.conf;


###################################################################################################
# BROWSER CSS CACHE
#
location ~* \.css$ {
	etag on;
	gzip_vary on;
	expires 30d;
	include /etc/nginx/rocket-nginx/conf.d/default/global.*.conf;
	include /etc/nginx/rocket-nginx/conf.d/default/css.*.conf;
}


###################################################################################################
# BROWSER JS CACHE
#
location ~* \.js$ {
	etag on;
	gzip_vary on;
	expires 30d;
	include /etc/nginx/rocket-nginx/conf.d/default/global.*.conf;
	include /etc/nginx/rocket-nginx/conf.d/default/js.*.conf;
}


###################################################################################################
# BROWSER MEDIA CACHE
#
location ~* \.(ico|gif|jpe?g|png|svg|eot|otf|woff|woff2|ttf|ogg|webp)$ {
	etag on;
	expires 30d;
	include /etc/nginx/rocket-nginx/conf.d/default/global.*.conf;
	include /etc/nginx/rocket-nginx/conf.d/default/media.*.conf;
}

# configuration file /etc/nginx/conf.d/ssl.conf:
ssl_dhparam /opt/psa/etc/dhparams2048.pem;
ssl_protocols TLSv1.2 TLSv1.3;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+AESGCM+AES128:EECDH+AESGCM+AES256:EECDH+CHACHA20:EECDH+SHA256+AES128:EECDH+SHA384+AES256:EECDH+SHA1+AES128:EECDH+SHA1+AES256:EECDH+HIGH:AESGCM+AES128:AESGCM+AES256:CHACHA20:SHA256+AES128:SHA256+AES256:SHA1+AES128:SHA1+AES256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK:!KRB5:!aECDH:!kDH:!EDH;
ssl_prefer_server_ciphers on;

# configuration file /etc/nginx/conf.d/zz010_psa_nginx.conf:
#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
include /etc/nginx/plesk.conf.d/server.conf;
include /etc/nginx/plesk.conf.d/webmails/*.conf;
include /etc/nginx/plesk.conf.d/vhosts/*.conf;
include /etc/nginx/plesk.conf.d/forwarding/*.conf;
include /etc/nginx/plesk.conf.d/wildcards/*.conf;
# configuration file /etc/nginx/plesk.conf.d/server.conf:
#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

include "/etc/nginx/plesk.conf.d/ip_default/*.conf";

server {
	listen 134.122.79.29:443 ssl;
	listen 10.19.0.5:443 ssl;
	listen 10.114.0.7:443 ssl;

	ssl_certificate             "/opt/psa/var/certificates/scfomJsqp";
	ssl_certificate_key         "/opt/psa/var/certificates/scfomJsqp";
	client_max_body_size 2048m;

	proxy_read_timeout 600;
	proxy_send_timeout 600;

	proxy_max_temp_file_size 0;
	proxy_buffers 16 16k;
	proxy_buffer_size 32k;
	proxy_busy_buffers_size 32k;

	server_name _;

	location / {
		proxy_pass http://127.0.0.1:8880;
		proxy_redirect http://$host:8880 $scheme://$host;
		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;
		access_log off;

		gzip on;
		gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
	}

	location ~ /ws$ {
		proxy_pass http://127.0.0.1:8880;
		proxy_redirect off;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "Upgrade";
		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;
		access_log off;
	}

	underscores_in_headers on;
}

server {
	listen 134.122.79.29:80;

	location ^~ /plesk-site-preview/ {
		proxy_pass http://127.0.0.1:8880;
		proxy_set_header Host               plesk-site-preview.local;
		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_cookie_domain plesk-site-preview.local $host;
		access_log off;
	}

	location / {
		proxy_pass http://134.122.79.29:7080;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}
}

server {
	listen 10.19.0.5:80;

	location ^~ /plesk-site-preview/ {
		proxy_pass http://127.0.0.1:8880;
		proxy_set_header Host               plesk-site-preview.local;
		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_cookie_domain plesk-site-preview.local $host;
		access_log off;
	}

	location / {
		proxy_pass http://10.19.0.5:7080;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}
}

server {
	listen 10.114.0.7:80;

	location ^~ /plesk-site-preview/ {
		proxy_pass http://127.0.0.1:8880;
		proxy_set_header Host               plesk-site-preview.local;
		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_cookie_domain plesk-site-preview.local $host;
		access_log off;
	}

	location / {
		proxy_pass http://10.114.0.7:7080;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}
}
# configuration file /etc/nginx/plesk.conf.d/webmails/admiring-banzai.134-122-79-29.plesk.page_webmail.conf:
#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

# Webmail is not enabled on the domain

The domain in question is a temporary domain: https://admiring-banzai.134-122-79-29.plesk.page/

You did not include the configuration at the right place.

You should check with your server administrator. You have to include it in the right existing server { ... } section and not create a new server section.

Have a great day.