Skip to content

Drupal 7 module updated to Varnish 6

License

Unlicense, Unknown licenses found

Licenses found

Unlicense
LICENSE
Unknown
COPYING
Notifications You must be signed in to change notification settings

fpfis/vmod-drupal7

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vmod-drupal7

SYNOPSIS

import drupal7;

DESCRIPTION

Drupal7 Varnish vmod demonstrating how to write an out-of-tree Varnish vmod.

Implements the traditional Hello World as a vmod.

FUNCTIONS

hello

Prototype
hello(STRING S)
Return value
STRING
Description
Returns "Hello, " prepended to S
Drupal7
set resp.http.hello = drupal7.hello("World");

INSTALLATION

The source tree is based on autotools to configure the building, and does also have the necessary bits in place to do functional unit tests using the varnishtest tool.

Building requires the Varnish header files and uses pkg-config to find the necessary paths.

Usage:

./autogen.sh
./configure

If you have installed Varnish to a non-standard directory, call autogen.sh and configure with PKG_CONFIG_PATH pointing to the appropriate path. For instance, when varnishd configure was called with --prefix=$PREFIX, use

export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
export ACLOCAL_PATH=${PREFIX}/share/aclocal

The module will inherit its prefix from Varnish, unless you specify a different --prefix when running the configure script for this module.

Make targets:

  • make - builds the vmod.
  • make install - installs your vmod.
  • make check - runs the unit tests in src/tests/*.vtc.
  • make distcheck - run check and prepare a tarball of the vmod.

If you build a dist tarball, you don't need any of the autotools or pkg-config. You can build the module simply by running:

./configure
make

Installation directories

By default, the vmod configure script installs the built vmod in the directory relevant to the prefix. The vmod installation directory can be overridden by passing the vmoddir variable to make install.

USAGE

In your VCL you could then use this vmod along the following lines:

import drupal7;

sub vcl_deliver {
        # This sets resp.http.hello to "Hello, World"
        set resp.http.hello = drupal7.hello("World");
}

COMMON PROBLEMS

  • configure: error: Need varnish.m4 -- see README.rst

    Check whether PKG_CONFIG_PATH and ACLOCAL_PATH were set correctly before calling autogen.sh and configure

  • Incompatibilities with different Varnish Cache versions

    Make sure you build this vmod against its correspondent Varnish Cache version. For instance, to build against Varnish Cache 4.1, this vmod must be built from branch 4.1.

START YOUR OWN VMOD

The basic steps to start a new vmod from this drupal7 are:

name=myvmod
git clone libvmod-drupal7 libvmod-$name
cd libvmod-$name
./rename-vmod-script $name

and follow the instructions output by rename-vmod-script

About

Drupal 7 module updated to Varnish 6

Resources

License

Unlicense, Unknown licenses found

Licenses found

Unlicense
LICENSE
Unknown
COPYING

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published