nginx: Tell the backend service what port we listen on.

The `$host` nginx variable is _not_ the unadulterated `Host`
header (which would be `$http_host`) -- it is that header, *without
the port*, with a fallback to the `server_name` which processed the
request.

This means that backend services are not aware of the port that the
request came in on, unless they derive that from reading
`nginx_listen_port` in `/etc/zulip/zulip.conf`, or similar.
Specifically, this caused `tusd`, on deploys with non-standard
`nginx_listen_port`, to generate a `Location` header which left off
the port, and as such attempted a CORS check when retrieving metadata
about the just-uploaded file, which failed.

Add the port to the `Host` header we pass to `tusd` and other backend
services.
This commit is contained in:
Alex Vandiver
2025-04-01 15:27:36 +00:00
committed by Tim Abbott
parent bee3c6eb59
commit 4e26705fbc

View File

@@ -2,7 +2,7 @@ proxy_http_version 1.1;
# Clearing the Connection header is required for keepalives from the load balancer
# http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $trusted_x_forwarded_proto;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-Ip $remote_addr;