How do I configure WordPress to work with Varnish SSL?

Unlimited Requests. Unlimited Servers. One Plan!

Need help with your Varnish configuration? Get Varnish support!

THESE STEPS ARE NO LONGER APPLICABLE STARTING FROM cPanel Varnish Plugin v6.0

The second you enable SSL in Varnish all current SSL installations, those you completed via cPanel, will stop working. This is because the plugin reprograms the SSL port of 443, that Apache listens on, to 4443. Nginx is then made to listen on port 443 (Nginx terminates SSL traffic for Varnish).

Please, plan ahead for this change (during low traffic periods) so you have a minute or two to enter the SSL certificate info into the WHM Varnish plugin screen.


There are a few extra steps that are needed to ensure Varnish can cache SSL traffic for WordPress. Here they are: 1. Your htaccess rules must not have forced https redirect like this. Do NOT do the following nor install a https redirection plugin: RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] Do this instead: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 2. Must have non-https URL (http://) in siteurl and home options in table wp_options ( or $table_prefix . options if not default) +-------------+--------------------------------+ | option_name | option_value | +-------------+--------------------------------+ | siteurl | http://www.cachoid.com/support | | home | http://www.cachoid.com/support | +-------------+--------------------------------+ 3. wp-config.php must have this line at the very top: if ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){ $_SERVER['HTTPS']='on'; }
  • 14 Users Found This Useful
Was this answer helpful?

Related Articles

Should I enable HTTP/2?

We don't recommend enabling http/2 unless you're absolutely certain all your visitors' browsers...

Important: READ THIS BEFORE ENABLING SSL!

THIS IS NO LONGER APPLICABLE STARTING FROM cPanel Varnish Plugin v6.0 The second you enable SSL...