V
V
Vladimir Revyakin2017-04-13 11:20:56
Nginx
Vladimir Revyakin, 2017-04-13 11:20:56

GeoIP NGINX open access for specific IP addresses?

Good afternoon, tell me how to open access for certain IP addresses from Latvia with this config?

geoip_country /usr/share/GeoIP/GeoIP.dat;
  map $geoip_country_code $allowed_country {
  default yes;
  LV no;
}


В блок server виртуального хоста добавил
if ($allowed_country = no) {
            return 403;
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kuzmenko, 2017-04-14
@jonimuesli

Take out separately:
map $remote_addr $extnet {
default 0;
104.192.143.0/24 1; # bitbucket.org
xx.xx.xx.145 1; # some-client
............................................... ......................
}
Use like this:
set $geoblock 0;
if ($extnet = 1){set $geoblock 0;}
if ($geoblock = 1){return 404;}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question