-
Notifications
You must be signed in to change notification settings - Fork 18
Home
Federico G. Schwindt edited this page Apr 13, 2017
·
27 revisions
Welcome to the libvmod-geoip2 wiki!
Please note you need to supply the full path for the mmdb file, e.g. /var/db/maxmind/GeoLite2-Country.mmdb
.
import geoip2;
sub vcl_init {
new country = geoip2.geoip2("GeoLite2-Country.mmdb");
}
sub vcl_recv {
set req.http.X-Country-Code = country.lookup("country/iso_code", client.ip);
}
import geoip2;
sub vcl_init {
new country = geoip2.geoip2("GeoLite2-Country.mmdb");
}
sub vcl_recv {
set req.http.X-Country-Code = country.lookup("country/iso_code",
std.ip(regsub(req.http.X-Forwarded-For, "^(\d+\.\d+\.\d+\.\d+).*", "\1"),
client.ip));
}