HTTP probe does not pass target dns name into "Host" request header#1303
HTTP probe does not pass target dns name into "Host" request header#1303CompileNix wants to merge 1 commit intoprometheus:masterfrom
Conversation
Override the HTTP request header `Host` to the original target host, after resolving it's IP and creating the HTTP request context. Signed-off-by: Kevin Weis <Kevin.Weis@plan.de>
fea0e3d to 85ccdb0 Compare | would love to see this go live, it is block us |
| I can't believe that blackbox_exporter has still not addressed this. Practically everything is served behind a reverse proxy or load balancer in any modern infrastructure. Without this PR it is a huge pain to simply probe sites which are not directly reachable by IP but are handled through the supplied Host header e.g. in a virtual hosting environment. Please merge this. I cannot use blackbox exporter without this. Adding >100 modules manually to simply define a header is not a viable workaround and clearly makes things unmaintainable. I do not want to maintain another fork just because I need the http module to behave like any other normal HTTP client which is able to make a simple request. Related issues include the following (there may be more but these are the main ones I found): |
| Please merge this. Pre DNS resolving helps a lot when doing some CDN endpoint healthcheck. |
| I was also forced to fork the repo because I need this feature. Very sad... |
| I need this feature as well. Any chance it will be merged soon? thanks! |
The HTTP probe module overrides the HTTP request header
Hostto 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.ymlmodule 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
Hostto 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/LinuxLinux 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/Linuxblackbox_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.ymlPerform 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%2FWhat logging output did you get from adding
&debug=trueto 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?