简体   繁体   中英

Always Getting ::1 for Client IP Address from Servlet

I'm not sure why I'm always getting ::1 for IP Address from the header.

System.out.println("IP Address: " + request.getHeader("X-FORWARDED-FOR"));

IP Address: ::1

The proxy we use is Apache2 Reverse Proxy. Any idea?

First be sure that this header is actually coming in the http packet using a network analayzer such as Wireshark. Once you are sure about it, then try to print all the headers to be sure that header is set in the ServletHttpRequest object. If you get through all this, you can be sure where the problem is.

Hope it helps!

请用

request.getHeader("REMOTE_ADDR")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM