Posts

Showing posts with the label IP

[JAVA] request.getRemoteAddr() outputs 0:0:0:0:0:0:0:1 problem

Image
Java source as below   String ip = request.getHeader("X-Forwarded-For"); Even if you put getHeader, the ip address is 0:0:0:0:0:0:0:1. 0:0:0:0:0:0:0:1 is an IPV6 address, and 127.0.0.1 is correct in IPV4. The reason is that if you set it up when running Tomcat in Eclipse, it will be imported as IPV6.     if (ip == null || ip.length() == 0) {         ip = request.getHeader("Proxy-Client-IP");     }          if (ip == null || ip.length() == 0) {         ip = request.getHeader("WL-Proxy-Client-IP");     }          if (ip == null || ip.length() == 0) {         ip = request.getHeader("HTTP_CLIENT_IP");     }          if (ip == null || ip.length() == 0) {         ip = request.getHeader("HTTP_X_FORWARDED_FOR");     }          if (ip == null || ip.length() == 0) {...