Files
2026-02-23 10:01:00 +09:00

43 lines
1.2 KiB
Plaintext

<%
Response.write "aaa=" & remoteIP()
Function remoteIP()
Dim clientIP
' 1. X-Forwarded-For 헤더 확인 (프록시 환경에서 가장 우선)
clientIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If clientIP <> "" Then
' 여러 프록시를 거친 경우 쉼표로 구분되므로 첫 번째 IP 추출
If InStr(clientIP, ",") > 0 Then
clientIP = Trim(Split(clientIP, ",")(0))
End If
remoteIP = clientIP
Exit Function
End If
' 2. X-Real-IP 헤더 확인 (Nginx 등에서 사용)
clientIP = Request.ServerVariables("HTTP_X_REAL_IP")
If clientIP <> "" Then
remoteIP = clientIP
Exit Function
End If
' 3. CF-Connecting-IP 헤더 확인 (Cloudflare 사용시)
clientIP = Request.ServerVariables("HTTP_CF_CONNECTING_IP")
If clientIP <> "" Then
remoteIP = clientIP
Exit Function
End If
' 4. HTTP_CLIENT_IP 확인
clientIP = Request.ServerVariables("HTTP_CLIENT_IP")
If clientIP <> "" Then
remoteIP = clientIP
Exit Function
End If
' 5. 기본 REMOTE_ADDR 사용
clientIP = Request.ServerVariables("REMOTE_ADDR")
remoteIP = clientIP
End Function
%>