Why your Synapse reverse proxy decides whether clients and federation work
A reverse proxy sits between Synapse and everything that reaches it, so its configuration decides which Matrix traffic arrives and how it is interpreted. Synapse serves the client-server API that Element and other clients use, the server-server federation API that other homeservers use, the media endpoints for uploads and downloads, and the /_synapse/admin API for operators. Each of these paths has different expectations for timeouts, body sizes and headers, and the proxy must route them separately. If you expose Synapse to users or to other servers, you almost always need a proxy in front, typically for TLS termination, certificate renewal and routing several hostnames to one machine. Synapse can listen on its own port without one, which is workable for a lab or a single internal host, but production deployments usually want the proxy handling public connections.
The main decision is which proxy you run. nginx, Caddy and HAProxy can all front Synapse, and the Synapse reverse proxy documentation includes examples for them. nginx and HAProxy use explicit server and location or frontend and backend blocks that you write and test yourself. Caddy uses a shorter site configuration and manages certificates automatically, which reduces moving parts but still needs the same path and header rules. Whichever you choose, confirm that your team can read and change its configuration during an incident and that the proxy's own upgrade and certificate process fits your patch cycle. Also confirm the federation port you will use: Synapse federates on port 8448 by default, and delegation can move that traffic to port 443 for the server name users see. Settle that before you write routing rules, because it changes which listeners the proxy must expose.
How client, federation and admin requests reach Synapse
The diagram starts with clients and remote servers arriving at the public reverse proxy on port 443, with federation traffic on port 8448 if you use that port. The proxy forwards client, media and federation paths to Synapse's internal listener, and forwards the original client address and protocol in forwarded headers. Synapse talks to PostgreSQL on the internal side. The /_synapse/admin path is not forwarded to the internet and stays reachable only from administrator networks. Check that every admin route returns an error from a public address.
Public proxy zone and internal listener, with the admin path limited to administrator networks.
nginx, Caddy or HAProxy: which proxy fits which team
This table compares nginx, Caddy and HAProxy on the points that matter when they front Synapse: body size limits, forwarded headers, HTTP/1.1 to the upstream, the federation port and team skills. Read each row as a question to answer in your own environment, then confirm version-specific behavior against the reverse proxy docs before you commit.
| Point to compare | nginx | Caddy | HAProxy |
|---|---|---|---|
| Body size limit for uploads | Set client_max_body_size, since the default of 1M is below Synapse's 50M max_upload_size default | Set a request body limit in the site block; confirm the directive and value for your Caddy version | Enforce limits in the frontend with tune or http-request rules; confirm the exact option against your HAProxy version |
| Forwarded headers to Synapse | Pass X-Forwarded-For, X-Forwarded-Proto and Host explicitly in the proxy location block | Forwards common headers by default; confirm the headers Synapse expects in its listener settings | Add X-Forwarded-For and related headers with http-request set-header; Synapse must be told to trust them |
| HTTP/1.1 to the upstream | Set proxy_http_version 1.1 so chunked responses stream correctly | Negotiates HTTP/1.1 with the upstream by default; confirm behavior for your transport settings | Use mode http with an HTTP/1.1 backend; confirm keep-alive and chunked handling in your build |
| Federation port 8448 | Add a separate server block or listen directive for 8448 if you do not use delegation to port 443 | Add a second site address for port 8448 or use delegation; confirm the TLS setup for that port | Add a frontend bound to 8448 with its own certificate handling and backend routing |
| Keeping /_synapse/admin private | Restrict the location with allow and deny, or return 404 for the path from the internet | Use a matcher with respond or abort for the admin path; confirm the matcher syntax | Route the path to a deny rule with http-request deny for external sources |
| Certificate handling | Certificates are managed by you or a tool such as certbot; renewal is part of your process | Obtains and renews public certificates automatically for public names | Certificates are loaded from files or a directory; renewal is part of your process |
| Team skills and tooling | Common in many operations teams with existing configuration management | Simple to read and run for small teams; less common in large enterprise standard stacks | Common where teams already run load balancers and need strict traffic control |
| Confirm before you commit | Test the upload limit, header trust and admin block with your Synapse version | Test the same three items and the 8448 listener on your domain | Test the same three items and confirm the HTTP mode on your build |
How to configure the proxy routes for Synapse
This sequence takes a Synapse listener from a bare process to a reverse proxy that serves client, media and federation traffic, passes real client addresses through, accepts uploads at the configured size, and keeps the admin API off the public internet.
Choose the listener layout and federation port
Decide whether federation will run on port 443 through .well-known delegation or on port 8448 directly. Delegation lets user IDs such as @user:example.com be served from a host like matrix.example.com on 443, while Synapse federates on 8448 by default if you do not delegate. Record the chosen layout in writing, along with the Synapse listener port and bind address the proxy will forward to. Confirm the choice against your server name and delegation plan before editing any proxy file. Done when the team has one agreed diagram showing which hostname and port serves clients, media, federation and admin traffic.
Forward client, media and federation paths
Create proxy locations for the client API under /_matrix and /_synapse/client, the media API under /_matrix/media, and the federation API under /_matrix/federation on the listener you chose. Point each location at the Synapse listener over HTTP, typically on localhost. If federation uses port 8448, add a separate server block on that port with TLS. Check the syntax with the proxy's configuration test command, such as nginx -t, caddy validate or haproxy -c, and then fetch /_matrix/client/versions through the proxy. A JSON response listing supported versions confirms the client path reaches Synapse.
Set forwarded headers and client IP handling
Pass Host, X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host to the upstream so Synapse can see the original client address and scheme. In Synapse, the x_forwarded setting must be enabled on the listener that receives proxied traffic, and it should only be enabled when the proxy is the only path to that listener. For Apache, the reverse proxy docs call for nocanon and ProxyPreserveHost to be on. Confirm the result by logging in or making a request through the proxy and checking that Synapse's access log shows the client address rather than the proxy's address.
Raise the body size limit to match uploads
nginx defaults client_max_body_size to 1M, which is far below Synapse's max_upload_size default of 50M, so media uploads fail with a 413 error until you raise the limit. Set client_max_body_size on the media location or server block to match the max_upload_size value in homeserver.yaml, and use the same value on any other proxy in front. Reload the proxy, then upload a file slightly below the configured limit and one slightly above it. The first should succeed and the second should return a clear size error, which confirms both ends agree.
Use HTTP/1.1 to the upstream for chunked responses
Configure the proxy to speak HTTP/1.1 to the Synapse upstream, and clear the Connection header so keep-alive and chunked transfer work correctly. Some long-running sync and media responses are streamed in chunks, and an HTTP/1.0 upstream connection can break them. In nginx this means proxy_http_version 1.1 and a cleared Connection header in the relevant locations. Verify by requesting a long sync with a timeout through the proxy and confirming the response completes without truncation or proxy errors in the error log.
Block the admin API from public routes
Do not forward /_synapse/admin through the public listener. Return a 404 or deny response for that path on every public hostname and port, and restrict any admin access to an internal network, a VPN or a jump host that reaches Synapse directly. The Synapse configuration manual also recommends firewalling the federation listener when it is not needed by peers. Verify by requesting /_synapse/admin/v1/server_version from outside your network through the public hostname and confirming it is refused, then requesting it from the internal path and confirming a valid response.
Confirm end-to-end behavior and log review
Run a final pass with a Matrix client through the public hostname: log in, send a message, join a public room, upload a file and, if federation is enabled, check the federation tester or a request from a peer server. Review the proxy access and error logs for 413, 502 and 504 responses that point to limits or upstream problems. Record the configuration files and the test results so the next upgrade or proxy change can be repeated and checked against the same list. Done when every path in the layout works and the admin check fails from outside.
Proxy-specific settings to get right
nginx is the most common choice in Synapse documentation, and its defaults trip up installs more than anything else. Its request body limit starts at 1M, far below Synapse's default upload limit, so uploads fail with a generic error unless the proxy is adjusted. The settings below belong in the server block that serves your Matrix hostname, and the exact directive names should be checked against the current reverse proxy page before you deploy.
- Body size: Set
client_max_body_sizeto matchmax_upload_sizein Synapse, which defaults to 50M. Raise both together, or the proxy becomes the limit users hit first. - Header forwarding: Pass
Host,X-Forwarded-ForandX-Forwarded-Protowithproxy_set_header, and keepx_forwarded: truein the Synapse listener so client IP addresses appear correctly in logs and rate limits. - Upstream protocol: Set
proxy_http_version 1.1so chunked responses from Synapse pass through intact. - Path matching: Forward
/_matrixand/_synapse/clientto the Synapse listener, and use separate server blocks if you publish federation on port 8448. - Admin block: Return a 404 or deny access for
/_synapse/adminin a location block, so the admin API is never reachable from the public side of the proxy.
After any change, confirm that a large media upload succeeds and that /_synapse/admin returns an error from an outside network.
Caddy handles TLS certificates automatically, which removes one of the largest sources of error in a Synapse setup. Its configuration is shorter than nginx, but it still needs the same Synapse-specific decisions: an upload limit, correct forwarded headers, the right paths and a blocked admin API. Confirm each directive in the Caddy documentation for your installed version, because the names of request limit and matcher options have changed across releases.
- Body size: Set an explicit request body limit in the site block, sized to at least your Synapse
max_upload_size, instead of relying on defaults you have not checked. - Header forwarding: Use
reverse_proxywith its default forwarded headers, and confirm that theX-Forwarded-ForandX-Forwarded-Protovalues reach Synapse and thatx_forwardedis enabled on the listener. - Upstream protocol: Confirm which HTTP version Caddy uses toward the Synapse listener, and test chunked responses such as sync and media downloads rather than assuming they work.
- Path matching: Use
handleblocks to send/_matrix/*and/_synapse/client/*to Synapse, and keep any other path on a separate handler so the matchers stay predictable. - Admin block: Add a matcher for
/_synapse/admin/*that responds with a 404 before the reverse proxy directive runs.
Test the configuration from outside your network, because a block that works on the local host can still be reachable through the public address.
HAProxy is usually chosen when a team already runs it for load balancing or wants fine control over routing in front of several Synapse processes. Its strengths are explicit ACLs and clear timeouts, but nothing about Synapse is configured for you. Every rule that nginx or Caddy handles must be written by hand, and some options depend on how the frontend and backend sections are set up, so check the current HAProxy documentation for each option before relying on it.
- Body size: Enforce the upload limit deliberately, for example by denying requests whose
Content-Lengthis above the value you chose for Synapse'smax_upload_size. Do not assume HAProxy will apply a limit that matches Synapse. - Header forwarding: Use
option forwardforand setX-Forwarded-Protoin the frontend, and confirm that the header names match what the Synapse listener trusts. - Upstream protocol: Run the backend in HTTP mode and confirm that HTTP/1.1 is used toward Synapse, since chunked responses depend on it.
- Path matching: Use ACLs with
path_begto route/_matrixand/_synapse/clientto the Synapse backend, and add a separate frontend or port for federation if you publish it. - Admin block: Create an ACL for
path_beg /_synapse/adminand deny it on the public frontend, so the admin API stays reachable only from an internal path.
When HAProxy sits in front of workers, verify that each route reaches the process type you intended, because a misrouted admin or federation request is easy to miss.
Apache can front Synapse, but it needs options that the other proxies do not. The reverse proxy documentation states that Apache needs nocanon and ProxyPreserveHost turned on, and that mod_security2 is reported to be incompatible with Synapse. Without these settings, requests may be rewritten or the Host header lost, which breaks federation and client discovery in ways that look like server faults.
- Required options: Enable
nocanonon the proxy directive and setProxyPreserveHost on, then check the exact syntax against the Apache documentation for your version. - Web application firewall: Reports indicate mod_security2 conflicts with Synapse. If your security policy requires a WAF, test a dedicated rule set on a staging homeserver before enabling it in production.
- Body size and headers: Set the request body limit and forwarded headers as you would for nginx, and confirm that Synapse receives the expected values.
- Admin block: Deny
/_synapse/adminwith aLocationorRequirerule on the public virtual host.
Confirm your Apache build and modules with a full test of login, sync, media upload and federation before you go live.
Keeping the admin API and internal listeners off the internet
Synapse exposes more than client traffic. The admin API, replication and metrics listeners, and the federation port all need a decision about who can reach them. The cards below cover what to block at the proxy, what to firewall at the host, and what to test before go-live.
Block the admin API at the proxy
Synapse serves its admin API under /_synapse/admin, and it can change users, rooms and media. Your proxy should return a refusal for that path to any client on the public internet, then allow it only from an internal network or VPN address. Check this with an external request to the path after every proxy change, because a catch-all location block can quietly expose it again.
Firewall the federation listener
Synapse federates on port 8448 by default. If you limit federation with federation_domain_whitelist, an empty list disables federation entirely, and the Synapse docs recommend firewalling the federation listener as well. Confirm that the host firewall, not only the proxy, blocks 8448 from networks you do not federate with, and test that a closed port actually refuses connections.
Keep replication and metrics private
Worker deployments add replication listeners, and Synapse can expose metrics endpoints. These carry internal traffic and operational detail, so they should bind to private addresses and never be forwarded by the proxy. Review each listeners entry in your configuration, confirm its bind address, and make sure your proxy routes only the client, federation and well-known paths you intend to publish.
Trust forwarded client addresses only from the proxy
Behind a proxy, Synapse sees the proxy's address unless it reads the forwarded headers. Set x_forwarded on the listener so Synapse trusts X-Forwarded-For from the proxy. Because any client can send that header, the listener must not accept direct connections from the internet, or an attacker can spoof the address that Synapse logs and uses for rate limiting.
Test WAF and ModSecurity rules
Web application firewalls and ModSecurity rule sets can block the request patterns Matrix clients and federation send, including large JSON bodies and media uploads. The Synapse reverse proxy docs report that mod_security2 is incompatible with Synapse. If your security team requires a WAF, plan a test run of sync, login, media upload and federation with the rules enabled, and document each exception you add.
Proxy requirementsQuestions teams ask before configuring Synapse behind a proxy
Can our own team configure Synapse behind a reverse proxy without outside help?
Yes, if your team already runs nginx, Caddy or HAProxy in front of other services and can manage TLS certificates and DNS. The Synapse side is a short list of routes, headers and size limits, and the reverse proxy guide in the Synapse documentation covers the paths that must reach the homeserver. The effort rises when your proxy estate is unusual, when you run several listeners or workers, or when you also need Matrix Authentication Service routes and separate federation endpoints. Ask yourself whether someone on the team has already tested a proxy change against a live Matrix client and a federation tester.
What drives the effort of a Synapse reverse proxy setup?
Four factors shape most of the work:
- Existing proxy estate: a proxy you already operate, with monitoring and config management, is cheaper to extend than a new one.
- Federation policy: whether you serve federation on port 8448, delegate to port 443, or disable federation changes which listeners and firewall rules you write.
- Number of listeners and workers: each listener type and worker route adds a path to test and a place where requests can go to the wrong process.
- TLS setup: certificate issuance, renewal and where TLS terminates all affect how headers reach Synapse.
For the scope and cost of your own case, ask a provider to list each of these factors in a written scope.
What do we need to provide before the proxy work starts?
Prepare these items before anyone edits a proxy configuration:
- DNS records for the Synapse host and any delegated names, pointing at the proxy.
- Certificates that cover every hostname the proxy serves, with a renewal method you control.
- Network access from the proxy to the Synapse listeners and, for federation, a firewall rule that matches your federation policy.
- A test account on the homeserver, plus a second test client, so you can check login, sync, media upload and room join after each change.
Keep a copy of your current proxy configuration so you can roll back quickly.
Is Caddy or nginx easier to use in front of Synapse?
Caddy usually needs less configuration for TLS, because it obtains and renews certificates automatically, which removes a common source of mistakes. nginx gives finer control over body size, buffering and timeouts, and many operators already know it well, so it is often the better fit for an existing estate. Both can forward the required paths and headers. HAProxy suits teams that already use it for load balancing. Choose on the basis of what your team operates and can monitor, and confirm the exact directives against the Synapse reverse proxy documentation for the version you run.
Why do file uploads fail at 1M behind a proxy?
nginx defaults to a request body limit of 1M, while Synapse accepts uploads up to 50M by default through its max_upload_size setting. When a client sends a larger file, nginx rejects the request before it reaches Synapse, and users see a failed upload with no clear message. Set client_max_body_size in nginx to match or exceed max_upload_size in your homeserver configuration. If you change max_upload_size, change the proxy value in the same maintenance window and test with a file close to the limit.
How do we verify that the admin API is blocked from the internet?
Test the blocked path from outside your network, not from inside the proxy host. Request /_synapse/admin through the public hostname and confirm the proxy returns a refusal rather than an admin response. Repeat the test from a network that has no VPN or internal route, and check the proxy access log to confirm the request was denied. Also confirm that the admin paths are reachable only from the networks you have allowed, and that the proxy does not forward them under a different path. Record the results so an auditor or a later change can check them.
When should we ask a partner for help with the proxy?
Ask for outside help when the proxy design touches several services at once, such as MAS routes, workers, a shared ingress controller or an existing gateway that other teams depend on. It also makes sense when you need a documented test plan for a compliance review, or when a federation or upload problem persists after you have checked the headers and size limits. A written scope should name the hostnames, listeners, test cases and deliverables, and it should state who keeps the configuration after handover.
What to confirm in your environment before go-live
A reverse proxy sits between every client and your Synapse listeners, so its behavior matters as much as Synapse's own settings. The cards below list the items to verify against the documentation for your exact Synapse release and your own network before you open the service to users.
Synapse release and listener expectations
Check the header, path and listener expectations in the upgrade notes for the Synapse release you deploy, because proxy rules that worked on an earlier release can break after an upgrade. Confirm which listener serves client traffic, which serves federation, and whether any port is expected to be reached directly. Compare your listeners block with the reverse proxy documentation for that release before go-live.
WAF or load balancer in front
Identify every device between the client and the proxy, including a web application firewall, a cloud load balancer or a CDN. Each layer can alter request bodies, strip headers, cap sizes or time out long syncs, and a web application firewall rule set may block Matrix request patterns. Ask the security team to document each rule that touches the Matrix hostnames and test sync, media upload and federation through the full path.
Certificates and DNS records
Confirm that the certificate covers every hostname that clients, federation peers and Element Web use, and that renewal runs without manual steps. Check that DNS for the server name and the delegated host resolves to the proxy, and that the federation port is reachable from the public internet if you federate. Verify the records and certificate chain from outside your network, not only from inside it.
Upload limits against the media policy
Compare the proxy body size limit with the media upload limit set in Synapse and with your own policy on file size. A proxy limit below the Synapse limit rejects uploads with an error that looks like a Synapse fault. Record both values in your runbook so that a future policy change updates the proxy and the homeserver together.
Synapse configuration manualWhether workers change routing
If you run Synapse workers, the proxy must send each endpoint family to the worker type that handles it, and a single upstream may no longer be enough. Confirm the routing table against the workers documentation for your release, and check which endpoints still go to the main process. Test client sync, messaging, federation and admin paths after every change to the worker layout.
Synapse workers docsWhere proxy mistakes show up later
Proxy mistakes rarely break the first login test. They surface after launch, when real users upload files, when remote servers federate with you, and when someone reads the logs. The most common failures are large media uploads that fail with an error that looks like a Synapse problem, federation requests that time out under load, and logs that show every client as the proxy's own address, which makes rate limiting and abuse investigation unreliable. Another is an admin endpoint that answers from the public internet because a broad location rule matched a path nobody meant to expose. Each of these looks different to users, so teams often chase the wrong component first.
A route review before go-live catches most of these. Walk every location block and list the paths it forwards, the listener port it targets, and whether the path is meant for clients, federation, media or administration. Confirm that /_synapse/admin returns nothing from an outside network, and that the federation listener is reachable only where you intend it to be. Check that the proxy's body size limit matches Synapse's max_upload_size, and that the client address Synapse records comes from the forwarded headers your proxy sets, with trusted proxy addresses declared in Synapse's listener settings. Confirm these details against the current Synapse reverse proxy documentation for the version you run.
A test plan turns the review into evidence. Upload a file close to the configured limit and one just over it, and confirm the error text and the status code are what you expect. Run a federation test from a second server, and watch for timeouts during a larger room join. Make an admin request from outside your network and confirm it is refused. Finally, check the access log for a real client address on a sample login. Repeat these checks after every proxy change and after every Synapse upgrade, since route lists and default limits can change between releases. Record the results so your security and operations teams can review them without rerunning the work.
How DeployOpen scopes and delivers a Synapse proxy setup
This sequence turns an unclear proxy question into a written scope, a tested configuration on your own infrastructure, and handover documentation your team can operate after the work ends.
Agree the written scope
Before any work starts, DeployOpen and your team agree in writing which proxy product, hostnames, listeners and admin restrictions are in scope, who approves changes, and what the deliverables are. Your team confirms the Synapse version it runs and the topology it uses, such as a single process or workers. The step is complete when the scope document is signed off and the open questions about certificates, load balancers and network zones have named owners.
Review the existing proxy estate
DeployOpen reviews the proxies, load balancers and TLS terminations already in front of Synapse, including any Apache or mod_security layers that sit in the request path. The review checks which paths reach Synapse, how forwarded headers are set, the configured body size limit, and whether the federation listener on port 8448 is reachable from where it should be. The output is a short gap list that your team can accept or reject before configuration starts.
Configure routes and forwarded headers
DeployOpen writes the proxy configuration inside your infrastructure, using your certificates and your deployment tooling where you have it. Client and federation paths are forwarded to the Synapse listeners, forwarded headers are set so Synapse sees the original client address and protocol, and the body size limit is raised to match Synapse's upload setting. HTTP/1.1 is used for upstream connections so chunked responses are handled correctly. The step closes when the configuration is committed to your repository and reviewed by your team.
Test client and federation routes
DeployOpen runs requests against each forwarded path from the networks that should reach it, and from networks that should not. Checks cover client API calls, media upload at a size near the limit, long-running responses, and federation requests to the listener. Results are recorded with the expected and actual status for each route. The step is complete when every route passes or has a documented, approved exception.
Verify admin path restrictions
DeployOpen confirms that the /_synapse/admin path is not reachable from the public internet, and that it is only served to the administrative networks or identity controls your team specifies. The test is run from outside your network and from an approved admin location, and the results are kept as evidence. Any path that is reachable from the wrong place is fixed and retested before the step is marked complete.
Hand over runbooks and configuration
DeployOpen delivers the final configuration, a route map, the test scripts and results, the restriction list for admin and replication paths, and runbooks for certificate renewal, configuration changes and rollback. Your administrators walk through the runbooks, and the handover is recorded against the agreed scope. The output is a set of documents your own team can operate without DeployOpen present.
Retain ongoing support if needed
After handover, your team may keep DeployOpen on a retainer for proxy changes, Synapse upgrades that alter proxy requirements, and periodic retesting of routes and admin restrictions. The retainer scope, response expectations and fees are agreed in writing, and nothing in the retainer is required to operate the handed-over setup. Ask for the retainer terms in the quote alongside the fixed-scope proposal.

