In data 16 marzo 2010 alle ore 17:22:53, Sebastian Cabrera
<[email protected]> ha scritto:
On a Website i want to have the posibility to do some rewriting due to
the Country he's comming from. So if someone visits the Mainpage
(domain.com) from US i want to have him visiting domain.com/us/.
Does anyone have any experiences with that? How can i do this?
Maybe you could be interested at this code,
http://github.com/cosimo/varnish-geoip/
We're *not* using it in production yet.
However, we're using a very similar one,
http://github.com/cosimo/varnish-accept-language/
And it proved very useful and stable since we
increased the default sess_workspace to 128k.
I just downloaded and installed the GeoIP Plugin from the varnish wiki
(http://varnish-cache.org/wiki/GeoipUsingInlineC), but how can i use it?
Is there any possibility to do something like
if (get_country_code(client.ip) == "US") {
set req.url = "/us/"
}
No, but you can use "C{ }C" blocks.
AFAIK the most common approach is to use HTTP headers as a sort
of "temporary storage", hence the need of upping sess_workspace.
The inline C code writes a new header, say "X-GeoIP-Country",
and then you can say:
sub vcl_recv {
...
C{
/* "sp" is the varnish session data structure */
my_c_function(sp);
}C
...
if (req.http.X-GeoIP-Country ~ "us") {
set req.url = "/us/";
}
}
Have fun :)
--
Cosimo
_______________________________________________
varnish-misc mailing list
[email protected]
http://lists.varnish-cache.org/mailman/listinfo/varnish-misc