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 <alexmv@zulip.com>
This commit is contained in:
n0099 2023-07-25 13:31:50 +08:00 committed by Alex Vandiver
parent befcb46ba3
commit 2b1d250154
2 changed files with 2 additions and 2 deletions

View File

@ -483,7 +483,7 @@ that your Zulip server sits at `https://10.10.10.10:443`; see
location / { location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host; proxy_set_header Host $host;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_buffering off; proxy_buffering off;
proxy_read_timeout 20m; proxy_read_timeout 20m;

View File

@ -44,7 +44,7 @@ def write_updated_configs() -> None:
sharding_json_f.write("{}\n") sharding_json_f.write("{}\n")
return 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") nginx_sharding_conf_f.write(" default http://tornado9800;\n")
shard_map: Dict[str, Union[int, List[int]]] = {} shard_map: Dict[str, Union[int, List[int]]] = {}
shard_regexes: List[Tuple[str, Union[int, List[int]]]] = [] shard_regexes: List[Tuple[str, Union[int, List[int]]]] = []