- spring-boot & nginx (nginx에 설정 필요)
https://playdev.tistory.com/3
- nginx + tomcat
https://2bmw3.tistory.com/9
- x-forwarded-for 이용
X-Forwarded-For: client, proxy1, proxy2
https://www.lesstif.com/pages/viewpage.action?pageId=20775886
http://all-record.tistory.com/168
https://code.i-harness.com/ko/q/fcab15
public String getClientIpAddr(HttpServletRequest request) {
logger.debug("getClientIpAddr");
String ip = request.getHeader("X-Forwarded-For");
logger.debug("X-Forwarded-For [{}]", ip);
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getHeader("Proxy-Client-IP");
logger.debug("Proxy-Client-IP [{}]", ip);
}
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getHeader("WL-Proxy-Client-IP");
logger.debug("WL-Proxy-Client-IP [{}]", ip);
}
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
logger.debug("HTTP_X_FORWARDED_FOR [{}]", ip);
}
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getHeader("HTTP_X_FORWARDED");
logger.debug("HTTP_X_FORWARDED [{}]", ip);
}
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getHeader("HTTP_X_CLUSTER_CLIENT_IP");
logger.debug("HTTP_X_CLUSTER_CLIENT_IP [{}]", ip);
}
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getHeader("HTTP_CLIENT_IP");
logger.debug("HTTP_CLIENT_IP [{}]", ip);
}
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getHeader("HTTP_FORWARDED_FOR");
logger.debug("HTTP_FORWARDED_FOR [{}]", ip);
}
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getHeader("HTTP_FORWARDED");
logger.debug("HTTP_FORWARDED [{}]", ip);
}
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getHeader("HTTP_VIA");
logger.debug("HTTP_VIA [{}]", ip);
}
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getHeader("REMOTE_ADDR");
logger.debug("REMOTE_ADDR [{}]", ip);
}
if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) {
ip = request.getRemoteAddr();
logger.debug("getRemoteAddr [{}]", ip);
}
return ip;
}
'servlet & jsp' 카테고리의 다른 글
WEB-INF 경로의 파일 읽어 들이기 (0) | 2018.06.15 |
---|---|
default servlet 설정 (0) | 2018.05.23 |
[링크] 자바 Http / https 의 결과를 주고받을때 세션을 유지하고 싶다면! (0) | 2018.04.09 |
JarCheck.jsp파일을 이용한 classcast Error 잡아내기 (0) | 2016.06.03 |
에러페이지 (0) | 2015.11.03 |