I have a http2 server but by default it responds http1 requests.
I want to stop my server responding to http1 requests?
Most browsers might use alpn or npn. is there a possibility to advertise only http2 ? or a custom list of application protocols ?
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:
…so that it says:
This will prevent it from advertising HTTP/1.1 via ALPN.
Then add this code to the beginning of the
ServeHTTP
method:This will immediately close the connection without sending headers if any protocol earlier than HTTP/2 is used.