common
common copied to clipboard
Set HTTP hostname based on TLS server name
The net/http library uses the Host field from the Request object in order to determine the value of the Host header [1]. In order for the Prometheus client to support SNI, it needs to set this field to the value provided in the TLS server name.
[1] https://github.com/golang/go/issues/29865
Signed-off-by: fpetkovski [email protected]
Fixes https://github.com/prometheus/prometheus/issues/9403
Hello,
Thank you for your contribution. I am surprised that SNI does not work out of the box.
I am not willing to have this repository depend on client_golang. We have an exception for an interface in version, and the tests in sigv4, but that's it.
Thanks for the feedback. Could you point me to where the dependency to client_golang is introduced in this PR? Do you mean because we are referencing the TLS config?
The initial commit introduced a dependency. Then it was force pushed.
I can not merge this as is, I need to check that 1. SNI works even with our connection pooling and 2. This does not break blackbox exporter, which has similar logic.
Ah yes, that seems to be correct: https://github.com/prometheus/common/commit/038724fffa024b190650f1cf95adaf7fd57eaa96#diff-cdb28b391884a82ef481177749e35ba9c3c54bda95d93ffe3d5f3ba1c67c2c5eR35
after thinking twice, the TLS servername should come from the header, not the other way around.
What do you mean by this? Isn't the TLS server name a user provided config?