- tune.h2.be.max-concurrent-streams
- tune.h2.be.max-frames-at-once
- tune.h2.be.rxbuf
+ - tune.h2.fe.enabled
- tune.h2.fe.glitches-threshold
- tune.h2.fe.initial-window-size
- tune.h2.fe.max-concurrent-streams
See also: tune.h2.be.initial-window-size, tune.h2.fe.rxbuf, http-reuse.
+tune.h2.fe.enabled { on | off }
+ Enables ('on') or disables ('off') HTTP/2 on all frontends. The default is
+ 'on'. This is meant as an emergency kill-switch to instantly stop serving
+ HTTP/2 to clients (e.g. in case of a problem in the HTTP/2 stack) without
+ having to modify every "bind" line. When set to 'off':
+ - "h2" is removed from the ALPN of "bind" lines and crt-list entries,
+ whether it comes from the default ALPN list or from an explicit "alpn"
+ setting. When "h2" was the only protocol listed, this is equivalent to
+ "no-alpn". Clients offering other protocols such as "http/1.1" will
+ negotiate them instead, and those offering only "h2" will get no ALPN
+ at all, hence will be processed as HTTP/1;
+ - "option disable-h2-upgrade" is implicitly set on all frontends, so that
+ HTTP/1 connections starting with the HTTP/2 preface are not upgraded to
+ HTTP/2 anymore and receive a 405 error;
+ - incoming connections which would still be processed by the HTTP/2
+ multiplexer (e.g. on "bind" lines forcing "proto h2", or an "h2" chosen
+ via NPN) are immediately closed.
+
+ Outgoing HTTP/2 connections to servers are not affected, since these are
+ only enabled by explicit configuration. Since explicit "alpn" settings are
+ adjusted when they are parsed, this setting must appear in the global
+ section before the proxies, which is normally the case.
+
+ See also: "option disable-h2-upgrade", "alpn", "no-alpn", "proto"
+
tune.h2.fe.glitches-threshold <number>
Sets the threshold for the number of glitches on a frontend connection, where
that connection will automatically be killed. This allows to automatically
#define GTUNE_NO_TG_FD_SHARING (1U<<31)
/* Global tuning options for tune.options2, since tune.options is full */
+#define GTUNE2_DISABLE_H2_FE (1U<<0)
/* subsystem-specific debugging options for tune.debug */
#define GDBG_CPU_AFFINITY (1U<< 0)
return -1;
}
}
+ else if (strcmp(args[0], "tune.h2.fe.enabled") == 0) {
+ /* parsed here so that it is accepted even without USE_H2 */
+ if (strcmp(args[1], "on") == 0)
+ global.tune.options2 &= ~GTUNE2_DISABLE_H2_FE;
+ else if (strcmp(args[1], "off") == 0)
+ global.tune.options2 |= GTUNE2_DISABLE_H2_FE;
+ else {
+ memprintf(err, "'%s' expects 'on' or 'off'.", args[0]);
+ return -1;
+ }
+ }
else if (strcmp(args[0], "tune.glitches.kill.cpu-usage") == 0) {
if (*(args[1]) == 0) {
memprintf(err, "'%s' expects a numeric value between 0 and 100", args[0]);
{ CFG_GLOBAL, "tune.disable-zero-copy-forwarding", cfg_parse_global_tune_forward_opts },
{ CFG_GLOBAL, "tune.fd.tables", cfg_parse_global_tune_opts, KWF_EXPERIMENTAL },
{ CFG_GLOBAL, "tune.glitches.kill.cpu-usage", cfg_parse_global_tune_opts },
+ { CFG_GLOBAL, "tune.h2.fe.enabled", cfg_parse_global_tune_opts },
{ CFG_GLOBAL, "tune.http.cookielen", cfg_parse_global_tune_opts },
{ CFG_GLOBAL, "tune.http.logurilen", cfg_parse_global_tune_opts },
{ CFG_GLOBAL, "tune.http.maxhdr", cfg_parse_global_tune_opts },
ret = ssl_sock_parse_alpn(args[cur_arg + 1], &conf->alpn_str, &conf->alpn_len, err);
if (ret)
memprintf(err, "'%s' : %s", args[cur_arg], *err);
+ else if (global.tune.options2 & GTUNE2_DISABLE_H2_FE)
+ alpn_remove_token(conf->alpn_str, &conf->alpn_len, ist("h2"));
return ret;
#else
memprintf(err, "'%s' : library does not support TLS ALPN extension", args[cur_arg]);
TRACE_ENTER(H2_EV_H2C_NEW);
+ /* "tune.h2.fe.enabled off" refuses any frontend H2 connection that
+ * could still reach us (e.g. "proto h2", or "h2" negotiated via NPN).
+ * Nothing was touched yet so we can leave without any cleanup.
+ */
+ if (!conn_is_back(conn) && (global.tune.options2 & GTUNE2_DISABLE_H2_FE)) {
+ TRACE_ERROR("H2 disabled on frontends", H2_EV_H2C_NEW|H2_EV_H2C_END|H2_EV_H2C_ERR, conn);
+ return -1;
+ }
+
h2c = pool_alloc(pool_head_h2c);
if (!h2c)
goto fail_no_h2c;
#include <haproxy/quic_tune.h>
#include <haproxy/server-t.h>
#include <haproxy/signal.h>
+#include <haproxy/ssl_utils.h>
#include <haproxy/stats.h>
#include <haproxy/stconn.h>
#include <haproxy/stream.h>
char *err = NULL;
int i;
+ /* "tune.h2.fe.enabled off" implies "option disable-h2-upgrade" */
+ if ((px->cap & PR_CAP_FE) && (px->mode == PR_MODE_HTTP) &&
+ (global.tune.options2 & GTUNE2_DISABLE_H2_FE))
+ px->options2 |= PR_O2_NO_H2_UPGRADE;
+
/* check and reduce the bind-proc of each listener */
list_for_each_entry(bind_conf, &px->conf.bind, by_fe) {
int mode = conn_pr_mode_to_proto_mode(px->mode);
}
#endif /* TLSEXT_TYPE_application_layer_protocol_negotiation */
+ if ((global.tune.options2 & GTUNE2_DISABLE_H2_FE) && px->mode == PR_MODE_HTTP && bind_conf->ssl_conf.alpn_str)
+ alpn_remove_token(bind_conf->ssl_conf.alpn_str, &bind_conf->ssl_conf.alpn_len, ist("h2"));
if (px->mode == PR_MODE_HTTP && global.tune.bufsize < 16384) {
#ifdef OPENSSL_NPN_NEGOTIATED