Forwarded - HTTP 编辑

The Forwarded header contains information from the reverse proxy servers that is altered or lost when a proxy is involved in the path of the request.

The alternative and de-facto standard versions of this header are the X-Forwarded-For, X-Forwarded-Host and X-Forwarded-Proto headers.

This header is used for debugging, statistics, and generating location-dependent content and by design it exposes privacy sensitive information, such as the IP address of the client. Therefore the user's privacy must be kept in mind when deploying this header.

Header typeRequest header
Forbidden header nameno

Syntax

Forwarded: by=<identifier>;for=<identifier>;host=<host>;proto=<http|https>

Directives

<identifier>
An identifier disclosing the information that is altered or lost when using a proxy. This can be either:
  • an IP address (v4 or v6, optionally with a port, and ipv6 quoted and enclosed in square brackets),
  • an obfuscated identifier (such as "_hidden" or "_secret"),
  • or "unknown" when the preceding entity is not known (and you still want to indicate that forwarding of the request was made).
by=<identifier>
The interface where the request came in to the proxy server.
for=<identifier>
The client that initiated the request and subsequent proxies in a chain of proxies.
host=<host>
The Host request header field as received by the proxy.
proto=<http|https>

Indicates which protocol was used to make the request (typically "http" or "https").

Examples

Using the Forwarded header

Forwarded: for="_mdn"

# case insensitive
Forwarded: For="[2001:db8:cafe::17]:4711"

# separated by semicolon
Forwarded: for=192.0.2.60;proto=http;by=203.0.113.43

# multiple values can be appended using a comma
Forwarded: for=192.0.2.43, for=198.51.100.17

Transitioning from X-Forwarded-For to Forwarded

If your application, server, or proxy supports the standardized Forwarded header, the X-Forwarded-For header can be replaced. Note that IPv6 address are quoted and enclosed in square brackets in Forwarded.

X-Forwarded-For: 123.34.567.89
Forwarded: for=123.34.567.89

X-Forwarded-For: 192.0.2.43, "[2001:db8:cafe::17]"
Forwarded: for=192.0.2.43, for="[2001:db8:cafe::17]"

Specifications

SpecificationTitle
RFC 7239, section 4: ForwardedForwarded HTTP Extension

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:29 次

字数:5104

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文