Nginx – What this is parameter in the geo block in Nginx

geoipnginx

In nginx, in geo module it has the following example
http://nginx.org/en/docs/http/ngx_http_geo_module.html
I am wondering what is this 0,2,1,1 numbers etc.. stated after the main addresses (values). what are the usage of them?

> geo $geo {
>     default        0;
> 
>     127.0.0.1      2;
>     192.168.1.0/24 1;
>     10.1.0.0/16    1;
> 
>     ::1            2;
>     2001:0db8::/32 1; 
>}

Best Answer

0, 1 and 2 are the values that the variable $geo takes when in use for that specific IP. Later in the documentation is't clearer

geo $country {
default        ZZ;
include        conf/geo.conf;
delete         127.0.0.0/16;
proxy          192.168.100.0/24;
proxy          2001:0db8::/32;

127.0.0.0/24   US;
127.0.0.1/32   RU;
10.1.0.0/16    RU;
192.168.1.0/24 UK;
}

Then you can use it as you wish, ie (devil if used only as example)

if ( $geo = 1 ) {
    return 403;
}
Related Topic