We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies from this website. If you would like to change your preferences you may do so by following the instructions here

Packaging Varnish VMODs

Varnish (the caching HTTP reverse proxy) had an extension mechanism called Varnish Modules (or VMODs) since it's version 3.0. The official listing on the homepage lists a bunch of production-ready open-source VMODs which are quite useful for a number of situations e.g.

libvmod-boltsort: sort or ignore the order of arguments in the query string, e.g. treat a request to /action?a=b&c=d the same as /action?c=d&a=b.

VMODs are typically distributed as source code on github.com and require a compile against the same version of source code the varnishd binary was build from. After a successful make the build files have to be copied into the lib/varnish/vmod directory and can be imported from there using e.g. import throttle; in your configuration files. Since this adds a little bit of complexity when deploying a Varnish configuration which relies on VMODs, we are having a closer look at what exactly is necessary to deliver a VMOD as an easy to install rpm.

Most VMODs follow the structure established by the libvmod-example (demo) project which means we can build a similar template for packaging such VMODs. We're using the fabulous fpm gem for the purpose. The basic steps are (illustrated below with the before mentioned VMODs):

Install some prerequisites (Ruby is assumed to be installed on the build machine though)

Fetch a copy of Varnish from github and pick an appropriate version (tag)

Build Varnish

Fetch a copy of the VMOD from github and pick an appropriate version (tag)

Build the VMOD

Package the VMOD artefacts using FPM

(not depicted here) Upload the package to some storage or repository

Please note that the build script does not cross-compile. In order to build an appropriate RPM you either need to run the build inside a matching virtual machine (we use Vagrant for this purpose) or integrate this into you CI environment of choice (we favor Travis Pro and Atlassian Bamboo). More on that in a later post!

Joern has been developing, debugging and designing software for many clients. At kreuzwerker he is responsible for architecture, new technologies and concepts. A computer science graduate, his professional interest is in the use of functional programming languages and the…