rija / docker-nginx-fpm-caches-wordpress

Wordpress (no DB server included) running with Nginx in a Docker container with caching and encryption enabled
Other
23 stars 7 forks source link

Wordpress plugins for Nginx cannot purge fast-cgi cache #9

Open rija opened 6 years ago

rija commented 6 years ago

For security reasons, php-fpm and nginx run under different users so Nginx-Cache and Nginx-Helper plugins cannot delete the cache on the filesystem. This is not desirable anyway because it creates an attack opportunity on the filesystems form Wordpress.

A better approach is to use a location-based approach, something like:

 location ~ /purge(/.*) {
            allow              127.0.0.1;
            deny               all;
            fastcgi_cache_purge  tmpcache $1$is_args$args;
        }

nginx is already compile with ngx_cache_purge.

Only Nginx-Helper supports this in theory but last time I tried it wasn't reliable.

davidsteinberger commented 6 years ago

I just tried fastcgi_cache_purge but couldn't get it working. Is this working for anyone else?

rija commented 6 years ago

I did manage to get it running, but the URL based invalidation wasn't reliable (it seems sometimes/often the cache won't be invalidated even if the url is correct) and the two related supporting wp plugins (one is Nginx Helper) didn't work well for me.

Unless I find out what's the problem or what I did wrong, I may abandon that approach on this project.

Redis and APCu are two approaches that I find more promising.