• Hello, I’m having a hard time getting the plugin to auto purge on page/post updates. I believe it has something to do me having a reverse proxy and doing SSL termination in front of the wordpress site. All HTTP traffic gets redirected to HTTPS by the load balancer which then communicates to the backend server via port 80.

    :443 nginx –> :80 Apache/php-fpm

    I’m using nginx as the cache as well as the ssl termination. I think it’s setup correctly as I see hashes created on the ngx filesystem as well as “Hit” status in the header. The cache purge actually works if I manually request the url from a browser. I just can’t get it work via the plugin.

    Here’s my nginx.conf:

    proxy_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
    proxy_cache_key "$scheme$request_method$host$request_uri";
    proxy_cache_use_stale error timeout invalid_header http_500;
    proxy_ignore_headers Cache-Control Expires Set-Cookie;
    
    location ~ /purge(/.*) {
                proxy_cache_purge WORDPRESS "$scheme$request_method$host$1";
            }
    
    location ~ / {
            proxy_pass https://wordpress:8080;
            proxy_set_header Host $http_host;
            proxy_set_header   X-Forwarded-Host $http_host;
            proxy_no_cache $skip_cache;
            proxy_cache_bypass $skip_cache;
            proxy_cache            WORDPRESS;
            proxy_cache_valid      200  1d;
            add_header X-Cache-Status $upstream_cache_status;
            add_header X-Forwarded-Host $http_host;
    }

    nginx_helper.log

    2018-03-09 00:00:28  | INFO | Purge post on transition post STATUS from publish to publish
    2018-03-09 00:00:28  | INFO | * * * * *
    2018-03-09 00:00:28  | INFO | * Blog :: Site4 (1).
    2018-03-09 00:00:28  | INFO | * Custom post type 'post' :: Hello world – Gamma (1).
    2018-03-09 00:00:28  | INFO | * CPT 'post' (1) published or edited and its status is published
    2018-03-09 00:00:28  | INFO | * * * * *
    2018-03-09 00:00:28  | INFO | Function purgePost BEGIN ===
    2018-03-09 00:00:28  | INFO | Purging homepage 'https://REDACTED/site4/'
    2018-03-09 00:00:28  | INFO | - Purging URL | https://REDACTED/site4/
    2018-03-09 00:00:28  | INFO | - - https://REDACTED/purge/site4/ is currently not cached
    2018-03-09 00:00:28  | INFO | - - https://REDACTED/purge/site4/feed/ is currently not cached
    2018-03-09 00:00:28  | INFO | - - https://REDACTED/purge/site4/feed/atom/ is currently not cached
    2018-03-09 00:00:28  | INFO | - - https://REDACTED/purge/site4/feed/rdf/ is currently not cached
    2018-03-09 00:00:28  | INFO | Purging post (id 1, blog id 1)
    2018-03-09 00:00:28  | INFO | - Purging URL | https://REDACTED/site4/hello-world/
    2018-03-09 00:00:28  | INFO | - - https://REDACTED/purge/site4/hello-world/ is currently not cached
    2018-03-09 00:00:28  | INFO | - - https://REDACTED/purge/site4/hello-world/feed/ is currently not cached
    2018-03-09 00:00:28  | INFO | - - https://REDACTED/purge/site4/hello-world/feed/atom/ is currently not cached
    2018-03-09 00:00:28  | INFO | - - https://REDACTED/purge/site4/hello-world/feed/rdf/ is currently not cached

    And when requesting via browser URL: https://REDACTED/purge/site4/hello-world/

    Successful purge
    Key : httpGETREDACTED/site4/hello-world/ 
    Path: /var/run/nginx-cache/e/45/9336f0f5c3f474ab8972e418a5c8245e
    nginx/1.10.3

    Any ideas? obviously the plugin is trying to connect via http. Does it don’t follow through the redirect to https?

    Thanks in advanced, I know it’s a complicated setup but it’s this way due to multiple apps and docker containers under the same url structure.

Viewing 1 replies (of 1 total)
  • Thread Starter castle9mm

    (@castle9mm)

    I may have found the issue and solution. After greping the nginx cache keys and using curl from the multiple hosts, I found that nginx was creating different keys for the same URL when they should have been serving the already cached copy. After messing around a bit, I found the culprit was the VARY header causing each request to be slightly different on each host request. Anyway, modifying the cache_ignore_headers to include Vary, helped in my case. More testing to make sure it doesn’t causes other issues but thought I would drop it here in case someone else having the same issue as I.

    proxy_ignore_headers Cache-Control Expires Set-Cookie Vary;

Viewing 1 replies (of 1 total)
  • The topic ‘Purge won’t work behind SSL termination?’ is closed to new replies.