forked from cosimo/varnish-geoip
-
-
Notifications
You must be signed in to change notification settings - Fork 0
guybedford/varnish-geoip
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Varnish Geo-IP VCL =========================== Update by Guy Bedford 14/05/2012 Reduction to GeoIP country only with direct inclusion of ready-to-use VCL USAGE:: -install GeoIP country (http://www.maxmind.com/app/c) -move geoip.vcl to /etc/varnish -edit geoip.vcl to set the correct path of the country database (wherever you download it to) -include in your default.vcl as in the example included -start varnish with the special cc options as demoed in start-varnish.sh (the important part being after the -p paramater) Last updated: 1/12/2011 Cosimo Streppone <cosimo@opera.com> 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 !!
About
Varnish VCL "plugin" that geolocates client IP addresses (requires geoip)
Resources
Stars
Watchers
Forks
Releases
No releases published
Sponsor this project
Packages 0
No packages published
Languages
- Shell 100.0%