Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Varnish VCL "plugin" that geolocates client IP addresses (requires geoip)
Perl C VCL
branch: master

This branch is 2 commits ahead, 13 commits behind cosimo:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
t
.gitignore
Makefile
README
gen_vcl.pl
geoip.c

README

Varnish Geo-IP VCL
===========================

Last updated: 28/03/2011
	Aaron Brady <bradya@gmail.com>
	Interactive Web Solutions Ltd

Here you will find a VCL config file for Varnish (http://varnish-cache.org)
This VCL will transparently add a HTTP request header with Geo-IP information
depending on the client IP address that made the request.

*** WARNING ***
This VCL consists of C code. Your Varnish might explode. YMMV.
Don't use it in production if you don't know what you're doing.
We are using it in production, but we _don't_ know what we're doing :).

Why would you want this?
------------------------
So your backend application can just read a HTTP header and figure out
where the client comes from.

The rewritten header is "X-Geo-IP", and contains the ISO country code.

Requirements
------------

- gcc, make
- a recent perl, with `prove'

Instructions
-------------

1) Run 'make && make test'
   You should see "All tests successful" at the end of the execution

2) Install the generated geoip.vcl in /etc/varnish/

3) At the top of your main VCL file, add the following line:

     include "/etc/varnish/geoip.vcl"

   and then in your vcl_recv() add:

     C{
     vcl_geoip_set_header(sp);
     }C

4) Restart Varnish

5) Cross your fingers

6) Profit !!

Something went wrong with that request. Please try again.