X-Forwarded-For 에서 클라이언트 아이피 얻는 다양한 방법
참조URL: https://www.lesstif.com/software-architect/proxy-client-ip-x-forwarded-for-xff-http-header-20775886.html
개요
본문
X-Forwarded-For: client, proxy1, proxy2String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}<?
#include_once('./_common.php');
$ip;
function getRealClientIp() {
if (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
}
if(getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
}
return $ip;
}
$ip = getRealClientIp();
echo $ip;
?>Apache Web Server 로그에 클라이언트 아이피 기록하기
Nginx Web Server 로그에서 클라이언트 아이피 기록하기
Apache Tomcat 의 Access log
Last updated