如何手动设置HTTP_X_FORWARDED_FOR的值? [英] How to set value for HTTP_X_FORWARDED_FOR manually?

查看:767
本文介绍了如何手动设置HTTP_X_FORWARDED_FOR的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在某处说他们说HTTP_X_FORWARDED_FOR在你想记录用户的IP时是不可信的变量,因为他们可以改变它。这是真的吗?如何?

非常感谢!

解决方案

使用的代理可以将此标题设置为任何想要的内容,因此您无法相信其值。尽管大多数代理都设置了正确的值。这个头文件通常被缓存代理使用,在这种情况下,您可以控制代理,并且可以验证是否为您提供了正确的信息。在所有其他情况下,其价值应被视为不值得信赖。有关维基百科关于 X-Forwarded-For


I read somewhere they said that HTTP_X_FORWARDED_FOR is not a trusted variables when you want to log the user's IP because they can change that. Is it real? And how?

Thanks a lot!

解决方案

The proxy used can set this header to anything it wants to, and therefore you can't trust its value. Most proxies do set the correct value though. This header is mostly used by caching proxies, and in those cases you're in control of the proxy and can thus verify that is gives you the correct information. In all other cases its value should be considered untrustworthy. Read more on the Wikipedia article about X-Forwarded-For.

这篇关于如何手动设置HTTP_X_FORWARDED_FOR的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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