X-Forwarded-Host标头的实际使用情况? [英] Real life usage of the X-Forwarded-Host header?

查看:2535
本文介绍了X-Forwarded-Host标头的实际使用情况?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 X-Forwarded - * 标题上找到了一些有趣的读物,包括反向代理请求标题部分,以及维基百科关于X-Forwarded-For的文章

I've found some interesting reading on the X-Forwarded-* headers, including the Reverse Proxy Request Headers section in the Apache documentation, as well as the Wikipedia article on X-Forwarded-For.

我理解:


  • X-Forwarded-For 给出连接到代理的客户地址

  • X-Forwarded-Port 给出客户端在代理上连接的端口(例如 80 443

  • X-Forwarded-Proto 给出客户端用于连接代理的协议( http https

  • X- Forwarded-Host 给出客户端发送给代理的 Host 标头的内容。

  • X-Forwarded-For gives the address of the client which connected to the proxy
  • X-Forwarded-Port gives the port the client connected to on the proxy (e.g. 80 or 443)
  • X-Forwarded-Proto gives the protocol the client used to connect to the proxy (http or https)
  • X-Forwarded-Host gives the content of the Host header the client sent to the proxy.

这些都有意义。

然而,我仍然无法弄清楚 X-Forwarded-Host 的真实用例。我理解需要在不同的端口上重复连接或使用不同的方案,但为什么代理服务器在重复请求时会更改主机标头目标服务器?

However, I still can't figure out a real life use case of X-Forwarded-Host. I understand the need to repeat the connection on a different port or using a different scheme, but why would a proxy server ever change the Host header when repeating the request to the target server?

推荐答案

如果你使用像 Apigee 作为API的前端,你需要像X-FORWARDED-HOST这样的东西来理解用于连接API的主机名,因为Apigee配置了你的后端DNS,nginx和你的应用程序堆栈只看到主机头作为你的后端DNS名称,而不是首先调用的主机名。

If you use a front-end service like Apigee as the front-end to your APIs, you will need something like X-FORWARDED-HOST to understand what hostname was used to connect to the API, because Apigee gets configured with whatever your backend DNS is, nginx and your app stack only see the Host header as your backend DNS name, not the hostname that was called in the first place.

这篇关于X-Forwarded-Host标头的实际使用情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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