Skip to content

Conversation

@gucci-on-fleek
Copy link

Fixes caddyserver/caddy#7055.

How to reproduce:

$ curl --insecure --resolve arbitrary.example.com:443:<your-server-IP> https://arbitrary.example.com/

@mholt
Copy link
Member

mholt commented Jun 10, 2025

This sounds terrible tbh 😆 Is this something we can fix? Or is it just a risk of enabling per-host metrics? (Which we hesitated to implement for a long time because of this problem, among some other technical problems too.)

@francislavoie
Copy link
Member

@mholt well, caddyhttp handler writes the empty 200 responses etc on the HTTP server for unknown domains, so metrics handlers pick that up since it wraps all handlers.

@gucci-on-fleek
Copy link
Author

@francislavoie

caddyhttp handler writes the empty 200 responses etc on the HTTP server for unknown domains

Is that behaviour intentional? The commits introducing that behaviour

don't seem to give any reason for this, and this doesn't appear to be documented anywhere

And returning 200 OK for an unhandled request doesn't quite seem right to me; any of 421 Misdirected Request, 404 Not Found, or 500 Internal Server Error seem like better choices, or maybe even TCP RST if you're feeling particularly unfriendly.

This was also discussed in caddyserver/caddy#5729, caddyserver/caddy#4026, and caddyserver/caddy#4173, but even after reading those, I still find this behaviour kinda weird. But without knowing the architecture of the metrics code, if unhandled responses always returned 421, would that make it easier to ignore unconfigured hosts (since you could filter out any 421 responses)?

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.

Random host values showing up in Prometheus metrics

3 participants