0

Trying to Add geoIP to my nginx server, but for some reason it's not quite working and I can't seem to figure out why not. If i try to add anything related to geoip_country in my config file, I get the error [emerg] unknown directive "geoip_country" in /etc/nginx/nginx.conf

Running Nginx 1.21.1 on Ubuntu 18.04.5 LTS.

nginx -V shows --with-http_geoip_module=dynamic and in my nginx.conf file I have load_module /etc/nginx/modules-enabled/ngx_http_geoip2_module.so;

  • 1
    The `http_geoip2_module` and `http_geoip_module` are different modules. – Richard Smith Aug 28 '21 at 11:22
  • You are right Richard, so I recompiled it with --add-dynamic-module=../ngx_http_geoip2_module and copied the new .so file over and loaded it. No luck. I then tried to compile it with geoip2 as a static module --add-module=/home/ngx_http_geoip2_module - still complains about the unknown directive “geoip_country” when I run nginx -t – Michael Nielsen Aug 28 '21 at 12:33
  • 1
    `geoip_country` is not a directive of the `http_geoip2_module` – Richard Smith Aug 28 '21 at 13:26
  • Makes sense now, that was a left over from the old geoip module in my nginx file. Didn't knew it wasn't also part of geoip2.. thanks for helping clear it up, manage to get it working now. – Michael Nielsen Aug 28 '21 at 15:10

1 Answers1

0

Update: As richardS Smith pointed out geoip_country isn't part of geoip2. Had to use $geoip2_data_country_code instead to get it working.