K
K
kalakosha2019-12-19 13:41:48
Nginx
kalakosha, 2019-12-19 13:41:48

NGINX+GeoIP2. How to allow access to the site from the local network?

Good afternoon!
The config contains the following block for GeoIP:

geoip2 /usr/local/share/GeoIP/GeoLite2-Country.mmdb {
        auto_reload 5m;
        $geoip2_data_country_code country iso_code;
        }
map $geoip2_data_country_code $country_code_allowed {
                default deny;
                UA allow;
                RU allow;
                DE allow;
        }

The following has been added to the server section for the HTTPS server:
if ($country_code_allowed = deny) {
                return 444;
          }

Countries are cut off. But at the same time, access to the site from the local network is also cut off.
added separately
map $remote_addr $localnets {
                default 0;
                10.9.6.0/23 1;
                10.10.40.0/24 1;
                }

Tried to add
if ($localnets = 0) {
                return 444;
          }

but the result didn't change.
How to combine checking $localnets and $country_code_allowed ? Or is there another reason?
Thanks in advance for your help and advice.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Karasik, 2019-12-19
@kalakosha

Here are two examples (didn't test it myself):
https://stackoverflow.com/questions/17223360/how-t...
https://serverfault.com/questions/585204/nginx-geo...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question