Cloudways is using Nginx together with Memcached, Varnish, and Redis to deliver faster responses to your website requests. The Nginx server will cache your static content including all your WordPress file uploads. The issue is Nginx caches your protected files as well, which makes them accessible to anyone with their file URLs.
Exclude protected files from Varnish caching
If you’re using Apache server, follow these 3 simple steps to exclude your protected files from caching.
- Under your Cloudways dashboard, go to “Application Settings”
- Under “Varnish settings” tab, click on “Add New Rule”
- Exclude “/wp-content/uploads/_pda” URL as per this screenshot
- In case, you’re using our Folder Protection feature, please exclude your folder accordingly – as per our first rule
Set up Raw URLs for PDA Gold file protection to work properly on Nginx
Please follow 3 steps below to make our Prevent Direct Access Gold plugin work nicely with Cloudways Nginx server:
-
- Enable our Raw URLs option
- Access to your website server using SSH or SFTP
- Go to our
_pda
folder located atwp-content/uploads/_pda
- Create a .htaccess file inside the
_pda
folder with the following rules
Order deny, allow Deny from all
You can ask Cloudways customer support to do this if it’s too technical for you.
- Go to our
- Contact Cloudways customer support and ask them to exclude our _pda folder from server cache
That’s all. Now, all your files should be protected correctly with our PDA Gold.
Protected images display issue: Exclude Varnish caching
There are cases where protected images returning 404 on Cloudways hosting. In other words, there are missing thumbnails on your Media Library and that you can’t access those image file URLs directly.
If that’s the case, please follow similar steps above to remove protected images from caching and get everything working correctly again.
-
-
- Under your Cloudways dashboard, go to “Application Settings”
- Under “Varnish settings” tab, click on “Add New Rule”
- Exclude “/index.php” URL as per this screenshot
-
That’s it. Now, all your protected images should show up as normal.