Skip to content

Instantly share code, notes, and snippets.

@hongry18
Last active April 24, 2018 02:03
Show Gist options
  • Save hongry18/c33e3fa548490f9ff53be12bc7be8499 to your computer and use it in GitHub Desktop.
Save hongry18/c33e3fa548490f9ff53be12bc7be8499 to your computer and use it in GitHub Desktop.
GeoIP module install

nginx GeoIP Module

download geoip

https://dev.maxmind.com/geoip/legacy/downloadable/

un archive and install

tar zxf GeoIP.tar.gz
cd GeoIP
./configure
make
make install

generate configure

echo '/usr/local/lib' > /etc/ld.so.conf.d/geoip.conf
ldconfig

download Databases

curl -O http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
curl -O http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz

gzip -d GeoIP.dat.gz
mv GeoIP.dat /server/geoip

gzip -d GeoLiteCity.dat.gz
mv GeoLiteCity.dat /server/geoip

nginx compile add options

...
--with-http_geoip_module

variables

  • $geoip_city_country_code : KR, US 등의 국가 코드
  • $geoip_city_country_code3 : KOR, USA 등의 세글자 국가 코드
  • $geoip_city_country_name : KOREA, United State 등의 전체 국가명
  • $geoip_region : 지방명
  • $geoip_city : Seoul 등의 도시명
  • $geoip_postal_code : 우편번호
  • $geoip_city_continent_code : 대륙 코드
  • $geoip_latitude : 위도
  • $geoip_longitude : 경도
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment