代理服务器转发消息时的相关头部

场景:客户端与原服务器间存在多个代理的时候,每个服务器之间传输都会建立新一个TCP连接,每个TCP连接的源端地址,只是这个TCP连接的IP地址。如图中的Origin Server与Gateway建立的TCP连接只能拿到Gateway的IP,如果Origin Server想基于客户端的IP地址做负载均衡或者限速限流,通过TCP连接是拿不到的。

我们如何传递客户端(User Agent)的 IP 地址到服务器Origin Server呢?

  • X-Forwarded-For
  • X-Real-IP

消息的转发:

Max-Forwards 头部

  • 限制 Proxy 代理服务器的最大转发次数,仅对 TRACE / OPTIONS 方法有效
  • Max-Forwards = 1 * DIGIT

Via 头部

指明经过的代理服务器名称及版本

Via = 1#( recevied-protocol RWS recevied-by [ RWS comment ])

  • recevied-protocol = [ protocol-name "/" ] protocol-version
  • recevied-by = ( uri-host [ ":" port ]) / pseudonym
  • pseudonym = token

访问淘宝时得到的Via:

Via : cache47.l2cn624[77,304-0,H], cache12.l2cn624[78,0], cache9.cn579[0,200-0,H], cache8.cn579[0,0]

Cache-Control:no-transform

  • 禁止代理服务器修改响应包体
posted @ 2019-06-02 18:00  冯小圆  阅读(291)  评论(0编辑  收藏  举报