This article is intended for Linux server administrators who want to install or remove Varnish Cache. If your server is hosted with and managed by Maxer, please contact our support team and we can do this for you. Do not attempt these steps if you are unsure.
Note for cPanel servers:
cPanel now includes NGINX caching support directly in WHM. If you want caching in front of Apache, we recommend using the built-in NGINX option instead of installing Varnish manually. More details: WHM » Home » Software » NGINX Manager.
What is Varnish Cache?
Varnish Cache is an advanced, open-source web application accelerator (reverse proxy) that can significantly improve website performance by caching dynamic content in memory. It is often used in front of Apache or NGINX to handle high traffic loads.
Step 1: Install Varnish Cache on a non-cPanel server
On RHEL/AlmaLinux/Rocky (systemd-based):
On Debian/Ubuntu:
Replace varnish70
with the appropriate LTS or stable release. See the official installation guide for details.
Step 2: Configure Varnish
-
By default, Varnish listens on port 6081 and expects the backend web server on port 8080.
-
Update your web server (Apache/Nginx) to listen on 8080 instead of 80.
-
Configure
/etc/varnish/default.vcl
to point to your backend:
-
Update
/etc/systemd/system/multi-user.target.wants/varnish.service
(or override withsystemctl edit varnish
) to listen on port 80:
-
Reload and enable Varnish:
Step 3: Remove Varnish Cache
To uninstall Varnish and restore your web server:
-
RHEL/AlmaLinux/Rocky:
-
Debian/Ubuntu:
Then reconfigure your web server (Apache/Nginx) to listen directly on port 80 again.
Notes & Caveats
-
cPanel servers: Instead of Varnish, use WHM’s NGINX Manager for a fully supported caching solution.
-
SSL/TLS support: Varnish does not handle SSL termination natively. You must place it behind a TLS-terminating proxy (like NGINX, Hitch, or HAProxy) if you want to use HTTPS.
-
Compatibility: Varnish requires careful integration with applications such as WordPress, Magento, or Drupal. Additional VCL rules are needed to prevent caching of admin sessions and dynamic content.
✅ With these steps you can safely install or remove Varnish Cache on your VPS or dedicated server. For cPanel servers, we recommend using the built-in NGINX support instead.
Updated by SP on 02/10/2025