Download IP address database:
National Database: http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
City database: http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
http {
geoip_country /path/to/GeoIP.dat;
geoip_city /path/to/GeoLiteCity.dat;
server{
listen 3592;
server_name www.siguoya.name;
location / {
default_type text/plain;
if ($geoip_country_code != 'CN'){
return 403;
}
return 200 "$remote_addr $geoip_city_country_name $geoip_country_code $geoip_city";
}
}
}
access:http://www.siguoya.name:3592/
119.32.216.122 China CN Guangzhou
Read topics
- 1. Nginx advantage
- 2. Nginx installation and boot from Kai
- 3. Nginx configuration syntax and directories
- 4. Nginx module
- 5. Nginx handling the static resources
- 6. Nginx browser cache principle
- 7. Cross-domain access resources Nginx
- Anti-theft chain 8. Nginx resources
- 9. Nginx proxy
- 10. Nginx Load Balancing
- 11. Nginx cache
- 12. Nginx static and dynamic separation
- 13. Nginx Rewrite
- 14. Nginx Secure Link
- 15. Nginx Geo
- 16. Nginx HTTPS service
- 17. Nginx and development of Lua
- 18. Nginx release and gray Lua
- 19. Nginx common errors
- 20. Nginx performance optimization
- 21. Nginx Security Management