Permalink
Browse files

Added a default VCL file as example

  • Loading branch information...
cosimo committed Jan 28, 2010
1 parent 935ef72 commit 2fa84a7b4cfb4eee7c4a4ee1c8b3c1c584f8aa3c
Showing with 23 additions and 2 deletions.
  1. +17 −0 examples/default.vcl
  2. +6 −2 geoip.c
View
@@ -0,0 +1,17 @@
+include "/etc/varnish/geoip.vcl";
+
+backend default {
+ .host = "localhost";
+ .port = "8080";
+}
+
+sub vcl_recv {
+ C{
+ vcl_geoip_set_header(sp);
+ }C
+}
+
+sub vcl_fetch {
+ set obj.http.X-Geo-IP = req.http.X-Geo-IP;
+}
+
View
@@ -1,5 +1,9 @@
/*
* Varnish-powered Geo IP lookup
+ *
+ * Idea and GeoIP code taken from
+ * http://svn.wikia-code.com/utils/varnishhtcpd/wikia.vcl
+ *
* Cosimo, 28/01/2010
*/
@@ -60,7 +64,7 @@ static inline int geoip_lookup(vcl_string *ip, vcl_string *resolved) {
#ifdef __VCL__
/* Returns the GeoIP info as synthetic response */
-void vcl_geoip_send_synthetic(const struct session *sp) {
+void vcl_geoip_send_synthetic(const struct sess *sp) {
vcl_string hval[HEADER_MAXLEN];
vcl_string *ip = VRT_IP_string(sp, VRT_r_client_ip(sp));
if (geoip_lookup(ip, hval)) {
@@ -72,7 +76,7 @@ void vcl_geoip_send_synthetic(const struct session *sp) {
}
/* Sets "X-Geo-IP" header with the geoip resolved information */
-void vcl_geoip_set_header(const struct session *sp) {
+void vcl_geoip_set_header(const struct sess *sp) {
vcl_string hval[HEADER_MAXLEN];
vcl_string *ip = VRT_IP_string(sp, VRT_r_client_ip(sp));
if (geoip_lookup(ip, hval)) {

0 comments on commit 2fa84a7

Please sign in to comment.