Last active
October 2, 2017 08:45
-
-
Save shellus/0f5d529efe00ca4257e26b890798cc91 to your computer and use it in GitHub Desktop.
Revisions
-
娃娃脾气 revised this gist
Oct 2, 2017 . 1 changed file with 7 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,9 +25,14 @@ server { 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>"; } } ``` -
娃娃脾气 created this gist
Oct 2, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ ## download GeoIP databases ```bash 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 "you location:"; echo "$geoip_city_country_name"; echo "$geoip_city"; } } ```