X-Forwarded-Host - support for including
See original GitHub issueSummary
Add support for X-Forwarded-Host
header
Context
In some circumstances it is useful for upstream services to know the original host. For example imagine an api that returns the following json:
{
"type": "articles",
"id": "1",
"attributes": {
"title": "Rails is Omakase"
},
"relationships": {
"author": {
"links": {
"self": "http://example.com/articles/1/relationships/author",
"related": "http://example.com/articles/1/author"
},
"data": { "type": "people", "id": "9" }
}
},
"links": {
"self": "http://example.com/articles/1"
}
}
Without access to a X-Forwarded-Host
header the application would need to store the value http://example.com
. This leads to extra unnecessary configuration
Further reading and context:
Possible Implementation
Looking at the documenation it seems like we could add a new kind host
to the existing Forwarded Header.
Adding the Forwarded header
Key | Default Value | Description |
---|---|---|
by | {kind: requestRandom} | The labeler to use with the router’s server address |
for | {kind: requestRandom} | The labeler to use with the upstream client’s address |
host | {kind: requestRandom} | The labeler to use with the host header, either host or connectionRandom |
Additionaly a new labeler kind host
could be added to write the host unobfuscated.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
X-Forwarded-Host - HTTP - MDN Web Docs
The X-Forwarded-Host (XFH) header is a de-facto standard header for identifying the original host requested by the client in the Host HTTP ......
Read more >HTTP header | X-Forwarded-Host - GeeksforGeeks
The HTTP X-Forwarded-Host header is a request-type header de-facto ... Supported Browsers: The browsers are compatible with the HTTP ...
Read more >X-Forwarded-Host HTTP Header: Syntax, Directive, Examples
The X-Forwarded-Host HTTP Header is used to identify the client's initial request. Since the host names and ports of reverse proxies differed at ......
Read more >Real life usage of the X-Forwarded-Host header?
X-Forwarded-Host gives the content of the Host header the client sent to the proxy.
Read more >X-Forwarded-Host (XFH) - KeyCDN Support
X-Forwarded-Host is an HTTP request header used to forward the original Host request header value to the origin server.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve also observed that if the
X-Forwarded-Host
is already set, linkerd forwards it on. Which in my particular case solves my scenario. I have kong api gateway infront of linkerd and have used the request transformer to add theX-Forwarded-Host
headerhey guys, do you know how to change the links in the payload (JSON API) based on the X-Forwarded-Host?