Can't get Client IP Address connected through a proxy using request.getHeader("x-forwarded-for");
I tried to get client ip address connected server through a proxy by the following:
PrintWriter out=response.getWriter();
out.println("x-forwarded-for : "+request.getHeader("x-forwarded-for"));
out.println("remote : "+request.getRemoteAddr());
But I get always null from getHeader("x-forwarded-for")
method.
I get only remote address by getRemoteAddr()
.
But I开发者_如何学Python tried spoofer firefox plugin and it works.
Anybody knows the solution? Thanks.
You need to check if that proxy server indeed add the 'x-forwarded-for' header to the request. A proxy server is not obligatory to do so.
精彩评论