download GeoIP databases mkdir /etc/nginx/geoip cd /etc/nginx/geoip wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz gunzip GeoIP.dat.gz wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz gunzip GeoLiteCity.dat.gz load GeoIP databases in Nginx http { geoip_country /etc/nginx/geoip/GeoIP.dat; geoip_city /etc/nginx/geoip/GeoLiteCity.dat; #... } setting location echo info server { listen 80; server_name domain.com; location / { add_header "Content-type" "text/html"; echo "<pre>"; echo "You IP:"; echo "$remote_addr"; echo "You Location:"; echo "$geoip_country_name"; echo "$geoip_region_name"; echo "$geoip_city"; echo "</pre>"; } }