I am trying to set up Nginx v. 1.24.0 and GeoIPupdate to work so that users not from a specific country do not get access to the web server.
However, as I'm following every guide I see that it is outdated, either the links do not work, because MaxMind deleted them, or they assume I have the module needed to be installed.
Even the official Nginx wiki has been of no help (https://nginx.org/en/docs/http/ngx_http_geoip_module.html)
I am at my wit's end and don't know what to do. All I want to do is know how to allow GeoIPupdate to work with Nginx, as I've got GeoIPupdate running.
I tried this guide: https://github.com/leev/ngx_http_geoip2_module
But now I am getting this:
Apr 24 15:25:51 localhost nginx[175588]: nginx: [emerg] unknown directive "if($allowed_country" in /etc/nginx/sites-enabled/default:80
Apr 24 15:25:51 localhost nginx[175588]: nginx: configuration file /etc/nginx/nginx.conf test failed
The config in question (in the server part):
if($allowed_country = no) {
return 403;
}
Upon checking Nginx modules I do see that 50-mod-http-geoip.conf does exist and should have loaded, but writing nginx -V does not input the module.
The most interesting part is, that the nginx.conf does work with allowed countries, as I do not get any errors from it.