Skip to content

Instantly share code, notes, and snippets.

@shellus
Last active October 2, 2017 08:45
Show Gist options
  • Select an option

  • Save shellus/0f5d529efe00ca4257e26b890798cc91 to your computer and use it in GitHub Desktop.

Select an option

Save shellus/0f5d529efe00ca4257e26b890798cc91 to your computer and use it in GitHub Desktop.

Revisions

  1. 娃娃脾气 revised this gist Oct 2, 2017. 1 changed file with 7 additions and 2 deletions.
    9 changes: 7 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -25,9 +25,14 @@ server {
    location / {
    add_header "Content-type" "text/html";
    echo "you location:";
    echo "$geoip_city_country_name";
    echo "<pre>";
    echo "You IP:";
    echo "$remote_addr";
    echo "You Location:";
    echo "$geoip_country_name";
    echo "$geoip_region_name";
    echo "$geoip_city";
    echo "</pre>";
    }
    }
    ```
  2. 娃娃脾气 created this gist Oct 2, 2017.
    33 changes: 33 additions & 0 deletions README.md
    Original 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";
    }
    }
    ```