In Caddy, if you're comfortable modifying the source code, you can make the following changes in caddyhttp/httpserver/server.go
.
Change the line that says:
var defaultALPN = []string{"h2", "http/1.1"}
…so that it says:
var defaultALPN = []string{"h2"}
This will prevent it from advertising HTTP/1.1 via ALPN.
Then add this code to the beginning of the ServeHTTP
method:
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if !r.ProtoAtLeast(2, 0) {
if hj, ok := w.(http.Hijacker); ok {
conn, _, err := hj.Hijack()
if err == nil {
conn.Close()
}
}
return
}
…
}
This will immediately close the connection without sending headers if any protocol earlier than HTTP/2 is used.