Reputation: 349
Declaring new variables such as map
or geoIP2 are always on the the http
context.
Lets say I need to check for location of an ip only on certain location
block in my configuration,
does that mean that this variables related to the geoIP2 will be calculated in any connection established to the server or only when its get called?
I wondered how NGINX actually works, when do the variables get calculated?
example:
http{
geoip2 GeoIP/GeoLite2-Country.mmdb {
$geoip2Country country iso_code;
}
map $geoip2Country $denyCountry {
default 1;
US 0;
}
location /zone/{ //the only location where I use the variable
if ($denyCountry){
return 444;
}
}
}
Upvotes: 1
Views: 385