I want to block visitors from some country, by country code, not by maintain a lot of ip ranges. I can do it using only nginx, but i've just configured varnish to frontend, and I have not found any solutions yet. I'm using centos 6.4 x64.

Thanks for any advice

  • What do you mean with "by country code"? Where would you get this information? Do you want to read the little stickers on the bumpers of the cars of your visitors? – Alexander Kosubek Oct 14 '13 at 5:53

Use some GeoIP module for Varnish. geoip-vmod for example.


If you install https://github.com/iwebhosting/varnish-geoip then you can do it in vcl_recv like this:

sub vcl_recv {
  if (req.http.X-Geo-IP ~ "IE|FR|US") {
    error 503 "Your country has been blocked.";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.