Website /check endpoint for Caddy/others #468

Closed
opened 2023-01-05 13:37:50 +00:00 by jpds · 5 comments
Contributor

Was reading the Caddy documentation when I came across the "On-Demand TLS" feature:

They recommend that the backend that serves these dynamic FQDNs implement a small /check endpoint that verifies that the site is a valid one to be served:

Whilst a niche usecase (most people would just configure static domains) - could still be good to have the endpoint.

Was reading the Caddy documentation when I came across the "On-Demand TLS" feature: - https://caddyserver.com/docs/automatic-https#using-on-demand-tls They recommend that the backend that serves these dynamic FQDNs implement a small `/check` endpoint that verifies that the site is a valid one to be served: - https://caddy.community/t/serving-tens-of-thousands-of-domains-over-https-with-caddy/11179 Whilst a niche usecase (most people would just configure static domains) - could still be good to have the endpoint.
Author
Contributor

Hmm, just found the authority_to_host() function already seems to listen on :3902's root, testing this out now.

Hmm, just found the `authority_to_host()` function already seems to listen on `:3902`'s root, testing this out now.
Owner

We have /health on the admin API endpoint that is meant exactly for this, does it not work with Caddy ?

We have `/health` on the admin API endpoint that is meant exactly for this, does it not work with Caddy ?
Author
Contributor

Looking at the code in

fn handle_health(&self) -> Result<Response<Body>, Error> {

The /health endpoint seems better suited for an active health check in Caddy: https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#active-health-checks

Whilst the /check endpoint Caddy purposes is more for "is this a valid domain for you to be serving before I request a TLS certificate for it?"

Looking at the code in https://git.deuxfleurs.fr/Deuxfleurs/garage/src/commit/02e8eb167efa1f08d69fe7f8e6192cde726c45aa/src/api/admin/api_server.rs#L80 The `/health` endpoint seems better suited for an active health check in Caddy: https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#active-health-checks Whilst the `/check` endpoint Caddy purposes is more for "is this a valid domain for you to be serving before I request a TLS certificate for it?"
Owner

Thanks, I understand the difference now. This is definitely a valid feature request, we also do ondemand TLS with our custom reverse proxy (Tricot) and are vulnerable to the kind of attack described in the community thread.

It's not clear to me how Caddy transmits the domain name it wants to check to the /check endpoint, does it send the Host header as if it tried to actually access the website?

Also: is it OK for this endpoint to be implemented in the admin API endpoint, or does it have to be on the website endpiont? And can we use a path different than /check?

Thanks, I understand the difference now. This is definitely a valid feature request, we also do ondemand TLS with our custom reverse proxy (Tricot) and are vulnerable to the kind of attack described in the community thread. It's not clear to me how Caddy transmits the domain name it wants to check to the `/check` endpoint, does it send the `Host` header as if it tried to actually access the website? Also: is it OK for this endpoint to be implemented in the admin API endpoint, or does it have to be on the website endpiont? And can we use a path different than `/check`?
lx added the
action
for-newcomers
kind
improvement
labels 2023-01-09 17:20:30 +00:00
Author
Contributor

The PR that added this is at https://github.com/caddyserver/caddy/pull/1939 - it seems to send a domain field at the /check and looks for a 2XX response.

I think the admin API should be used - as a user might create a file called check in their bucket?

The PR that added this is at https://github.com/caddyserver/caddy/pull/1939 - it seems to send a `domain` field at the `/check` and looks for a `2XX` response. I think the admin API should be used - as a user might create a file called `check` in their bucket?
lx closed this issue 2023-01-19 12:33:17 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Deuxfleurs/garage#468
No description provided.