Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward headers to upstream #44

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

friedrichg
Copy link

The idea is being able to pass specific headers to upstream.

For example: to make this work with Cortex/Mimir and also pass user agent, one would do

/thanos-federate-proxy --upstream=http://127.0.0.1:8000/api/prom -forward-header X-Scope-OrgID -forward-header User-Agent

Tests are missing. But can you give a review? do you like it?

If you like it, I will add tests and update the readme

@luisdavim
Copy link
Contributor

Shouldn't all headers be forwarded by default?

@friedrichg
Copy link
Author

Shouldn't all headers be forwarded by default?

Yeah, that was my first thought too. But it will open a can of worms as not all headers should be forwarded

  1. See in comparison ReverseProxy, which is the default reverse proxy for go, which doesn't forward all headers.
    https://github.com/golang/go/blob/go1.21.1/src/net/http/httputil/reverseproxy.go#L488-L494

  2. This proxy is not a reverseproxy per se, so current request from federate always looks like this:

POST /api/v1/query HTTP/1.1
Host: 127.0.0.1:9090
User-Agent: Go-http-client/1.1
Content-Length: 31
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip

query=up&time=1695647619.777714

if we forward all headers, we will need to skip Content-Length, Content-Type and Accept-Encoding and maybe others, it may be brittle.

Let me know if you want to skip all these headers or how do you want to proceed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants