Caddy block requests on port 80 from non browser clients

Caddy simply does not serve HTTP, by default. Caddy is HTTPS by default. And HTTP->HTTPS redirects are enabled unless you explicit turn it off. The redirect happen quietly unless you enable access logs for the HTTP server, which you can do like this:

:80 {
	log
}

To see that Caddy is redirecting, just do this:

$ curl -v http://myhost.it
*   Trying 127.0.0.1:80...
* Connected to myhost.it (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: myhost.it
> User-Agent: curl/7.81.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 308 Permanent Redirect
< Connection: close
< Location: https://myhost.it/
< Server: Caddy
< Date: Thu, 08 Aug 2024 08:57:30 GMT
< Content-Length: 0
< 
* Closing connection 0
*

The Location header is the redirect. You can follow the redirect with curl -vL

1 Like