Varnish Cache is a powerful HTTP accelerator that can dramatically improve website speed — especially for dynamic sites like WordPress. However, if you’re using CWP (Control Web Panel) with HTTPS, Varnish often doesn’t work properly until it’s configured the right way.
This guide walks you through setting up Varnish for HTTPS in a CWP environment, step by step.
🔍 Why Varnish Doesn’t Work with HTTPS by Default
Varnish cannot handle HTTPS traffic directly. It must sit behind a web server like Nginx, which terminates the SSL, then passes traffic to Varnish (usually on port 82), and then to Apache.
Without proper configuration, Varnish is skipped entirely for HTTPS traffic — and you lose all caching benefits.
✅ How to Properly Enable Varnish for HTTPS in CWP
🔹 Step 1: Confirm Varnish Is Installed and Running
Run this on your server:
systemctl status varnish
You should see something like:
Active: active (running)
If it’s not installed, do this:
dnf install varnish -y
❗ What If Varnish Is Installed but CWP Doesn’t Recognize It?
If CWP shows:
“Varnish NOT installed or conf file /etc/varnish/varnish.params does not exist”
Even though varnishd -V
works — this is because CWP checks for a specific config file.
✅ Fix: Create the missing config file
nano /etc/varnish/varnish.params
Add this:
VARNISH_LISTEN_PORT=82
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
VARNISH_ADMIN_LISTEN_PORT=6082
VARNISH_SECRET_FILE=/etc/varnish/secret
VARNISH_STORAGE="malloc,256m"
VARNISH_VCL_CONF=/etc/varnish/default.vcl
Then create the secret file if missing:
touch /etc/varnish/secret
Restart Varnish:
systemctl restart varnish
Now CWP will recognize it and allow you to manage it from the panel.
🔹 Step 2: Configure Varnish to Listen on Port 82
Edit:
nano /usr/lib/systemd/system/varnish.service
Make sure this is part of the ExecStart=
line:
-a :82 -T localhost:6082 -f /etc/varnish/default.vcl -s malloc,256m
Reload systemd and restart Varnish:
systemctl daemon-reload
systemctl restart varnish
🔹 Step 3: Enable Varnish in CWP WebServer Stack
From CWP Admin:
- Go to:
WebServer Settings → Select WebServers
- Choose:
Nginx → Varnish → Apache + PHP-FPM
- Click Save & Rebuild Configuration
🔹 Step 4: Update Nginx SSL Vhost to Pass Through Varnish
Edit your SSL vhost file:
nano /etc/nginx/conf.d/vhosts/yourdomain.com.ssl.conf
Find any lines like:
proxy_pass http://127.0.0.1:8181;
Change them to:
proxy_pass http://127.0.0.1:82;
Then restart Nginx:
systemctl restart nginx
🧪 Step 5: Confirm Varnish Is Handling HTTPS Requests
Run:
curl -I https://yourdomain.com --resolve yourdomain.com:443:YOUR.SERVER.IP
Look for headers like:
Via: 1.1 varnish
X-Varnish: 123456
X-Cache: HIT
That means HTTPS traffic is going through Varnish!
🧠 Pro Tip: Customize Caching for WordPress
If you’re using WordPress or WooCommerce, edit /etc/varnish/default.vcl
to bypass cache for:
/wp-login.php
/wp-admin/
/cart
,/checkout
,/my-account
- Logged-in users or WooCommerce session cookies
Also install the Varnish HTTP Purge plugin for automatic purging when content updates.
🚀 Need Better Performance with CWP?
If you’re serious about caching and performance, a high-end VPS or dedicated server makes a big difference.
👉 Explore high-performance VPS & Dedicated Servers optimized for CWP
💬 Need Help with Configuration?
If you’d prefer to have an expert handle it:
📨 Contact Servers9 Support — they’ll help you get Varnish + HTTPS working flawlessly on your CWP server.