java - Strange IP addresses in tomcat -
this question has answer here:
- how remote address of client in servlet? 8 answers
some have in generic class.
public static string getrequestip (httpservletrequest request){ string ipaddr = request.getheader("x-forwarded-for"); if (ipaddr == null)ipaddr = request.getremoteaddr(); return ipaddr; }
for every request call method , in moment insert record in mysql database.
in cases works , can see record every request valid ip address in right field. ip should there this. "unknown, 93.186.30.120" or "10.0.1.169, 186.38.84.3" apache @ front listening @ port 80 , used proxy tomcat listens @ port 8081. router config not allow pass conection come port other 80. help? in advance.
the format x-forwarded-for http header is:
x-forwarded-for: client, proxy1, proxy2, ...
thus
unknown, 93.186.30.120
means request coming proxy @ 93.186.30.120, originating unknown local address; ,
10.0.1.169, 186.38.84.3
similarly means, request 186.38.84.3 proxy, coming local ip 10.0.1.169
Comments
Post a Comment