서버에 접속하는 IP의 국가를 확인하는 방법이 있나요?
GeoIP로 국가 확인:
# CLIsudo apt install geoip-bin geoip-databasegeoiplookup 8.8.8.8# GeoIP Country Edition: US, United States# Pythonpip install geoip2import geoip2.databasereader = geoip2.database.Reader("GeoLite2-City.mmdb")resp = reader.city("8.8.8.8")print(resp.country.name) # United States# Nginx에서 국가별 차단geoip2 /usr/share/GeoIP/GeoLite2-Country.mmdb { $geoip2_data_country_code country iso_code;}if ($geoip2_data_country_code = "CN") { return 403; }
MaxMind GeoLite2 DB를 무료로 사용할 수 있습니다 (회원가입 필요). 주기적 업데이트를 위해 geoipupdate를 설정하세요.
댓글 1
GeoIP로 국가 확인:
MaxMind GeoLite2 DB를 무료로 사용할 수 있습니다 (회원가입 필요). 주기적 업데이트를 위해 geoipupdate를 설정하세요.