티스토리 뷰

1 Tier 서버 (WEB IIS + DB 1 Server) 에서
유독 한 사이트가 느려서 서버 로그를 확인해보니
500 Script timeout 오류가 많이 발생하고 있었고
client ip들을 분석하여보니
timeout 유발은 99% 중국 아니면 외국이었다.

중국측 IP 대역만 막으려다가
딱히 국외를 위해 서비스할 사이트가 아니어서
한국 접속만 허용으로 정책을 정했다.

GeoIP 다운로드 [새창]
GeoLite Country 최근 DB 다운로드 [새창]

'한국만 접속 가능토록 필터링
remote_ip_address = request.ServerVariables("REMOTE_ADDR")
set geo_ip = Server.CreateObject("GeoIPCOM.GeoIP")
geo_ip.loadDataFile("C:\Program Files\GeoIP\GeoIP.dat")
country_code = geo_ip.country_code_by_name(remote_ip_address)
country_name = geo_ip.country_name_by_name(remote_ip_address)
'한국 국내 접속이 아니면
If UCase(country_code) <> "KR" Then
    'Response.Status = "403 Forbidden" '금지 상태코드 내뱉어주기
    msg = "

HTTP Error 403.0 - Forbidden

"&_ "
You do not have permission to view this directory or page.
" Response.Write(msg) Response.end '끝내기 End If

참고:

http://www.restapitutorial.com/httpstatuscodes.html
http://dev.maxmind.com/geoip/legacy/geolite/
국가별 IP 차단 대역 http://www.ipdeny.com/ipblocks/
KRNIC 중국 IP 대역 http://krnic.or.kr/jsp/infoboard/stats/ipCurrent.jsp?nationCode1=CN

댓글