HTTP 代理如何利用 HTTP 协议?代理 RFC?
与实现 HTTP Web 服务器相比,如何实现 HTTP 代理?有什么区别?是否有关于此主题的明确指南或 RFC 或有用的书籍?
How does one go about implementing a HTTP proxy compared to implementing a HTTP webserver, what are the differences? Is there a definitive guide or RFC or a helpful book on this subject?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
发送到代理的标头是不同的。
例如,以下是 Google Chrome 通过代理服务器发送到 www.baidu.com 的内容:
我们可以看到它是
而不是
,这里
也是
http 代理的 Host 字段是必需。
对于 HTTPS 隧道代理:
我们可以看到
domain:443
而不是https://domain
。CONNECT字段将代理服务器变成类似TCP隧道的东西,然后将协议
HTTPS
替换为端口:443
对于socks5代理,事情变得很容易,因为socks5什么都不关心对于更高的协议,您只需告诉它主机和端口即可。
The header sent to a proxy is different.
For example, here is what is sent by Google Chrome to www.baidu.com via a proxy server:
We can see it is
instead of
and here is
also
Host field is required for http proxy.
For HTTPS tunnel proxy:
We can see
domain:443
instead ofhttps://domain
.CONNECT field turn the proxy server to something like a TCP tunnel, then the protocol
HTTPS
is replaced by the port:443
For socks5 proxy, things become easy, because socks5 care nothing about higher protocol, you just tell it host and port.
HTTP 代理服务器的要求在
路由
语义和内容
The requirements on HTTP Proxy servers are specified within
Routing
Semantics and Content
代理与服务器非常相似;唯一的区别是,解析请求后,它只是转发请求并返回结果*,而不是处理请求本身。由于代理不必执行与普通服务器相同的处理量,因此它通常可以比完整的服务器对请求进行最少的解析,但除此之外它的想法是相同的。
*一些代理实现额外的缓存。有些还对响应/请求进行模糊处理,但这是邪恶的代理,希望您没有想到。
A proxy is very similar to a server; the only difference is that, after parsing the request, it merely forwards it and returns the result*, rather than processing the request, itself. Because the proxy does not have to do the same amount of processing as a normal server, it can often get away with a far more minimal parsing of the requests than a full-fleded server, but otherwise it is the same idea.
*Some proxies implement additional caching. Some also futz with the response/request, but that is the evil kind of proxy, which hopefully you do not have in mind.