/geoip-vmod

A GeoIp module for varnish

Primary LanguageCOtherNOASSERTION

Usage:

./configure VARNISHSRC=DIR

VARNISHSRC is the directory of the Varnish source tree for which to
compile your vmod. Both the VARNISHSRC and VARNISHSRC/include
will be added to the include search paths for your module.

Make targets:
    make - builds the vmod
    make install - installs your vmod in VMODDIR
    make check - runs the unit tests in src/tests/*.vtc

In your VCL you could then use this vmod like the following. This
sets the request header X-GeoIP to the requestor's country code.
    ,----
    | import geoip;
    |
    | sub vcl_recv {
    |     set req.http.X-Forwarded-For = client.ip;
    |     set req.http.X-GeoIP = geoip.country(req.http.X-Forwarded-For)
    | }
    `----

Instead, you can set the header with a JSON-like hash including all the
data (city, latitude, longitude).
    ,----
    | import geoip;
    |
    | sub vcl_recv {
    |     set req.http.X-Forwarded-For = client.ip;
    |     set req.http.X-GeoIP = geoip.record(req.http.X-Forwarded-For)
    | }
    `----

CREDITS:

   the idea for this varnish module and the proof of concept and the
   initial implementation are all due to David Newhall II

   Lee Doolan, the maintainer, added libtool configuration details,
   added thread safety, added SCM (git).