From 2b1d25015404f5514705299543c599e861514065 Mon Sep 17 00:00:00 2001 From: n0099 Date: Tue, 25 Jul 2023 13:31:50 +0800 Subject: [PATCH] nginx: Switch from `$host` to `$http_host` for HTTP/3 compatibility. nginx sets the value of the `$http_host` variable to the empty string when using http/3, as there is technically no `Host:` header sent: https://github.com/nginx-quic/nginx-quic/issues/3 Users with a browser that support http/3 will send their first request to nginx with http/2, and get an expected HTTP 200 -- but any subsequent requests will fail with am HTTP 400, since the browser will have upgraded to http/3, which has an empty `Host` header, which Zulip rejects. Switch to the `$host` variable, which works for all HTTP versions. Co-authored-by: Alex Vandiver --- docs/production/deployment.md | 2 +- scripts/lib/sharding.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/production/deployment.md b/docs/production/deployment.md index f72120dab8..3cfcb2f18c 100644 --- a/docs/production/deployment.md +++ b/docs/production/deployment.md @@ -483,7 +483,7 @@ that your Zulip server sits at `https://10.10.10.10:443`; see location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header Host $http_host; + proxy_set_header Host $host; proxy_http_version 1.1; proxy_buffering off; proxy_read_timeout 20m; diff --git a/scripts/lib/sharding.py b/scripts/lib/sharding.py index 878dc86094..6107a54d36 100755 --- a/scripts/lib/sharding.py +++ b/scripts/lib/sharding.py @@ -44,7 +44,7 @@ def write_updated_configs() -> None: sharding_json_f.write("{}\n") return - nginx_sharding_conf_f.write("map $http_host $tornado_server {\n") + nginx_sharding_conf_f.write("map $host $tornado_server {\n") nginx_sharding_conf_f.write(" default http://tornado9800;\n") shard_map: Dict[str, Union[int, List[int]]] = {} shard_regexes: List[Tuple[str, Union[int, List[int]]]] = []