MINOR: global: add tune.h2.fe.enabled to disable HTTP/2 on frontends
In case of trouble in the HTTP/2 stack, users currently have no simple way
to stop serving HTTP/2 to clients: the default ALPN of SSL "bind" lines
silently advertises "h2", explicit "alpn" settings have to be edited on
every "bind" line and crt-list entry, HTTP/1 connections starting with the
H2 preface are upgraded unless "option disable-h2-upgrade" is set
everywhere, and "proto h2" binds have to be found and changed.
This patch adds a new global setting, "tune.h2.fe.enabled", which defaults
to "on" and is stored as GTUNE2_DISABLE_H2_FE in tune.options2. When set
to "off", three layers are touched:
- h2 is prevented from being configured: "h2" is removed from explicit
alpn via alpn_remove_token() when proxies are finalized, as well as
from crt-list entries. The default ALPN (or the one derived from
"proto") is processed the same way in proxy_finalize(). If "h2" is
the only protocol, the string ends up empty, which is equivalent to
"no-alpn". Nothing changes on the data path: the SSL contexts are
created afterwards from the final strings.
- h1 is prevented from upgrading to h2 in proxy_finalize(), which sets
PR_O2_NO_H2_UPGRADE on HTTP frontends, so that the H1 mux responds
a 405 to the H2 preface as with "option disable-h2-upgrade",
indicating that method "PRI" is rejected;
- finally, h2_init() refuses frontend new connections, so anything that
cannot be fixed above (e.g. "proto h2" or NPN) is immediately closed.
The keyword is parsed in cfgparse-global.c so that it remains accepted
when building without USE_H2. Backend connections are not affected since
the main purpose it to provide an emergency switch to protect against an
exploitable flaw for example with limited impact. This may change later
with a new option if deemed useful.
One limitation is that the keyword must be seen before parsing "alpn"
keyword on "bind" lines, which is normally granted since "global" section
isn't supposed to appear after proxies. In any case, any residual case
would still be blocked by h2_init(), by closing the connection.
The goal is to offer an emergency kill-switch, so this is meant to be
backported to stable versions, along with the two preceding commits:
MINOR: ssl: add alpn_remove_token() to drop a protocol from an ALPN string
MINOR: global: add tune.options2 to host new GTUNE2_* flags