远程地址是否与 x-forwarded-for 相同? [英] Is remote address the same as x-forwarded-for?

查看:57
本文介绍了远程地址是否与 x-forwarded-for 相同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从请求中获取 x-forwarded-for 标头.由于我已经有一个 http 过滤器,我可以使用 HttpServletRequest.getRemoteAddr() 轻松记录远程地址,而记录 x-forwarded-for 会需要额外的配置.我的问题是,HttpServletRequest.getRemoteAddr() 是否会返回与 x-forwarded-for 相同的地址,是 x-forwarded-for远程地址一样吗?

I need to get the x-forwarded-for header from requests. Since i already have an http filter, i can easily log remote address using HttpServletRequest.getRemoteAddr(), whereas logging x-forwarded-for would require additional configuration. My question is, will the HttpServletRequest.getRemoteAddr() return the same address as x-forwarded-for, are x-forwarded-for and remote address the same?

推荐答案

否,HttpServletRequest.getRemoteAddr() 将返回最后一个代理的地址,或者负载均衡器,通过它发送请求.X-Forwarded-For 将返回第一次发送请求的原始地址,然后是代理负载均衡器的地址>.

No, HttpServletRequest.getRemoteAddr() will return the address of the last proxy, or load balancer through which the request was sent. X-Forwarded-For will return the original address, from which the request was first sent, followed with the address of the proxy or the load balancer.

这篇关于远程地址是否与 x-forwarded-for 相同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆