开发者

Can't get Client IP Address connected through a proxy using request.getHeader("x-forwarded-for");

开发者 https://www.devze.com 2023-03-08 17:04 出处:网络
I tried to get client ip address connected server through a proxy by the following: PrintWriter out=response.getWriter();

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消