I have nginx-1.12.1 installed on Centos 6.7 final. Already loaded the --with-http_geoip_module 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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Are you using an updated GeoLiteCity.dat ? Also remember that a lot of connections are now IPv6, so you need to use the GeoLiteCityv6.dat: https://dev.maxmind.com/geoip/legacy/geolite/
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.