Blog/ How to install a Varnish module on Ubuntu 12.04

Varnish has a bunch of modules providing extra functionality that don't come with standard installation. You can find them on VMODs Directory. To install any of these modules, Varnish and the module have to be compiled from source. Recently we had to install the Cookie module to parse the cookie string and use it for caching. Here are the steps:

1) Install Varnish from source. If you don't know how to do this, click here to find out how to install varnish from source. We installed it in /home/neemehta/varnish3 directory but you could install it wherever you want. Just make sure to replace this path with your installation directory in the following commands.

2) Create Varnish Modules directory and go inside it.

mkdir /home/neemehta/Varnish-Modules; cd /home/neemehta/Varnish-Modules

3) Clone the libvmod-cookie git repository and go inside it.

git clone; cd libvmod-cookie

4) Create the configure file by running autogen script.


5) Execute the configuration script. Set VARNISHSRC to the source code directory of Varnish and VMODDIR to lib/varnish/vmods directory inside the Varnish installation.

./configure VARNISHSRC=/home/neemehta/Varnish-Cache VMODDIR=/home/neemehta/varnish3/lib/varnish/vmods

6) Execute make


7) Run make check. Make sure that there are no errors.

make check

8) Install the module.

make install

Congratulations!! The libvmod-cookie module has been installed now. You can modify the default.vcl file to use this module. Once done, restart Varnish by stopping the currently running Varnish and executing the following:

sudo /home/neemehta/varnish3/sbin/varnishd -P /var/run/ -a :80 -T localhost:6082 -f /home/neemehta/varnish3/etc/varnish/default.vcl -S /home/neemehta/varnish3/etc/varnish/secret -s malloc,1g
Ready to get started?REQUEST A QUOTE