Giter Site home page Giter Site logo

varnish-geoip's Introduction

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

Last updated: 1/12/2011
	Cosimo Streppone <[email protected]>
	Opera Software ASA

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, city, country and latitude/longitude.
Of course this doesn't come for free. You need the city edition of Geo-IP.

The rewritten header is "X-Geo-IP".

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) If you run Debian, look here:

   http://my.opera.com/cstrep/blog/2011/11/30/how-to-start-up-varnish-with-a-custom-cc-command-on-debian

   for instructions on how to specify a custom "cc_command" in
   the Varnish init script.

5) Restart Varnish

6) ?

7) Profit !!

varnish-geoip's People

Contributors

cosimo avatar

Stargazers

Hien Phan avatar

Watchers

Hien Phan avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.