[Solved] Force HTTP2

Added by JulianGro 4 months ago

Hello, I would like to disable http1.0 and http1.1 in order to force the client to use http2.
Is this possible with lighttpd? The server.protocol-http11 option as shown in doesn't seem to work (doesn't take anything, not even enable).

I am on lighttpd/1.4.59 (ssl) on Debian Bullseye.

Reason for wanting to force http2 is that I want to 100% make sure that my client is using http2 to test support and performance.

Replies (4)

RE: Force HTTP2 - Added by gstrauss 4 months ago

There is no way to "force" clients to upgrade to HTTP/2. (That is a general statement and not limited to lighttpd.)

Clients supporting HTTP/2 should attempt HTTP/2 with "h2" in ALPN during TLS negotiation, or can attempt Upgrade: h2c with HTTP/1.1.


For server.protocol-http11, the doc was a bit misleading and I have updated it. The doc should say server.protocol-http11 = "disable" or server.protocol-http11 = "enable"
For historical misbehaving clients, server.protocol-http11 = "disable" disables HTTP/1.1, forcing HTTP/1.0

server.feature-flags += ( "server.h2proto" => "disable" ) would disable HTTP/2

If you disable both HTTP/1.1 and HTTP/2, that leaves only HTTP/1.0

RE: Force HTTP2 - Added by JulianGro 4 months ago

Ah. So one needs to write "enable" or "disable" instead of enable or disable.

I guess your answer takes care of my question.

RE: [Solved] Force HTTP2 (nope: controlled by client) - Added by gstrauss 4 months ago

You could patch lighttpd in a couple lines of code to reject requests that are not HTTP/2, but that would not force the clients to use HTTP/2. Instead, it would only send an error to the request. There is prior art which suggests 426 Upgrade Required:

Perhaps I'll add a feature flag for that to lighttpd.

RE: [Solved] Force HTTP2 (nope: controlled by client) - Added by gstrauss 4 months ago

If you want to intercept requests and reject non-HTTP/2 requests with 426 Upgrade Required, then you can do so using mod_magnet and checking SERVER_PROTOCOL lua:

Check for lighty.req_env["SERVER_PROTOCOL"] != "HTTP/2.0"