Search
Varnish Enterprise

Introduction Installation Upgrading Troubleshooting Changelog Changelog for 6.0.x Changes (Varnish Cache 4.1) Changes (Varnish Cache Plus 4.1) Known Issues Features Backend SSL/TLS Client SSL/TLS termination Cluster In-Process TLS MSE 4 Basic Configuration / Getting Started Configuration Persisted caching Categories Configuration Reference MSE 3.0 Settings mkfs.mse Memory Governor MSE 2.0 NUMA Parallel ESI Backend health counter HTTP/2 Support JSON Logging TCP Only Probes Timeouts Transit Buffer Varnish scoreboard VMODs Accept Accounting ACL (aclplus) ActiveDNS Akamai Connector AWS VCL Body Access & Transformation (xbody) Brotli Cookie Plus (cookieplus) DeviceAtlas DeviceAtlas3 Digest Dynamic backends (goto) Edgestash File Format Geolocation (geoip/mmdb) Header Manipulation (headerplus) HTTP communication (http) Image JSON parsing (json) JWT Key value storage (kvstore) Least connections director (leastconn) Module to control the built-in HTTP2 transport (h2) MSE control (mse) MSE4 control (mse4) Probe Proxy ProxyV2 TLV Attribute Extraction (proxy) Pseudo Random Number Generator Purge (purge/softpurge) Real-time Status (rtstatus) Reverse DNS (resolver) Rewrite S3 VMOD Session Slicer SQLite3 Stale Standard (std) Stat (Prometheus) Strings (str) Synthetic backends (synthbackend) Tag-based invalidation (Ykey/Xkey) TCP configuration (tcp) TLS Total Encryption (crypto) Unified director object (udo) Uniform Resource Identifier (uri) Unix Socket Utilities (unix) URL Plus (urlplus) Utils Vsthrottle

Client SSL/TLS termination

Description

The SSL/TLS addon in Varnish Enterprise is a complete setup for doing SSL/TLS (https) termination in front of Varnish Enterprise.

Varnish Enterprise SSL/TLS addon consists of a supported helper process (called “hitch”) that does SSL/TLS termination, and PROXY protocol support between the helper process and Varnish Enterprise.

Installation

The SSL/TLS addon can be installed with:

yum install varnish-plus-addon-ssl        # redhat systems

or

apt-get install varnish-plus-addon-ssl    # ubuntu based systems

This will download and install the addon from the Varnish Enterprise repositories.

Configuration


hitch-ports.png
Default hitch/Varnish port configuration

The SSL/TLS terminator, named hitch is already configured (versions >=1.4.5) to listen on all interfaces on port 443 in /etc/hitch/hitch.conf, and Varnish Enterprise is also packaged (>= 4.1.6) to listen on localhost:8443 that hitch uses as a backend.

The only configuration action needed is configuring the certificates, this is done in /etc/hitch/hitch.conf by editing the pem-file entry:

pem-file = "/etc/hitch/testcert.pem"

You can change this to point to your own certificate, and if you have more than one, simply add one pem-file statement per certificate.

Alternatively, to test your setup, you can generate a certificate using:

/etc/pki/tls/certs/make-dummy-cert /etc/hitch/testcert.pem

You can then persist and start the SSL/TLS helper process.

# persist
systemctl enable hitch        # on systemd machines
update-rc.d hitch defaults    # on Ubuntu Trusty
chkconfig hitch on            # on EL6

# start
service hitch start

Changing ports

Frontend

As explained, hitch will try to listen on port 443on all interfaces, as defined in /etc/hitch/hitch.conf:

frontend = {
    host = "*"
    port = "443"
}

Backend

The backend is specified as “[HOST]:port” for IPv4/IPv6 endpoints. By default hitch will find its backend at 127.0.0.1:8443 using the PROXY protocol. This is configured by the following lines:

backend = "[127.0.0.1]:8443"
write-proxy-v2 = on

Or it can be specified as a path to a UNIX domain socket(UDS):

backend = "/var/run/varnish.sock"

This configuration above must match the default configuration of Varnish Enterprise to listen on the same port, expecting the PROXY protocol:

For IPv4/IPv6 endpoints:

varnishd [...] -a 127.0.0.1:8443,PROXY

with UDS, the mode of the socket must be specified as well:

-a uds=/var/run/varnish.sock,proxy,user=varnish,group=varnish,mode=666

The -a argument can be specified multiple times in order to make varnish listen to multiple ports. This is useful when support for both http and https is needed. The following configuration will make varnish listen for HTTP on port 80 and PROXY on port 8443:

varnishd [...] -a :80 -a 127.0.0.1:8443,PROXY

Checking a request is secure

VCL code:

import std;
sub vcl_recv {
	# on PROXY connections the server.ip is the IP the client connected to.
	# (typically the DNS-visible SSL/TLS virtual IP)
	std.log("Client connected to " + server.ip);
	if (std.port(server.ip) == 443) {
		# client.ip for PROXY requests is set to the real client IP, not the
		# SSL/TLS terminating proxy.
		std.log("Real client connecting over SSL/TLS from " + client.ip);
	}
}

Availability

SSL/TLS addon was added to Varnish Enterprise starting from Varnish Enterprise 4.0.3r2.


®Varnish Software, Wallingatan 12, 111 60 Stockholm, Organization nr. 556805-6203