mirror of
https://github.com/element-hq/synapse.git
synced 2026-10-23 23:53:58 +00:00
Remove $server_port from the Host header in the nginx reverse proxy example (#20391)
Fixes #19583 The nginx example in `docs/reverse_proxy.md` sets `proxy_set_header Host $host:$server_port;`. The server block listens on 443, so nginx sends `Host: matrix.example.com:443`. With `public_baseurl: https://matrix.example.com/`, the request URI never starts with `public_baseurl`, and `SsoRedirectServlet` keeps redirecting to itself. That breaks SSO even when the internal and external ports are the same. The line came in with #17994. This switches the example to `proxy_set_header Host $host;`, as @anoadragon453 recommended in #18359. I added a short comment for setups where clients use a non-default port: use `$http_host` and put that port in `public_baseurl`. The setup in #18359 (external port 50080) needs that variant. I left `docker/conf-workers/nginx.conf.j2` alone. Its listener port matches `public_baseurl`, so `$host:$server_port` is right there. This is a docs-only change, so there are no tests. Thanks to @shibotto for reporting this and for pointing at the fix. ### Pull Request Checklist <!-- Please read https://element-hq.github.io/synapse/latest/development/contributing_guide.html before submitting your pull request --> * [x] Pull request is based on the develop branch * [x] Pull request includes a [changelog file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog). The entry should: - Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from `EventStore` to `EventWorkerStore`.". - Use markdown where necessary, mostly for `code blocks`. - End with either a period (.) or an exclamation mark (!). - Start with a capital letter. - Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry. * [x] [Code style](https://element-hq.github.io/synapse/latest/code_style.html) is correct (run the [linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
This commit is contained in:
1 parent
7ea942a5fe
commit
4853cd4238
2 files changed
+4
-1
No files matched your search
@@ -0,0 +1 @@
|
||||
Remove `$server_port` from the `Host` header in the nginx reverse proxy example, as it can cause an SSO redirect loop.
|
||||
@@ -76,7 +76,9 @@ server {
|
||||
proxy_pass http://localhost:8008;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Host $host:$server_port;
|
||||
# If clients reach Synapse on a non-default port, use `$http_host` instead
|
||||
# so the port is kept, and include that port in `public_baseurl`.
|
||||
proxy_set_header Host $host;
|
||||
|
||||
# Nginx by default only allows file uploads up to 1M in size
|
||||
# Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
|
||||
|
||||
Reference in new issue
Block a user