Permalink
Browse files

Added proper README, was copied from the accept-language one

  • Loading branch information...
1 parent 2fa84a7 commit ed5805d9c7a7815b142950d208467296e198cd80 @cosimo committed Feb 10, 2010
Showing with 18 additions and 35 deletions.
  1. +18 −35 README
View
53 README
@@ -1,13 +1,13 @@
-Varnish Accept-Language VCL
+Varnish Geo-IP VCL
===========================
-Last updated: 22/01/2010
+Last updated: 10/02/2010
Cosimo Streppone <cosimo@opera.com>
Opera Software ASA
Here you will find a VCL config file for Varnish (http://varnish-cache.org)
-This VCL allows you to normalize and filter all the incoming requests
-Accept-Language headers and reduce them to just the languages your site supports.
+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.
@@ -16,19 +16,11 @@ We are using it in production, but we _don't_ know what we're doing :).
Why would you want this?
------------------------
-Your site supports English and Japanese languages.
-Your client browsers will send every possible Accept-Language header on Earth.
-If you enable "Vary: Accept-Language" on Varnish or on your backends,
-the cache hit ratio will rapidly drop, because of the huge variations
-in Accept-Language contents.
+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.
-With this VCL, the Accept-Language header will be "rewritten" to just
-"en" or "ja", depending on your client settings. If no match occurs,
-you can select a default language.
-
-The rewritten header is "X-Varnish-Accept-Language".
-You can choose to put this header back in "Accept-Language" if you wish.
-In this way, the normalization will be completely transparent.
+The rewritten header is "X-Geo-IP".
Requirements
------------
@@ -39,33 +31,24 @@ Requirements
Instructions
-------------
-1) Configure the list of languages your site supports
- and the default fallback in the Makefile, *NOT* in the C code.
-
-2) Run 'make && make test'
+1) Run 'make && make test'
You should see "All tests successful" at the end of the execution
-3) Install the generated accept-language.vcl in /etc/varnish/
+2) Install the generated geoip.vcl in /etc/varnish/
-4) At the top of your main VCL file, add the following line:
+3) At the top of your main VCL file, add the following line:
- include "/etc/varnish/accept-language.vcl"
+ include "/etc/varnish/geoip.vcl"
and then in your vcl_recv() add:
- vcl_rewrite_accept_language();
-
- This will parse Accept-Language and insert the final language into the
- "X-Varnish-Accept-Language" header (req.http.X-Varnish-Accept-Language).
-
- or optionally specifying a custom header name. You need the length of
- the string in octal before it, and a colon (":") after. Example:
-
- vcl_rewrite_accept_language("\007X-Lang:");
+ C{
+ vcl_geoip_set_header(sp);
+ }C
-6) Restart Varnish
+4) Restart Varnish
-7) Cross your fingers
+5) Cross your fingers
-8) Profit !!
+6) Profit !!

0 comments on commit ed5805d

Please sign in to comment.