Configure Varnish (TM) for WordPress
NOTE: The steps below assume that WordPress is already running at the root URL of the server, such as at http://wordpress.example.com/, and that Varnish (TM) is enabled. Varnish (TM) is disabled by default, but you can enable it by following the instructions in our Varnish (TM) guide.
Download the different files used in the example:
NGINX
Follow these steps:
-
Log in to the server console. Learn how to connect to the server through SSH.
-
Backup the Varnish (TM) configuration file:
$ sudo cp /opt/bitnami/varnish/etc/varnish/default.vcl /opt/bitnami/varnish/etc/varnish/default.vcl.backup
-
Add the WordPress-specific Varnish (TM) configuration by executing the following commands:
$ sudo cp wordpress.vcl /opt/bitnami/varnish/etc/varnish/default.vcl $ sudo sed -i 's/port\s*=\s*"[^"]*"/port = "80"/g' /opt/bitnami/varnish/etc/varnish/default.vcl
-
Check if your website is being served properly by Varnish (TM) on port 81 by adding :81 to the domain name in your browser.
-
If Varnish (TM) is working correctly, switch the NGINX and Varnish (TM) ports and activate Varnish (TM) on port 80.
-
Remove the firewall rule for port 81.
Varnish is a registered trademark of Varnish Software AB and its affiliates.