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

Http proxy requests can fail if they have to do DNS lookup #398

Open
rdubrock opened this issue Jan 31, 2023 · 2 comments
Open

Http proxy requests can fail if they have to do DNS lookup #398

rdubrock opened this issue Jan 31, 2023 · 2 comments

Comments

@rdubrock
Copy link
Contributor

I'm not 100% what's going on here, or if this is maybe use case specific. I'm just tossing this here as a placeholder until I can swing back a flesh it out.

To reproduce:

  • Create an http check pointed at a normal url (like http://www.google.com) with a proxy URL and auth header

What happened:

  • The probe fails

However, if you change the target from a URL like http://www.google.com to the IP address that the domain resolves to, it will work just fine.

@mem
Copy link
Collaborator

mem commented Feb 1, 2023

OK, this is weird.

@adriansr
Copy link
Contributor

adriansr commented Feb 23, 2023

I submitted a patch that I think will solve this issue: #405

However, I'm not 100% what is causing the problem.

Without the patch, a proxied HTTPS request for google.com looks like:

CONNECT 216.58.215.142:443 HTTP/1.1
Host: 216.58.215.142:443
User-Agent: Go-http-client/1.1

And the SNI field in the TLS Client Hello is google.com.

(Note that the host field is wrong, should be google.com, and the User-Agent is also wrong)

Edit: This is correct, according to this discussion haproxy/haproxy#1159, the Host header must be equal to the target passed in the connect method. I still think the below is correct:

This sometimes works, sometimes doesn't, and sometimes results in a redirect that is requested as:

CONNECT google.com:443 HTTP/1.1
Host: google.com:443
User-Agent: Go-http-client/1.1

My understanding is that the proxy request is handled internally by either Go or prometheus/common and is not prepared to use the Host header that BBE injects after resolving the original hostname. Then we depend on how the target server responds to a request without the correct Host header.

The above patch is supposed to fix this as it disables all the magic around the hostname. The only drawback is that we're loosing the DNS metrics, but those doesn't make sense in a proxied request anyway.

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

No branches or pull requests

3 participants