Bug #3214
closed"X-LIGHTTPD-KBytes-per-second" header not working with HTTP/2
Description
Using this header in a Lua script is a convenient method to limit bandwidth per-request on custom criteria. Though, it works only with http/1.
I've tried to download static file when this header was set at magnet.attract-physical-path-to stage (
r.resp_header["X-LIGHTTPD-KBytes-per-second"] = 100):
1. wget (no http/2 support): bandwidth is limited to ~100kb/s
2. curl --http1.1: bandwidth is limited to ~100kb/s
3. curl --http2: bandwidth is NOT limited
4. download vai Firefox: bandwidth is NOT limited (DevTools shows Version:HTTP/2)
Tested with lighttpd-1.4.71
Is there any way to force this header to work properly with http/2? Or to disable http/2 via config conditionals?
Updated by gstrauss almost 2 years ago
- Status changed from New to Wontfix
- Priority changed from Normal to Low
- Target version deleted (
1.4.xx)
Is there any way to force this header to work properly with http/2?
Not at this time. lighttpd rate limiting is simple and defers sending additional bytes on the connection if too many bytes are send in a second. This simple mechanism is not compatible with the way that HTTP/2 works, and is a known limitation (documented as disabled in lighttpd source code src/h2.c
)
Or to disable http/2 via config conditionals?
server.feature-flags += ("server.h2proto" => "disable")
Updated by blz almost 2 years ago
server.feature-flags += ("server.h2proto" => "disable")
Seems it is not supported inside conditionals:
(../lighttpd-1.4.71/src/configfile-glue.c.332) DEPRECATED: do not set server options in conditionals, variable: server.modules
I'm struggling trying to keep http/2 on globally but turn it off for particular path/domain/whatever for the bandwidth limiting purposes
Updated by gstrauss almost 2 years ago
HTTP/2 is negotiated during TLS negotiation via TLS ALPN, which is before an encrypted request is received. That is why "server.h2proto"
is in the global configuration settings of server.feature-flags
, and is not a per-request conditional.
lighttpd is very lightweight. For your use, you might run a separate, second instance of lighttpd behind your main instance of lighttpd. The main instance of lighttpd can support HTTP/2 and use mod_proxy to reverse proxy specific requests to your backend instance of lighttpd. On the backend instance of lighttpd, you can disable HTTP/2, although that is not necessary at the moment since lighttpd mod_proxy currently always makes HTTP/1.1 requests to HTTP backends.
(../lighttpd-1.4.71/src/configfile-glue.c.332) DEPRECATED: do not set server options in conditionals, variable: server.modules
That is a different error. Do not put server.modules
inside a conditional in lighttpd.conf.
Also available in: Atom