Varnish

Varnish

Varnish is a web-application accelerator and caching HTTP reverse proxy designed for dynamic, high-traffic websites. On the platform, it is bundled with NGINX so HTTPS traffic can be decrypted by NGINX and then passed to Varnish for caching and further processing.

Varnish Overview

Varnish focuses primarily on HTTP acceleration and caching. Within the platform implementation, NGINX runs on port 443 as the HTTPS proxy. After incoming encrypted traffic is decrypted, NGINX forwards it to Varnish on port 80.

HTTP/3Varnish is HTTP/3-ready, with support enabled by default for the documented 5.2.x and 6.x.x stack versions. A public IP is required to bypass the Shared Load Balancer and communicate directly over HTTP/3.
CachingImproves website speed by offloading delivery of static objects and reducing backend application-server work.
Basic load balancingSupports round-robin and random redirectors, backend health checks, and related balancing features.
Statistics and analysisSupports tools such as varnishstat, varnishhist, and the live traffic analyzer varnishlog.
Threaded processingEach client connection is handled by a worker thread. Connections are queued when the worker-thread limit is reached and rejected if the overflow queue also reaches its configured limit.
System initialization: the Varnish template uses the modern systemd initialization daemon.

Varnish Load Balancer Installation

  1. Log in to the PaaS dashboard.
  2. Click New environment in the upper-left corner.
Varnish new environment
Create a new environment from the dashboard.
  1. Open the required programming-language tab and activate the Balancing section.
  2. Select Varnish from the corresponding load-balancer list.
  3. Configure the remaining topology: application servers, other nodes, cloudlet limits, and public IPs where required.
  4. Enter an environment name, for example varnish, and click Create.
Varnish environment wizard
Select Varnish in the Balancing section and configure the remaining environment topology.

The environment is created within a few minutes and Varnish is placed in front of the configured backend application servers.

Varnish environment created
The environment is ready with Varnish acting as the load balancer.

Varnish Server Configurations

The Varnish load balancer can be configured through either of these platform tools:

  • Connect directly to the Varnish server through the platform SSH Gateway.
  • Use the embedded Configuration File Manager to edit configuration files from the dashboard.
Varnish SSH access
Manage the Varnish server through the platform SSH Gateway.
Varnish configuration button
Use the embedded file manager to edit Varnish configuration files.

Link Backend Servers

Backend servers can be linked even when they belong to other environments. Add a backend definition at the beginning of:

vcl > default.vcl

Use this format:

backend server_identifier {
    .host = "server_internal_ip";
    .port = "80";
}
server_identifierAny preferred name for the linked backend server.
server_internal_ipThe internal address of the required backend server. It is available through the server’s Additionally menu.

Then, in the sub vcl_init section below the new myclust = directors.hash(); line, add:

myclust.add_backend(server_identifier, 1);
Varnish backend configuration
Add the backend definition and register the backend in the Varnish cluster configuration.

Save the changes and restart the Varnish load-balancer server to apply the updated backend configuration.

Custom Varnish Modules

Custom Varnish modules can be applied by uploading them into the vmods directory.

Varnish modules
Upload custom Varnish modules into the vmods folder.

Varnish Daemon Parameters

Initial Varnish daemon parameters are read every time the balancer starts. These values can be adjusted in:

sysconfig > varnish
Varnish daemon parameters
Adjust the initial Varnish daemon parameters in the sysconfig varnish file.

Expected Result

Varnish is deployed as an HTTP caching reverse proxy in front of the selected backend application servers. HTTPS traffic can be terminated by the bundled NGINX proxy, cached traffic is handled by Varnish, and backend, module, and daemon settings can be managed through the dashboard or SSH.

Important Notes

  • Varnish is focused on HTTP acceleration and caching rather than advanced load-balancing logic.
  • NGINX handles HTTPS traffic on port 443 and forwards decrypted requests to Varnish on port 80.
  • A public IP is required for direct HTTP/3 communication.
  • Backend servers from other environments can be linked through default.vcl.
  • Save configuration changes and restart the Varnish server when required.
  • Custom modules are uploaded to the vmods directory.
  • Startup daemon parameters are managed in sysconfig > varnish.

What’s Next?