Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Hi Ben, This geoip is already in a separate file (GeoIP.dat) and country blocking is working correctly. The include is already a part of the nginx.conf file. I am looking for a way to add whitelisted IPs to this functionality but I do not know the syntax for including it either in the map $geoip_country_code $allowed_country function in the nginx.conf file or in each virtual host file. That is what I need assistance with. Thanks! Commented May 23, 2016 at 14:22
  • I see, I misunderstood the question then. The way to do that would be the geo module. I will update my answer Commented May 23, 2016 at 15:12
  • Hi Ben, when I implement this or similar solutions I get a 403 from all IP addresses. It looks like the geo $allowed_ip denies all IP addresses by default. Is there no way to not set a default = no and set if ($allowed_ip = yes) { try files ... Commented May 24, 2016 at 14:20
  • You could skip the default and override allowed_country geo $allowed_country { 127.0.0.1 yes; 192.168.1.0/24 yes; } Commented May 24, 2016 at 17:42