HTTP probe does not pass target dns name into "Host" request header #1303
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The HTTP probe module overrides the HTTP request header
Host
to the resolved IP address, which causes servers / hosts that require or expect the proper host name to be set, to behave differently then a typical browser or cURL would have. This affects both TLS (SNI) as well as vhost server name matching, on servers that either have multiple vhosts configured.This and similar issues have been created, with different outcomes here (i.e.: #936 and #558).
A mentioned workaround is to statically configure the desired DNS name via the
blackbox.yml
module config, just like in this partial example:The downside of this workaround is that you would need to create a separate module config for each target that requires it, which might be a lot or even all targets.
My proposed solution is to override only the HTTP request header
Host
to the original target host, after resolving it's IP and creating the HTTP request context.I hope I've made correct assumptions with this PR, if not feel free to comment, discuss or change :)
Kind regards,
Kevin | CompileNix
Host operating system: via Docker on:
Linux 6fe1959b57a1 6.10.9-100.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Sep 9 02:28:01 UTC 2024 x86_64 GNU/Linux
Linux 12b86e19e018 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
blackbox_exporter version: 0.25.0
What is the blackbox.yml module config:
How do you perform the probe?
Start the container
docker run -it --rm -p 36692:9115 -v $(pwd)/blackbox.yml:/config/blackbox.yml:z blackbox_exporter --config.file=/config/blackbox.yml
Perform Probe via Browser or cURL
http://127.0.0.1:36692/probe?module=http_2xx_strict_ssl&debug=true&target=https%3A%2F%2Fwww.google.com%3A443%2F
What logging output did you get from adding
&debug=true
to the probe URL?What did you do that produced an error?
curl 'http://127.0.0.1:36692/probe?module=http_2xx_strict_ssl&debug=true&target=https%3A%2F%2Fwww.google.com%3A443%2F'
What did you expect to see?
What did you see instead?
What logging output did you get with this PR?