leev / ngx_http_geoip2_module

Nginx GeoIP2 module
BSD 2-Clause "Simplified" License
983 stars 186 forks source link

New variables can't be used as source #88

Closed artembokhan closed 4 years ago

artembokhan commented 4 years ago

If variable is defined inside configuration file it can't be used as source. Please fix if possible.

geoip2 /usr/share/GeoIP/GeoLite2-City.mmdb {
    auto_reload 5m;
    $country_code   source=$ipaddress country iso_code;
    $country_name   source=$ipaddress country names en;
    $city_name      source=$ipaddress city names en;
    $continent_name source=$ipaddress continent names en;
    $continent_code source=$ipaddress continent code;
}

nginx -t nginx: [emerg] unknown "ipaddress" variable nginx: configuration file /etc/nginx/nginx.conf test failed

wronan commented 4 years ago

I think you must have messed something up in the config, because I'm using such a solution in one of my apps and it's working fine (different sources for the IP to be geolocated, variable set in the main file, geoip2 directives loaded from conf.d/)

artembokhan commented 4 years ago

I have a workaround using variable $http_variable (aka request header) which is working but not with $variable

artembokhan commented 4 years ago

Variable must be defined to use it. I was trying to use variable from named capture group which did not work.

seguri commented 3 months ago

@wronan can you please show me the content of your configuration file from conf.d?

wronan commented 3 months ago

Sorry man... I've switched to other solution long time ago and the config is gone.