Question
How to use $geoip_city on Nginx
I have nginx-1.12.1 installed on Centos 6.7 final. Already loaded the –with-httpgeoipmodule on configure arguments.
I have this code on my nginx.conf inside http context
geoip_city /usr/local/share/GeoIP/GeoLiteCity.dat;
Also add this code
map $geoip_city $not_allowed_region {
default no;
Shanghai yes;
}
Inside my vhost conf file
# server content
if ($not_allowed_region = yes) {
rewrite ^/(.*)$ https://test.com redirect;
}
I did nginx -t and also restart using nginx -s reload but nothing happens.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×