如何检查页面是否正在从代理请求?
我有一个页面:http://example/mypage
并且有一个代理向我的页面发出请求:
http://proxy/?url=http://example/mypage
如何确定该页面是否从没有代理的空白页面打开,或者是否它是由代理请求的吗?
I have a page: http://example/mypage
And there is a proxy that make a request to my page:
http://proxy/?url=http://example/mypage
How can I find out if the page is opening from a blank page without proxies or if it is being requested by a proxy?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,你不能。当请求到达您的 HTTP 服务器时,您拥有的有关客户端的唯一信息是其 IP 地址以及客户端决定在请求标头中发送给您的任何其他信息。您能做的最好的事情就是在某种数据库中查找 IP 地址,看看它是否是已知的代理。
如果您正在寻找一个特定代理,您希望在请求标头中传递特定信息,那就完全是另一回事了。但一般来说,我可以从我的客户端向您发送 Web 请求并使其看起来像代理,或者我可以从代理发送请求并使其看起来像是直接来自客户端。
In general, you can't. When a request gets to your HTTP server, the only information you have about the client is its IP address and whatever other information the client decides to send to you in the request headers. The best you can do is look up the IP address in some kind of database to see if it's a known proxy.
If you're looking for a specific proxy that you expect to pass particular information in request headers, that's something else entirely. But in general, I can send a Web request to you from my client and make it look like a proxy, or I could send a request from a proxy and make it look like it's coming directly from the client.
我怀疑没有可靠的方法可以做到这一点,因为匿名代理试图......好吧匿名......您可以尝试检查
HttpContext.Request.UrlReferrer
是否具有某些价值,但这并不可靠。您可以检查一些已知代理 IP 地址的数据库,但我怀疑这也不是很可靠。I suspect there won't be a reliable way to do that, because anonymous proxies try to be ... well anonymous ... You can try to check if
HttpContext.Request.UrlReferrer
has some value, but that won't be reliable. You can check against some database of known proxy IP addresses, but I suspect that won't be very reliable either.