question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

X-Forwarded-Host - support for including

See original GitHub issue

Summary

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:closed
  • Created 6 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ewildecommented, Apr 10, 2017

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 the X-Forwarded-Host header

0reactions
conanconstantinecommented, Sep 6, 2018

hey guys, do you know how to change the links in the payload (JSON API) based on the X-Forwarded-Host?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found