cloudpanel-io / cloudpanel-ce

1.21k stars 99 forks source link

Varnish never hits cache (Wordpress + Wordfence) #514

Closed rkcreation closed 2 weeks ago

rkcreation commented 2 weeks ago

CloudPanel version(s) affected

2.4.2

Description

Varnish never hits cache, because controller.php is never included. I have to include file manually in wp-config.php to make Varnish cache work. After some digging, the auto_prepend_file directive added in vhost seems to be ignored, because Wordfence create a .user.ini file with auto_prepend_file directive. Any idea to have compatibility?

How to reproduce

Use Wordpress site with Wordfence enabled, and enable Varnish in CloudPanel

Possible Solution

Use another directive? Add this to nginx config :

location ~ ^/\.user\.ini {
  deny all;
}

Additional Context

No response

cloudpanel-io commented 2 weeks ago

As a workaround, you can include another PHP file in the varnish controller.

CloudPanel adds the following lines in the vhost:

auto_prepend_file=/home/$siteUser/.varnish-cache/controller.php;

You can open the controller.php file and include the wordfence file:

include /home/$siteUser/htdocs/...../wordfence-file

After that, remove the "auto_prepend_file" directive from .user.ini