• tesmer

    (@uraniumhazee)


    Hi @isaumya and other experts.
    I have a problem with this plugin.
    I will share everything so you can help me.

    I have a single vps cloud with one IP and we have 2 sites on it. One of them mine and others is my brothers. We register two different Cloudflare account for each domain.

    domains:
    https://wifisifrekirici.com
    https://burunestetigi.xyz

    System: Nginx Debian11 lemp server
    Not necessarry but i will share nginx fastcache blocks too.

    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;
    include /etc/nginx/modules-enabled/*.conf;
    
    events {
    	worker_connections 768;
    	# multi_accept on;
    }
    
    http {
    	# NGINX Cache path
    	fastcgi_cache_path /usr/share/nginx/fastcgi_cache levels=1:2 keys_zone=phpcache:100m max_size=10g inactive=60m use_temp_path=off;
    	fastcgi_cache_key "$scheme$request_method$host$request_uri";
    	##
    	# Basic Settings
    	##
    
    	sendfile on;
    	tcp_nopush on;
    	types_hash_max_size 2048;
    	# server_tokens off;
    
    	# server_names_hash_bucket_size 64;
    	# server_name_in_redirect off;
    
    	include /etc/nginx/mime.types;
    	default_type application/octet-stream;
    
    	##
    	# SSL Settings
    	##
    
    	ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
    	ssl_prefer_server_ciphers on;
    
    	##
    	# Logging Settings
    	##
    
    	access_log /var/log/nginx/access.log;
    	error_log /var/log/nginx/error.log;
    
    	##
    	# Gzip Settings
    	##
    
    	gzip on;
    	gzip_disable "msie6";
    	gzip_vary on;
    	gzip_proxied any;
    	gzip_comp_level 6;
    	gzip_buffers 16 8k;
    	gzip_http_version 1.1;
    	gzip_min_length 256;
    	gzip_types text/richtext text/plain text/css text/vcard text/x-script text/x-component text/x-java-source text/x-markdown text/vnd.rim.location.xloc text/vtt application/javascript application/x-javascript text/javascript text/js text/cache-manifest image/bmp image/x-icon image/vnd.microsoft.icon application/x-perl application/x-httpd-cgi text/xml application/geo+json application/atom+xml application/xml application/rdf+xml application/xml+rss application/vnd.api+json application/vnd.geo+json application/x-protobuf application/json multipart/bag multipart/mixed application/xhtml+xml font/opentype font/eot font/ttf font/otf font/x-woff image/svg+xml application/vnd.ms-fontobject application/ttf application/x-ttf application/x-font-ttf application/otf application/x-otf application/truetype application/opentype application/x-opentype application/font-woff application/eot application/font application/font-sfnt application/wasm application/javascript-binast application/manifest+json application/ld+json application/x-web-app-manifest+json text/x-cross-domain-policy;
    
    	##
    	# Virtual Host Configs
    	##
    
    	include /etc/nginx/conf.d/*.conf;
    	include /etc/nginx/sites-enabled/*;
    }
    
    #mail {
    #	# See sample authentication script at:
    #	# https://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
    #
    #	# auth_http localhost/auth.php;
    #	# pop3_capabilities "TOP" "USER";
    #	# imap_capabilities "IMAP4rev1" "UIDPLUS";
    #
    #	server {
    #		listen     localhost:110;
    #		protocol   pop3;
    #		proxy      on;
    #	}
    #
    #	server {
    #		listen     localhost:143;
    #		protocol   imap;
    #		proxy      on;
    #	}
    #}
    

    each sites domain blocks

    wifisifrekirici.com

    server {
       server_name wifisifrekirici.com www.wifisifrekirici.com;
       root /var/www/wifisifrekirici.com;
       index index.php index.html index.htm;
       client_max_body_size 30M;
    
    set $skip_cache 0;
    
    # POST requests and urls with a query string should always go to PHP
    if ($request_method = POST) {
        set $skip_cache 1;
    }
    if ($query_string != "") {
        set $skip_cache 1;
    }
    
    # Don't cache uris containing the following segments
    if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|^/feed/*|/tag/.*/feed/*|index.php|/.*sitemap.*\.(xml|xsl)") {
        set $skip_cache 1;
    }
    
    # Don't use the cache for logged in users or recent commenters
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
        set $skip_cache 1;
    }
    
    location / {
    		try_files $uri $uri/ /index.php?$args;
    }
    
    location ~ \.php$ {
          include /etc/nginx/fastcgi_params;
          fastcgi_pass unix:/run/php/php7.4-fpm.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_cache_bypass $skip_cache;
          fastcgi_no_cache $skip_cache;
          fastcgi_cache phpcache;
          fastcgi_cache_valid 200 301 302 60m;
          fastcgi_cache_use_stale error timeout updating invalid_header http_500 http_503;
          fastcgi_cache_min_uses 1;
          fastcgi_cache_lock on;
          add_header X-FastCGI-Cache $upstream_cache_status;
          fastcgi_connect_timeout 300s;
          fastcgi_read_timeout 300s;
          fastcgi_send_timeout 300s;
          add_header Content-Security-Policy "default-src https: data: 'unsafe-inline' 'unsafe-eval'" always;
          add_header Strict-Transport-Security "max-age=31536000; includeSubdomains" always;
          add_header X-Frame-Options "SAMEORIGIN" always;
          add_header X-Xss-Protection "1; mode=block" always;
          add_header X-Content-Type-Options "nosniff" always;
    }
    
    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
    location /robots.txt { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
    location ~* \.(css|js|pdf)$ { add_header Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=2592000, stale-while-revalidate=86400, stale-if-error=604800"; expires 30d; }
    location ~* \.(jpg|jpeg|png|gif|ico|eot|swf|svg|webp|avif|ttf|otf|woff|woff2|ogg|mp4|mpeg|avi|mkv|webm|mp3)$ { add_header Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=31536000, stale-while-revalidate=86400, stale-if-error=604800"; expires 365d; }
    location /wp-cron.php { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
    location = /wp-content/wp-cloudflare-super-page-cache/wifisifrekirici.com/debug.log { access_log off; deny all; }
    
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/wifisifrekirici.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/wifisifrekirici.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    
    }
    
    server {
        if ($host = www.wifisifrekirici.com) {
            return 301 https://$host$request_uri;
        } # managed by Certbot
    
        if ($host = wifisifrekirici.com) {
            return 301 https://$host$request_uri;
        } # managed by Certbot
    
       server_name wifisifrekirici.com www.wifisifrekirici.com;
        listen 80;
        return 404; # managed by Certbot
    
    }
    

    burunestetigi

    server {
       server_name burunestetigi.xyz www.burunestetigi.xyz;
       root /var/www/burunestetigi.xyz;
       index index.php index.html index.htm;
       client_max_body_size 30M;
    
    set $skip_cache 0;
    
    # POST requests and urls with a query string should always go to PHP
    if ($request_method = POST) {
        set $skip_cache 1;
    }
    if ($query_string != "") {
        set $skip_cache 1;
    }
    
    # Don't cache uris containing the following segments
    if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|^/feed/*|/tag/.*/feed/*|index.php|/.*sitemap.*\.(xml|xsl)") {
        set $skip_cache 1;
    }
    
    # Don't use the cache for logged in users or recent commenters
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
        set $skip_cache 1;
    }
    
    location / {
    		try_files $uri $uri/ /index.php?$args;
    }
    
    location ~ \.php$ {
          include /etc/nginx/fastcgi_params;
          fastcgi_pass unix:/run/php/php7.4-fpm.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_cache_bypass $skip_cache;
          fastcgi_no_cache $skip_cache;
          fastcgi_cache phpcache;
          fastcgi_cache_valid 200 301 302 60m;
          fastcgi_cache_use_stale error timeout updating invalid_header http_500 http_503;
          fastcgi_cache_min_uses 1;
          fastcgi_cache_lock on;
          add_header X-FastCGI-Cache $upstream_cache_status;
          fastcgi_connect_timeout 300s;
          fastcgi_read_timeout 300s;
          fastcgi_send_timeout 300s;
          add_header Content-Security-Policy "default-src https: data: 'unsafe-inline' 'unsafe-eval'" always;
          add_header Strict-Transport-Security "max-age=31536000; includeSubdomains" always;
          add_header X-Frame-Options "SAMEORIGIN" always;
          add_header X-Xss-Protection "1; mode=block" always;
          add_header X-Content-Type-Options "nosniff" always;
    }
    
    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
    location /robots.txt { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
    location ~* \.(css|js|pdf)$ { add_header Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=2592000, stale-while-revalidate=86400, stale-if-error=604800"; expires 30d; }
    location ~* \.(jpg|jpeg|png|gif|ico|eot|swf|svg|webp|avif|ttf|otf|woff|woff2|ogg|mp4|mpeg|avi|mkv|webm|mp3)$ { add_header Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=31536000, stale-while-revalidate=86400, stale-if-error=604800"; expires 365d; }
    location /wp-cron.php { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
    location = /wp-content/wp-cloudflare-super-page-cache/burunestetigi.xyz/debug.log { access_log off; deny all; }
    
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/burunestetigi.xyz/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/burunestetigi.xyz/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    
    }
    server {
        if ($host = www.burunestetigi.xyz) {
            return 301 https://$host$request_uri;
        } # managed by Certbot
    
        if ($host = burunestetigi.xyz) {
            return 301 https://$host$request_uri;
        } # managed by Certbot
    
       server_name burunestetigi.xyz www.burunestetigi.xyz;
        listen 80;
        return 404; # managed by Certbot
    
    }

    And plugin at plugins all settings are default excepts “Add browser caching rules for static assets”
    it is ON enabled and i added below block to each of domain blocks

    location /robots.txt { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
    location ~* \.(css|js|pdf)$ { add_header Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=2592000, stale-while-revalidate=86400, stale-if-error=604800"; expires 30d; }
    location ~* \.(jpg|jpeg|png|gif|ico|eot|swf|svg|webp|avif|ttf|otf|woff|woff2|ogg|mp4|mpeg|avi|mkv|webm|mp3)$ { add_header Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=31536000, stale-while-revalidate=86400, stale-if-error=604800"; expires 365d; }
    location /wp-cron.php { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
    location = /wp-content/wp-cloudflare-super-page-cache/burunestetigi.xyz/debug.log { access_log off; deny all; }

    Cloudflare 2 different account page rules
    https://burunestetigi.xyz/*
    Cache Level: Cache Everything

    https://wifisifrekirici.com/*
    Cache Level: Cache Everything

    Browser Cache TTL
    respect existing headers

    What is the problem?
    Cache not working properly!
    When i tests pages over vps panel with
    curl -I https://wifisifrekirici.com/cmd
    curl -I https://burunestetigi.xyz/iletisim

    the result are not unstable
    wifisifrekirici is working sometimes but at that time other site is unstable.
    CF-Cache-Status is always different some times hit some times full miss
    For example when i test it at first time it gives misss then miss again then miss then hit then miss again :S

    Ehen i try to disable plugin ina any of my site it gives Invalid page rule identifier (err code: 1002) sometimes.

    I mean this does not work with 2 domain properly! (different cloudflare accounts)
    When i use it with single domain there are no problem!

    How can i fix this problems :S
    Please check my site and reply me. Thanks very much.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘2 Domain Different Acoounts WP Cloudflare Cache Not Working properly’ is closed to new replies.