Server Setup

How to install vmod-xcounter for Varnish 6.0 LTS

by , , revisited on

We have by far the largest RPM repository with dynamic stable NGINX modules and VMODs for Varnish 4.1 and 6.0 LTS. If you want to install NGINX, Varnish, and lots of useful modules for them, this is your one-stop repository to get all performance-related software.
You have to maintain an active subscription in order to be able to use the repository!

About vmod-xcounter

Varnish 6.0.x branch is officially the LTS version. Many useful Varnish 6 modules (VMODs) are available for installation via our RPM repository.

vmod-xcounter is the new VMOD by Shohei Tanaka. It allows to create and use custom counters.

Install vmod-xcounter in CentOS/RHEL 7 for Varnish 6.0 LTS

The first step is enabling RPM repository with Varnish VMODs. This is a no-brainer with:

yum -y install
yum -y install yum-utils
yum-config-manager --enable getpagespeed-extras-varnish60

If you have not installed Varnish already, do so now:

yum install varnish

And to get the vmod-xcounter installed, run:

yum install vmod-xcounter

Use vmod-xcounter

Load the VMOD by placing the following at the top of your main .vcl file:

import xcounter;

Now you can create counters with:

sub vcl_init {
  new example_com = xcounter.vsc();

You can increment / otherwise adjust and work with counters virtually anywhere in VCL, e.g. to count visits to domain:

sub vcl_recv {
  if( == ""){

You can then run varnishstat -f XCNT.* in order to view the counter. More documentation is available on the project’s homepage.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.