Network Topology

Simplified Varnish and Joomla

I am NOT going to impose a 7-server configuration on you. Varnish and Joomla setup can be even further simplified to just 2 servers. In this way, I can more easily convey necessary configurations and required software. I'm going to show the Ubuntu 24.04 version of this software stack. Your environment may be slightly different (in process or package name) if you're using something other than Ubuntu. You'll have to rely on your own knowledge to set up the server OS, I'm only dealing with the aspects directly related to Varnish and Joomla!

Everyone runs SSL these days, so I feel it needs to be mentioned that the certificate is installed on the load balancer, and all communication between the load balancer and Joomla or Varnish and Joomla is on port 80. The load balancer handles the encrypted traffic with the public.  Joomla is configured to use the "behind a load balancer" setting in global configuration.

To make the config files more clear, I'm giving each server an entry in /etc/hosts.  This way I can refer to meaningful names like varnish and liveserver instead of IP addresses.  You could easily use IP addresses if you wanted.

/etc/hosts

127.0.0.1    varnish
192.168.1.2 liveserver

Load Balancer + Varnish

This could be 2 separate servers, but for the purposes of this howto - we can squeeze them into one without any issues. This is the required package list (using Ubuntu package names):

  • varnish
  • nginx
  • libnginx-mod-http-headers-more-filter

Yup, that's it.  Configs will be detailed later.

Linux NGINX MySQL PHP

As with the load balancer server, this could be many different servers, and if you wanted to use Apache instead of NGINX, you could do that - but you'd lose some of the load balancer magic..no big deal.  Plenty of guides exist to help you configure the basic stack.

What is / why NGINX?  I prefer NGINX (pronounced Engine-X) to Apache.  I made the switch years ago, and found that it's faster and easier to configure and maintain.

Here's the required package list (again, using Ubuntu package names):

  • nginx
  • mariadb-server
  • php-fpm
  • php-mysqlnd
  • php-redis
  • php-json
  • php-simplexml
  • php-dom
  • php-zip
  • php-gd
  • php-intl

This is a pretty standard installation for Joomla on LNMP stack.

Some Basic Rules

Before we get started, some basic rules about setting up this Varnish and Joomla site tech stack.  You'll need to be very careful about forms.  If a form resides on a cached page, it's not going to work because the cached CSRF token won't be valid anymore.  That means no login modules, at least on pages that can be cached.

Any page that submits data or displays any kind of dynamic result needs to be non-cached.  Search results pages, user profiles, contact forms... It's a pain in the ass sometimes, but your site will be fast.

Next, we'll start with configuration on the load balancer.