{"id":3696,"date":"2016-10-01T14:34:34","date_gmt":"2016-10-01T18:34:34","guid":{"rendered":"https:\/\/underhost.com\/blog\/?p=3696"},"modified":"2026-10-23T09:56:27","modified_gmt":"2026-10-23T13:56:27","slug":"install-varnish-centos-7","status":"publish","type":"post","link":"https:\/\/underhost.com\/blog\/install-varnish-centos-7\/","title":{"rendered":"How to Install Varnish Cache in Front of Apache (AlmaLinux, Rocky Linux and Ubuntu)"},"content":{"rendered":"<div class=\"uh-blog-hero\" style=\"margin:0 0 40px;text-align:center;padding:48px 24px;border-radius:20px;background:linear-gradient(135deg,#0D1F3C 0%,#125A8A 58%,#176EA5 100%);color:#ffffff;box-shadow:0 20px 40px -15px rgba(13,31,60,0.28);position:relative;overflow:hidden;\">\n<div style=\"display:inline-flex;align-items:center;gap:8px;padding:7px 14px;margin-bottom:16px;border:1px solid rgba(0,212,255,0.32);border-radius:999px;color:#DFF8FF;font-size:12px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;background:rgba(0,212,255,0.10);\"><i class=\"fas fa-server\" style=\"color:#00D4FF;\"><\/i> Hosting Guide<\/div>\n<h1 style=\"color:#ffffff;font-size:clamp(32px,5vw,46px);line-height:1.12;margin:0 0 14px;font-weight:800;\">How to Install Varnish Cache in Front of Apache (AlmaLinux, Rocky Linux and Ubuntu)<\/h1>\n<\/div>\n<div class=\"uh-blog-excerpt\" style=\"border-left:4px solid #00D4FF;padding:18px 20px;margin:0 0 34px;background:#F8FAFC;color:#1F2937;border-radius:0 14px 14px 0;box-shadow:0 8px 28px rgba(13,31,60,0.08);line-height:1.75;\"><strong style=\"color:#0D1F3C;\">Short answer:<\/strong> Install Varnish from your distribution&#8217;s packages (<code>dnf install varnish<\/code> or <code>apt install varnish<\/code>), move Apache to port 8080, point Varnish&#8217;s backend at <code>127.0.0.1:8080<\/code> in <code>\/etc\/varnish\/default.vcl<\/code>, and make Varnish listen on port 80. Varnish does not handle HTTPS, so put Nginx or Hitch in front of it on port 443. Test with <code>curl -I<\/code> and look for the <code>X-Varnish<\/code> and <code>Age<\/code> headers. On cPanel servers, use NGINX Manager in WHM instead.<\/div>\n<nav aria-label=\"Table of contents\" class=\"uh-toc\" style=\"background:#ffffff;border:1px solid #E5E7EB;border-radius:16px;padding:20px 22px;margin:0 0 34px;box-shadow:0 4px 12px rgba(13,31,60,0.08);\">\n<div style=\"font-size:12px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;color:#176EA5;margin-bottom:10px;\"><i class=\"fas fa-list\" style=\"color:#00D4FF;\"><\/i> In this guide<\/div>\n<ol style=\"margin:0;padding-left:20px;columns:2 260px;column-gap:28px;line-height:1.9;\">\n<li><a href=\"#what-varnish-does\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">What Varnish does<\/a><\/li>\n<li><a href=\"#a-note-on-the-name\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">A note on the name<\/a><\/li>\n<li><a href=\"#how-the-pieces-fit-together\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">How the pieces fit together<\/a><\/li>\n<li><a href=\"#requirements\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Requirements<\/a><\/li>\n<li><a href=\"#step-1-install-varnish\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Step 1: install Varnish<\/a><\/li>\n<li><a href=\"#step-2-move-apache-to-port-8080\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Step 2: move Apache to port 8080<\/a><\/li>\n<li><a href=\"#step-3-point-varnish-at-apache\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Step 3: point Varnish at Apache<\/a><\/li>\n<li><a href=\"#step-4-make-varnish-listen-on-port-80\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Step 4: make Varnish listen on port 80<\/a><\/li>\n<li><a href=\"#step-5-add-https-in-front\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Step 5: add HTTPS in front<\/a><\/li>\n<li><a href=\"#step-6-test-the-cache\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Step 6: test the cache<\/a><\/li>\n<li><a href=\"#monitor-varnish\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Monitor Varnish<\/a><\/li>\n<li><a href=\"#clear-the-cache-after-changes\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Clear the cache after changes<\/a><\/li>\n<li><a href=\"#set-how-long-pages-stay-cached\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Set how long pages stay cached<\/a><\/li>\n<li><a href=\"#troubleshooting\" style=\"color:#176EA5;text-decoration:none;font-weight:600;\">Troubleshooting<\/a><\/li>\n<\/ol>\n<\/nav>\n<div class=\"uh-post-content\" style=\"color:#1F2937;font-size:16px;line-height:1.75;\">\n<h2 id=\"what-varnish-does\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-info-circle\" style=\"color:#00D4FF;\"><\/i> What Varnish does<\/h2>\n<p style=\"margin:0 0 18px;\">Varnish Cache is a reverse proxy that keeps copies of pages in memory. The first visitor&#8217;s request goes to the web server. Later visitors get the stored copy straight from memory, without PHP or the database doing any work. For busy sites with pages that are the same for most visitors, such as blogs, news sites and catalogs, this cuts server load and speeds up response times a great deal.<\/p>\n<p style=\"margin:0 0 18px;\">Varnish is less useful for pages that are different for each visitor, such as carts, checkouts and account pages. Those must bypass the cache.<\/p>\n<h2 id=\"a-note-on-the-name\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-angle-double-right\" style=\"color:#00D4FF;\"><\/i> A note on the name<\/h2>\n<p style=\"margin:0 0 18px;\">In 2025 the open-source Varnish Cache project was renamed <strong>Vinyl Cache<\/strong>, while Varnish Software continues to publish Varnish Cache. Most Linux distributions still ship the package as <code>varnish<\/code>, and the commands and configuration in this guide are the same.<\/p>\n<h2 id=\"how-the-pieces-fit-together\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-info-circle\" style=\"color:#00D4FF;\"><\/i> How the pieces fit together<\/h2>\n<div style=\"overflow-x:auto;margin:26px 0;border:1px solid #E5E7EB;border-radius:14px;-webkit-overflow-scrolling:touch;\">\n<table style=\"width:100%;border-collapse:collapse;background:#ffffff;color:#1F2937;font-size:15px;line-height:1.55;margin:0;min-width:600px;\">\n<thead>\n<tr style=\"background:#0D1F3C;color:#fff;\">\n<th style=\"padding:14px;text-align:left;\">Port<\/th>\n<th style=\"padding:14px;text-align:left;\">Service<\/th>\n<th style=\"padding:14px;text-align:left;\">Job<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">443<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Nginx (or Hitch)<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Handles HTTPS, then passes the request to Varnish<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">80<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Varnish<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Answers from the cache, or asks Apache<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">8080<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Apache with PHP<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Builds the page when it is not in the cache<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"margin:0 0 18px;\">Apache only listens on <code>127.0.0.1<\/code>, so visitors cannot reach it directly.<\/p>\n<h2 id=\"requirements\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-clipboard-check\" style=\"color:#00D4FF;\"><\/i> Requirements<\/h2>\n<ul style=\"list-style:none;padding-left:0;\">\n<li style=\"margin:0 0 8px;\">\u2713 A VPS or dedicated server with root access, running a supported release such as AlmaLinux 9, Rocky Linux 9 or Ubuntu 24.04.<\/li>\n<li style=\"margin:0 0 8px;\">\u2713 A working Apache and PHP site.<\/li>\n<li style=\"margin:0 0 8px;\">\u2713 Enough memory for the cache. Start with 256 MB to 1 GB for Varnish, depending on the size of your site.<\/li>\n<li style=\"margin:0 0 8px;\">\u2713 A plan for HTTPS, because Varnish does not handle TLS itself.<\/li>\n<\/ul>\n<div style=\"background:#FFF7ED;border:1px solid #FDBA74;border-radius:16px;padding:20px 22px;margin:24px 0;\">\n<h3 style=\"margin:0 0 10px;color:#9A3412;font-size:20px;\"><i class=\"fas fa-exclamation-triangle\" style=\"color:#F97316;\"><\/i> On cPanel servers:<\/h3>\n<p style=\"margin:0;color:#7C2D12;line-height:1.7;\">cPanel manages Apache&#8217;s ports and configuration, and Varnish is not a supported add-on. Use <strong>WHM &gt; Software &gt; NGINX Manager<\/strong>, which puts NGINX with caching in front of Apache, or use LiteSpeed. Do not change Apache&#8217;s ports by hand on a cPanel server.<\/p>\n<\/div>\n<h2 id=\"step-1-install-varnish\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-terminal\" style=\"color:#00D4FF;\"><\/i> Step 1: install Varnish<\/h2>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code># AlmaLinux, Rocky Linux\ndnf install -y varnish\n\n# Ubuntu and Debian\napt update &amp;&amp; apt install -y varnish\n\nvarnishd -V<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">Distribution packages are older than the newest release but get security updates. If you need a newer version, use the official repositories listed on the project&#8217;s website.<\/p>\n<h2 id=\"step-2-move-apache-to-port-8080\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-terminal\" style=\"color:#00D4FF;\"><\/i> Step 2: move Apache to port 8080<\/h2>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code># AlmaLinux and Rocky Linux: \/etc\/httpd\/conf\/httpd.conf\nListen 127.0.0.1:8080\n\n# Ubuntu and Debian: \/etc\/apache2\/ports.conf\nListen 127.0.0.1:8080<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">Change <code>&lt;VirtualHost *:80&gt;<\/code> to <code>&lt;VirtualHost *:8080&gt;<\/code> in each site&#8217;s configuration, then restart Apache:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>systemctl restart httpd      # AlmaLinux, Rocky Linux\nsystemctl restart apache2    # Ubuntu, Debian<\/code><\/pre>\n<h2 id=\"step-3-point-varnish-at-apache\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-terminal\" style=\"color:#00D4FF;\"><\/i> Step 3: point Varnish at Apache<\/h2>\n<p style=\"margin:0 0 18px;\">Edit <code>\/etc\/varnish\/default.vcl<\/code>:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>vcl 4.1;\n\nbackend default {\n    .host = \"127.0.0.1\";\n    .port = \"8080\";\n}\n\nsub vcl_recv {\n    # Never cache admin, login, cart and checkout pages\n    if (req.url ~ \"^\/(wp-admin|wp-login\\.php|cart|checkout|my-account)\") {\n        return (pass);\n    }\n    # Never cache logged-in users\n    if (req.http.Cookie ~ \"wordpress_logged_in|woocommerce_items_in_cart\") {\n        return (pass);\n    }\n}<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">Adjust the paths and cookie names to your application. The example covers WordPress and WooCommerce.<\/p>\n<h2 id=\"step-4-make-varnish-listen-on-port-80\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-terminal\" style=\"color:#00D4FF;\"><\/i> Step 4: make Varnish listen on port 80<\/h2>\n<p style=\"margin:0 0 18px;\">The listening port is set in the systemd service, and the packaged command differs between distributions. First look at it:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>systemctl cat varnish | grep ExecStart<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">Then create an override, so package updates do not undo your change:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>systemctl edit varnish<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">Add an empty <code>ExecStart=<\/code> line, which clears the original, then paste the original ExecStart line and change only <code>-a :6081<\/code> to <code>-a :80<\/code>. Keep every other option, such as <code>-F<\/code> on Ubuntu. On AlmaLinux 9 the result looks like this:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>[Service]\nExecStart=\nExecStart=\/usr\/sbin\/varnishd -a :80 -f \/etc\/varnish\/default.vcl -s malloc,512m<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">The <code>-s malloc,512m<\/code> option sets the cache size. Then start Varnish:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>systemctl daemon-reload\nsystemctl enable --now varnish\nss -tlnp | grep -E \":80 |:8080 \"<\/code><\/pre>\n<h2 id=\"step-5-add-https-in-front\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-terminal\" style=\"color:#00D4FF;\"><\/i> Step 5: add HTTPS in front<\/h2>\n<p style=\"margin:0 0 18px;\">Install Nginx, give it your certificate, and pass requests to Varnish on port 80:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>server {\n    listen 443 ssl;\n    server_name example.com www.example.com;\n    ssl_certificate     \/etc\/letsencrypt\/live\/example.com\/fullchain.pem;\n    ssl_certificate_key \/etc\/letsencrypt\/live\/example.com\/privkey.pem;\n\n    location \/ {\n        proxy_pass http:\/\/127.0.0.1:80;\n        proxy_set_header Host $host;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto https;\n    }\n}<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">Our <a href=\"https:\/\/underhost.com\/blog\/free-ssl-install-lets-encrypt-cpanel-centos-servers\/\">free SSL guide<\/a> shows how to get the certificate. Make sure your application trusts the X-Forwarded-Proto header, or it may loop between HTTP and HTTPS.<\/p>\n<h2 id=\"step-6-test-the-cache\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-tachometer-alt\" style=\"color:#00D4FF;\"><\/i> Step 6: test the cache<\/h2>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>curl -sI https:\/\/example.com\/ | grep -iE \"x-varnish|age|via\"\ncurl -sI https:\/\/example.com\/ | grep -iE \"x-varnish|age|via\"   # run twice<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">On the second request, <code>Age<\/code> should be above 0, and <code>X-Varnish<\/code> shows two numbers. That means the page came from the cache.<\/p>\n<h2 id=\"monitor-varnish\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-angle-double-right\" style=\"color:#00D4FF;\"><\/i> Monitor Varnish<\/h2>\n<div style=\"overflow-x:auto;margin:26px 0;border:1px solid #E5E7EB;border-radius:14px;-webkit-overflow-scrolling:touch;\">\n<table style=\"width:100%;border-collapse:collapse;background:#ffffff;color:#1F2937;font-size:15px;line-height:1.55;margin:0;\">\n<thead>\n<tr style=\"background:#0D1F3C;color:#fff;\">\n<th style=\"padding:14px;text-align:left;\">Tool<\/th>\n<th style=\"padding:14px;text-align:left;\">What it shows<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\"><code>varnishstat<\/code><\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Cache hits and misses, memory use and connection counts<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\"><code>varnishlog<\/code><\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Every request in detail, useful for finding why a page is not cached<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\"><code>varnishtop<\/code><\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">The most frequent log entries, such as the busiest URLs<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\"><code>varnishhist<\/code><\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">A live chart of response times, split by hits and misses<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\"><code>varnishncsa<\/code><\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">An access log in the usual Apache format<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2 id=\"clear-the-cache-after-changes\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-tachometer-alt\" style=\"color:#00D4FF;\"><\/i> Clear the cache after changes<\/h2>\n<p style=\"margin:0 0 18px;\">After you publish content, old pages may stay in the cache until they expire. Ban everything, or install a purge plugin for your CMS, such as Proxy Cache Purge for WordPress:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>varnishadm \"ban req.url ~ \/\"<\/code><\/pre>\n<h2 id=\"set-how-long-pages-stay-cached\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-tachometer-alt\" style=\"color:#00D4FF;\"><\/i> Set how long pages stay cached<\/h2>\n<p style=\"margin:0 0 18px;\">Varnish follows the <code>Cache-Control<\/code> headers your application sends. If the application sends none, Varnish uses its default lifetime of two minutes. You can set your own lifetime, and a grace period that lets Varnish serve a slightly old page while it fetches a fresh one, or while Apache is down:<\/p>\n<pre style=\"background:#0D1F3C;color:#EAF6FF;padding:18px 20px;border-radius:14px;overflow-x:auto;line-height:1.7;font-size:15px;\"><code>sub vcl_backend_response {\n    if (beresp.ttl &lt;= 0s) {\n        set beresp.ttl = 5m;     # cache for 5 minutes when the app sets nothing\n    }\n    set beresp.grace = 1h;       # serve stale pages for up to 1 hour if needed\n}<\/code><\/pre>\n<p style=\"margin:0 0 18px;\">Reload Varnish after each VCL change with <code>systemctl reload varnish<\/code>. A reload keeps the cache.<\/p>\n<h2 id=\"troubleshooting\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-exclamation-triangle\" style=\"color:#00D4FF;\"><\/i> Troubleshooting<\/h2>\n<div style=\"overflow-x:auto;margin:26px 0;border:1px solid #E5E7EB;border-radius:14px;-webkit-overflow-scrolling:touch;\">\n<table style=\"width:100%;border-collapse:collapse;background:#ffffff;color:#1F2937;font-size:15px;line-height:1.55;margin:0;min-width:600px;\">\n<thead>\n<tr style=\"background:#0D1F3C;color:#fff;\">\n<th style=\"padding:14px;text-align:left;\">Problem<\/th>\n<th style=\"padding:14px;text-align:left;\">Likely cause<\/th>\n<th style=\"padding:14px;text-align:left;\">Fix<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Varnish will not start: address already in use<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Apache or Nginx still listens on port 80<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Check with <code>ss -tlnp | grep :80<\/code> and move that service to another port.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">503 Backend fetch failed<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Apache is stopped or not on 127.0.0.1:8080<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Start Apache and check the backend address in default.vcl.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Redirect loop on HTTPS<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">The application does not know the visitor used HTTPS<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Pass X-Forwarded-Proto from Nginx and make the application trust it.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Every request is a miss<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Cookies or no-cache headers on every page<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Use varnishlog to find the cookie or header, then remove or allow it in the VCL.<\/td>\n<\/tr>\n<tr>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Logged-in users see other people&#8217;s pages<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Personal pages were cached<\/td>\n<td style=\"padding:14px;border-top:1px solid #E5E7EB;vertical-align:top;\">Pass all requests with login or cart cookies, as in Step 3, and clear the cache.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div aria-hidden=\"true\" class=\"uh-section-divider\" style=\"width:min(100% - 32px, 1080px);margin:44px auto;display:grid;grid-template-columns:1fr 32px 1fr;align-items:center;gap:18px;pointer-events:none;\"><span style=\"height:1px;background:linear-gradient(90deg,transparent,rgba(0,212,255,0.40),rgba(23,110,165,0.24),transparent);\"><\/span><img alt=\"\" decoding=\"async\" height=\"32\" loading=\"lazy\" src=\"https:\/\/cdn.underhost.com\/android-chrome-192x192.webp\" style=\"width:32px;height:32px;display:block;border-radius:8px;filter:drop-shadow(0 0 14px rgba(0,212,255,0.30));\" width=\"32\"\/><span style=\"height:1px;background:linear-gradient(90deg,transparent,rgba(23,110,165,0.24),rgba(0,212,255,0.40),transparent);\"><\/span><\/div>\n<\/div>\n<div class=\"uh-blog-cta\" style=\"background:linear-gradient(135deg,#0D1F3C 0%,#125A8A 58%,#176EA5 100%);color:#ffffff;padding:36px 24px;border-radius:20px;text-align:center;margin:44px 0;box-shadow:0 20px 40px -15px rgba(13,31,60,0.32);\">\n<h2 style=\"margin:0 0 12px;font-size:28px;line-height:1.25;color:#ffffff;\">Need help with this?<\/h2>\n<p style=\"font-size:17px;margin:0 auto 22px;color:#EAF6FF;max-width:720px;line-height:1.7;\">Need a cache layer set up and tuned for your site? Run it on a Cloud VPS, or let our team configure it for you.<\/p>\n<p><a href=\"https:\/\/underhost.com\/cloud-vps.php\" style=\"background:linear-gradient(90deg,#00D4FF,#0077FF);color:#ffffff;padding:13px 28px;border-radius:10px;text-decoration:none;font-weight:800;display:inline-block;margin:8px;\">See Cloud VPS plans<\/a><a href=\"https:\/\/customerpanel.ca\/client\/\" style=\"background:transparent;color:#ffffff;padding:12px 28px;border-radius:10px;text-decoration:none;font-weight:800;display:inline-block;margin:8px;border:1px solid rgba(255,255,255,0.32);\">Contact @CustomerPanel<\/a><\/div>\n<div class=\"uh-faq-section\" id=\"faq\" style=\"margin:34px 0;scroll-margin-top:90px;\">\n<h2 style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:0 0 18px;border-bottom:2px solid rgba(0,212,255,0.22);padding-bottom:10px;\">Frequently asked questions<\/h2>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">Does Varnish support HTTPS?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">Not by itself. Put Nginx, Hitch or another TLS proxy in front of Varnish to handle HTTPS.<\/p>\n<\/div>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">Can I use Varnish on a cPanel server?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">It is not a supported add-on. Use NGINX Manager in WHM, or LiteSpeed, for caching on cPanel servers.<\/p>\n<\/div>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">Why are my pages not cached?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">Usually because of cookies or Cache-Control headers from the application. Use varnishlog to see why each request was passed.<\/p>\n<\/div>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">Is Varnish still maintained?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">Yes. The open-source project continues under the name Vinyl Cache, and Varnish Software publishes Varnish Cache. Distribution packages still use the varnish name.<\/p>\n<\/div>\n<div style=\"margin-top:18px;background:#F8FAFC;padding:18px 20px;border-radius:14px;border:1px solid rgba(23,110,165,0.14);\">\n<h3 style=\"color:#0D1F3C;margin:0 0 8px;font-size:19px;\">Can I still follow CentOS 7 steps?<\/h3>\n<p style=\"margin:0;color:#1F2937;line-height:1.7;\">CentOS 7 reached end of life in June 2024. Use a supported system such as AlmaLinux 9 or Ubuntu 24.04.<\/p>\n<\/div>\n<\/div>\n<p><!-- uh-related-start --><\/p>\n<div style=\"background:#F4F8FC;border:1px solid #DCE7F3;border-radius:14px;padding:18px 22px;margin:32px 0 8px;\">\n<h2 style=\"margin:0 0 12px;font-size:22px;\">Related guides<\/h2>\n<ul style=\"margin:0;padding-left:20px;\">\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/how-to-install-rkhunter-on-linux-rootkit-hunter\/\">How to Install RKHunter on Linux (RootKit Hunter) in RHEL, CentOS and Fedora<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/install-ffmpeg-on-linux\/\">Install FFmpeg on AlmaLinux, Debian, CentOS, and Ubuntu (Updated Guide)<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/centos-7-cloudlinux-7-eol-what-underhost-customers-need-to-know-before-july-1-2025\/\">CentOS 7 &amp; CloudLinux 7 EOL: What UnderHost Customers Need to Know Before July 1, 2025<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/install-gmp-cpanel-centos-servers\/\">How to Install GMP on a cPanel Server (EasyApache 4)<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/underhost.com\/blog\/install-clamav-in-centos-with-cpanel\/\">Updated MARCH 2025: How to Install and Configure ClamAV Antivirus on a VPS or Dedicated Server<\/a><\/li>\n<\/ul>\n<\/div>\n<p><!-- uh-related-end --><br \/>\n<script type=\"application\/ld+json\">{\"@context\": \"https:\/\/schema.org\", \"@type\": \"FAQPage\", \"mainEntity\": [{\"@type\": \"Question\", \"name\": \"Does Varnish support HTTPS?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Not by itself. Put Nginx, Hitch or another TLS proxy in front of Varnish to handle HTTPS.\"}}, {\"@type\": \"Question\", \"name\": \"Can I use Varnish on a cPanel server?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"It is not a supported add-on. Use NGINX Manager in WHM, or LiteSpeed, for caching on cPanel servers.\"}}, {\"@type\": \"Question\", \"name\": \"Why are my pages not cached?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Usually because of cookies or Cache-Control headers from the application. Use varnishlog to see why each request was passed.\"}}, {\"@type\": \"Question\", \"name\": \"Is Varnish still maintained?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"Yes. The open-source project continues under the name Vinyl Cache, and Varnish Software publishes Varnish Cache. Distribution packages still use the varnish name.\"}}, {\"@type\": \"Question\", \"name\": \"Can I still follow CentOS 7 steps?\", \"acceptedAnswer\": {\"@type\": \"Answer\", \"text\": \"CentOS 7 reached end of life in June 2024. Use a supported system such as AlmaLinux 9 or Ubuntu 24.04.\"}}]}<\/script><\/p>\n<h2 id=\"sources\" style=\"color:#0D1F3C;font-size:28px;line-height:1.25;margin:34px 0 14px;scroll-margin-top:90px;\"><i class=\"fas fa-book\" style=\"color:#00D4FF;\"><\/i> Sources<\/h2>\n<ul style=\"margin:0 0 24px;padding-left:22px;\">\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/varnish-cache.org\/docs\/\">Varnish Cache documentation<\/a><\/li>\n<li style=\"margin:0 0 8px;\"><a href=\"https:\/\/docs.cpanel.net\/whm\/software\/nginx-manager\/\">cPanel documentation: NGINX Manager<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Install Varnish from your distribution&#8217;s packages (dnf install varnish or apt install varnish), move Apache to port 8080, point Varnish&#8217;s backend at 127.0.0.1:8080 in \/etc\/varnish\/default.vcl, and make Varnish listen on port 80. Varnish does not handle HTTPS, so put Nginx or Hitch in front of it on port 443. Test with curl -I and look for the X-Varnish and Age headers. On cPanel servers, use NGINX Manager in WHM instead.<\/p>\n","protected":false},"author":1,"featured_media":3665,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[81,25],"tags":[111,112,120,115,124,114],"class_list":["post-3696","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hosting-guides","category-linux","tag-tag-almalinux","tag-tag-centos","tag-tag-cloud-vps","tag-tag-linux-server","tag-tag-ssl","tag-tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/3696","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/comments?post=3696"}],"version-history":[{"count":11,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/3696\/revisions"}],"predecessor-version":[{"id":7022,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/3696\/revisions\/7022"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/media\/3665"}],"wp:attachment":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/media?parent=3696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/categories?post=3696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/tags?post=3696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}