Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Set Host header for graphite-proxied requests to graphite host, not incoming host header #1980

Merged

Conversation

GuillaumeConnan
Copy link
Contributor

Due to an unresolved issue in the net/http/httputil package, Metrictrank can't reach a Graphite-Web fallback hosted behind an AWS application load balancer configured to route requests based on their host header.

The request's Host attribute, sent by Metrictank and read by the application load balancer, should match the request's URL.Host attribute to be correctly routed.

Currently, the Host attribute is set to the original request's host (the request made to Metrictank, which need to be proxified to Graphite).

This workaround replace the request's bad Host attribute with the expected value stored in URL.Host attribute.

@Dieterbe
Copy link
Contributor

Currently, the Host attribute is set to the original request's host

the request's host? as in the hostname of the client? or did you mean the Hostname header set in the original request?

@GuillaumeConnan
Copy link
Contributor Author

the Hostname header set in the original request

Given a client calling Metrictank's render API (on http://metrictank.internal/render for example).
The host header of this initial request is set to "metrictank.internal", everything is going as expected so far :-)

Then, if the request needs to be proxified by Metrictank to the Graphite fallback (on http://graphite-web.internal/render), the host header of the proxified request sent by Metrictank to Graphite is left untouched to "metrictank.internal" (the host header from the original request) when it should be set to "graphite-web.internal" to be correctly routed.

@stale
Copy link

stale bot commented Aug 22, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 22, 2021
@Dieterbe Dieterbe changed the title Add workaround for net/http/httputil host header issue Set Host header for graphite-proxied requests to graphite host, not incoming host header Aug 23, 2021
@stale stale bot removed the stale label Aug 23, 2021
Copy link
Contributor

@Dieterbe Dieterbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @shanson7 do you envision this may cause any breakage for you?

Note that we can't guarantee that all metrictank deployments will be okay with this change, so i have to asses the risk of this change for various deployments.

@shanson7
Copy link
Collaborator

shanson7 commented Nov 2, 2021

I don't see this breaking our deploy

@Dieterbe Dieterbe merged commit c401f8f into grafana:master Nov 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants