
4 views
This guide explains how to install and configure Varnish Cache on EL9-based systems when using CWP (CentOS Web Panel) with the Apache + Nginx + Varnish stack.
On AlmaLinux 9 / RockyLinux 9 / RHEL 9, Varnish may not install automatically via CWP.
This guide provides a manual workaround to install and configure it correctly.
Login to CWP Admin Panel
Go to:
WebServer Settings → Select WebServers
Choose:
Apache + Nginx + Varnish
Click Save & Rebuild Configuration
👉 At this stage, Varnish may appear as missing — proceed to Step 2.
Run the following commands:
dnf install -y epel-release
curl -s https://packagecloud.io/install/repositories/varnishcache/varnish66/script.rpm.sh | sudo bash
dnf install -y varnish
Edit the Varnish systemd service file:
nano /usr/lib/systemd/system/varnish.service
ExecStart=/usr/sbin/varnishd -a :6081 ...
ExecStart=/usr/sbin/varnishd -a :82 -f /etc/varnish/default.vcl -s malloc,256m
Run:
systemctl daemon-reexec
systemctl daemon-reload
setenforce 0
systemctl restart varnish
ss -tulnp | grep varnish
systemctl status varnish
Lock the service file to prevent CWP overwriting:
chattr +i /usr/lib/systemd/system/varnish.service
To unlock later:
chattr -i /usr/lib/systemd/system/varnish.service
If your website shows 503 Backend fetch failed, update Varnish backend.
Edit:
nano /etc/varnish/default.vcl
backend default {
.host = "127.0.0.1";
.port = "8080";
}
backend default {
.host = "YOUR_SERVER_IP";
.port = "8181";
}
Example:
.host = "109.50.345.14";
chattr +i /etc/varnish/default.vcl
Unlock if needed:
chattr -i /etc/varnish/default.vcl
systemctl restart varnish
Visit your website in a browser.
✔ Website should load normally
✔ No more 503 Backend fetch failed errors
curl -I http://yourdomain.com
Look for:
Via: 1.1 varnish
| Service | Port |
|---|---|
| Nginx | 80 / 443 |
| Varnish | 82 |
| Apache | 8181 / 8443 |
Ensure Apache is running on port 8181
Disable SELinux temporarily if issues occur:
setenforce 0
Check logs:
systemctl status varnish
journalctl -xe
By following this guide, you can successfully install and configure Varnish Cache on EL9 systems with CWP, even though it is not fully supported natively.
Was this article helpful?
Didn't find what you needed?
© 2026 BiswasHost, All Rights Reserved. Operated by Biswas Host LLC (USA) & Biswas Host Ltd (BD).