Why teams put NGINX in front of Mattermost
Put NGINX in front of Mattermost when you want one controlled edge for certificates, public ports and request handling, and keep the application off the public network. Mattermost runs as a single Linux binary with PostgreSQL as its database, so the server does not provide a managed edge of its own. The proxy accepts browser and client traffic on ports 80 and 443, terminates TLS, redirects plain HTTP to HTTPS, and forwards requests to the Mattermost listener. Teams usually settle this early because the same edge then handles certificate renewal, firewall rules and log collection for every service behind it. Changing the edge later means revisiting certificates, firewall rules and client URLs at the same time.
A proxy is not required for every site. Mattermost can terminate TLS on the server itself, and the sibling guidance on TLS setup explains when that fits. A reverse proxy becomes the better default when you run more than one application node, need a load balancer in front of them, must use a certificate from your internal authority or a managed renewal process, or want rate limiting and access controls at the edge. High availability is a separate constraint: the Mattermost high availability cluster deployment docs describe redundant load balancers as part of the design, and that architecture is available only on the Enterprise and Enterprise Advanced plans. Confirm your plan and node count before you choose the edge design.
Two behaviors need explicit proxy configuration. Live messaging depends on long-lived WebSocket connections, so the proxy must pass the upgrade headers through to Mattermost and must not apply idle timeouts that drop connected clients. The second concern is logging: Mattermost does not log file uploads and downloads, so the NGINX access logs become a primary record of file transfer activity. Decide before go-live who owns those logs, how long they are kept, and whether they hold personal data that your retention policy covers. Confirm the exact header and timeout settings against the documentation for the Mattermost release you run, because those values depend on the version.
Where should TLS terminate for your install
A small single-server install can let Mattermost handle TLS itself, using its built-in Let's Encrypt support or a certificate you supply. This keeps the moving parts low: one host, one set of certificates, and one place to troubleshoot. The trade-off is that the application server owns the certificate lifecycle and listens on the public port, which leaves less room for a separate edge layer.
- Certificate ownership: The Mattermost server renews its own Let's Encrypt certificate, so someone must confirm that renewal succeeds and that port 80 stays reachable for the challenge.
- Port binding: The server binds directly to port 443, which requires the service account to have that privilege or a capability granted to the binary.
- Fewer hops: Traffic reaches the application without an intermediate proxy, which simplifies debugging of WebSocket and upload issues.
- Limited edge features: Request logging of file uploads and downloads, rate limiting and header policy are harder to add without a proxy in front.
- Migration path: Moving to a proxy later means changing the listen address, the site URL and the certificate handling together.
Before go-live, confirm that the certificate renews without manual steps and that your security team accepts the server holding the private key directly.
Once an install serves more users, most teams terminate TLS on a reverse proxy such as NGINX and forward plain HTTP to the Mattermost server on a private interface. The proxy then owns certificates, cipher policy, redirects and access logs, while the application stays on an internal address. This split also lets your platform team manage certificates with the same tooling used for other internet-facing services.
- Central certificate management: Certificates and key rotation sit with the team that already operates your other public services.
- Consistent policy: Protocol versions, cipher suites and HSTS headers are set once at the edge.
- Logging at the edge: The proxy can record request paths for uploads and downloads that the application server does not log.
- Internal binding: The Mattermost listener moves off the public interface, so ports exposed to the network are limited to the proxy.
- Site URL alignment: The public site URL in the server settings must match the hostname users see, or links and WebSocket connections break.
Confirm which team owns the certificate renewal process and that the proxy and application agree on the public hostname before cutover.
In a high availability cluster, the proxy becomes part of the load balancer layer that distributes requests across several application nodes. Mattermost documents high availability as redundant application servers, redundant database servers and redundant load balancers, and that setup is available only on the Enterprise and Enterprise Advanced plans. TLS termination here has to fit the cluster design, so the decision is made with the load balancer topology in mind rather than per node.
- Termination at the balancer: Certificates usually live on the load balancer tier, with traffic between the balancer and nodes on a private network.
- Redundant balancers: Each balancer needs the same certificate and configuration, so changes must be applied to every instance.
- Session and WebSocket routing: The balancer must pass WebSocket connections through correctly and keep clients on nodes that handle their sessions.
- Shared file storage: Every node mounts the same S3-compatible or NAS storage, which the proxy layer does not replace.
- Plan check: Confirm the cluster plan and the balancer product with the vendor before you commit to a design.
Review the cluster diagram with your network team and confirm which layer holds the certificates before building the balancer tier.
How client requests reach Mattermost through NGINX
Requests start at browsers, desktop apps and mobile apps, which connect to NGINX on port 80 or 443. Port 80 requests are redirected to HTTPS, and TLS ends at NGINX. Chat traffic that needs live updates uses a WebSocket upgrade that NGINX must pass through to the Mattermost application nodes. Those nodes read and write the PostgreSQL database and share file storage for uploads. Check the log points where NGINX records each upload and download, since the Mattermost server does not log file transfers itself.
Client traffic through NGINX to Mattermost nodes, database and shared storage.
NGINX directives and settings and when each fits
This table compares the NGINX settings that shape a Mattermost reverse proxy, from certificates and redirects to WebSocket handling, load balancing, uploads, timeouts and logging. Read each row for the situation where the setting applies, then confirm the exact values against the Mattermost documentation for your release before you copy anything into production.
| Setting | When it fits | What to confirm in the Mattermost docs |
|---|---|---|
| TLS certificate source | Terminating TLS at NGINX suits larger installs that already run a proxy tier and want certificate renewal in one place. Choose a public certificate authority, an internal CA, or Let's Encrypt based on your trust model. | Confirm which TLS settings Mattermost expects when it sits behind a proxy, and whether the server's own TLS listener should stay disabled. |
| HTTP to HTTPS redirect | Use a plain port 80 server block that returns a permanent redirect to HTTPS for every request. This fits any deployment where users may type the bare hostname. | Confirm the public site URL in the Mattermost configuration matches the HTTPS address so links and redirects stay consistent. |
| WebSocket upgrade headers | Required for real-time messaging, typing indicators and presence. Set the upgrade and connection headers on the WebSocket path so the connection is not dropped to polling or broken. | Confirm the WebSocket path and header requirements for your release, since the docs define which location blocks need the upgrade settings. |
| Upstream load balancing method | A simple single upstream fits one application server. Multiple application servers in a high availability cluster need an upstream group, and the balancing method should match how your nodes are sized. | Confirm that multi-node operation is only supported on Enterprise and Enterprise Advanced plans, and that every node shares file storage and configuration. |
| Sticky sessions | Session affinity can simplify troubleshooting on a small pool, but it reduces the benefit of load distribution if one node fails. Weigh it against how the cluster handles session state on failover. | Confirm whether Mattermost requires or recommends session affinity for your version and whether WebSocket connections need the same treatment. |
| Client body size for file uploads | Raise the maximum request body size to match the file size limit you set in Mattermost. A value below the application limit causes uploads to fail at the proxy with errors users see as generic failures. | Confirm the file size limit configured in Mattermost and make the proxy value match it, including any limits applied at a load balancer in front of NGINX. |
| Proxy timeouts | Longer read and send timeouts keep large uploads, downloads and long-lived WebSocket connections open. Short defaults suit only light, text-only traffic. | Confirm the timeout guidance for file transfers and WebSocket connections, and test with your largest expected attachment before go-live. |
| Custom log format | A custom format that records request path, status, bytes sent and request time captures file uploads and downloads that the Mattermost server does not log. Add fields that your audit and incident response process needs, and keep query strings and tokens out of the log. | Confirm which events Mattermost logs itself so the proxy log complements rather than duplicates them, and check log retention and access controls with your compliance team. |
Setting up NGINX in front of Mattermost, step by step
This sequence takes a Mattermost server from a plain listening port to a TLS-terminated, WebSocket-capable proxy with logs that record file transfers, and confirms each layer works before go-live.
Confirm the site URL and listening port
The platform engineer checks the Mattermost site URL in the System Console and the ListenAddress value in config.json, then records the internal port Mattermost binds to, commonly 8065 on a default install. The proxy must forward to that port and users must reach the proxy under the exact hostname in the site URL. Done when a local request to the internal port returns the Mattermost login page and the site URL matches the public hostname you plan to publish. Confirm the port numbers with your own install, since they depend on your configuration.
Obtain and install the TLS certificate
The network or security team obtains a certificate for the public hostname, either from your internal certificate authority or a public authority, and installs the full chain and private key on the NGINX host with restricted file permissions. Private keys should never be readable by general users. Done when
nginx -treports the configuration syntax is valid after the certificate paths are added and the certificate chain validates from a client that trusts your authority. Confirm the certificate issuance process and renewal ownership with your security team before this step closes.Write the server block with redirect and proxy headers
The platform engineer creates one server block that listens on port 80 and returns a permanent redirect to HTTPS, and a second block on port 443 that terminates TLS and forwards requests to the Mattermost port with
proxy_set_headerentries for Host, X-Real-IP, X-Forwarded-For and X-Forwarded-Proto. Mattermost relies on these headers to build correct links and apply client address logic. Done whencurl -I returns a redirect to the https address andcurl -I reaches Mattermost through the proxy without certificate warnings.Enable WebSocket forwarding
The platform engineer adds the Upgrade and Connection headers for the WebSocket path, usually with a map block so that plain HTTP requests keep their normal behavior, and sets HTTP/1.1 as the proxy protocol. Real-time messages, typing indicators and presence depend on this connection. Done when a browser session stays connected for several minutes and a message sent from a second account appears without a page reload. Check the Mattermost deployment documentation for the exact WebSocket location your version expects.
Set upload size and timeouts
The platform engineer sets
client_max_body_sizeto a value at least as large as the file upload limit configured in Mattermost's file settings, and sets proxy read and send timeouts so large uploads and downloads are not cut off. A mismatch between NGINX and Mattermost limits causes uploads to fail with errors that look like application faults. Done when a file slightly below the Mattermost limit uploads successfully and a file above the NGINX limit fails at the proxy with a 413 response recorded in the access log. Confirm the Mattermost file size setting with your administrators first.Configure the log format for file transfers
The platform engineer defines a custom
log_formatthat records the request method, path, status, bytes sent, request time, user agent and the forwarded client address, then applies it to the access log for the Mattermost server block. Mattermost does not log every file upload or download, so this proxy log is often the only record of transfer volume and timing. Done when an upload and a download each produce one access log line showing the file path, status 200 or 201, and bytes transferred. Confirm your log retention and privacy requirements, since these logs contain user and file identifiers.Reload NGINX and verify in the browser
The platform engineer runs
nginx -t, reloads NGINX without a full restart, and then signs in through a browser in a private window to check login, channel loading, real-time updates and the padlock indicator for the certificate. Done when every browser test passes and the NGINX error log shows no new entries for the test session. Record the reload time and configuration version in your change log.Verify the desktop client and a test file transfer
The platform engineer signs in with the Mattermost desktop client using the same hostname, confirms that real-time messages arrive, and then uploads a test file in a private channel, opens it, downloads it and compares the checksum with the original. The engineer then checks the NGINX access log for matching upload and download lines. Done when the checksums match, the log lines show the expected paths and status codes, and the desktop client reconnects after the network interface is briefly toggled. Keep the test file and results with the change record.
Why proxy logs capture file uploads and downloads the server does not
The Mattermost server records what its own application logic decides to record, and file transfers are a common blind spot. An upload or download is a plain HTTP request to a file endpoint, so an NGINX access log in front of Mattermost can capture the request method, path, status code, response size and timing for every transfer, including ones the application never writes to its own log. That record answers questions such as who pulled a large export, how many uploads failed, and when a bulk download started. Before relying on it, the team should confirm in its own environment what the Mattermost server logs at its configured levels, because the answer varies with settings and version and should not be assumed from documentation alone.
Access logs are also personal data, and the URL is the sensitive part. File paths in Mattermost can include identifiers that link a request to a team, channel or user, and query strings may carry tokens in some integration patterns. Decide before go-live which fields the NGINX log_format will record, whether client IP addresses are kept and for how long, and who can read the files. Logging $request_uri in full versus a trimmed $uri is a direct trade-off between investigative value and exposure. Set a retention period in logrotate that matches your privacy notice and legal hold obligations, and restrict read access to the log directory.
Treat the proxy log as a control you must test, not a setting you assume works. Upload a test file, download it, and confirm that the access log line appears with the expected status and byte count, then confirm that the same request does not appear in the Mattermost logs at your chosen level. Check that large uploads are not truncated by client_max_body_size, which causes 413 responses that are easy to miss without this check. Ship the proxy logs to the same central system as the application logs, and document the field meanings so that a security or compliance reviewer can read them without help from the platform team.
Security and operational risks at the proxy layer
The reverse proxy is the only component that sees every request before Mattermost does, so its settings decide which client addresses, certificates, ports and log entries the server trusts. The cards below cover the decisions that most often go wrong and the checks to run before go-live and after each upgrade.
Trust of forwarded client IP and headers
Mattermost uses headers such as X-Forwarded-For and X-Real-IP set by NGINX to record client addresses. If NGINX passes through headers supplied by the browser, a client can spoof its address in audit records and rate limits. Set these headers in the proxy itself, overwrite any incoming values, and confirm that only your proxy addresses are trusted by the application. Test with a request carrying a forged header and check the resulting audit entry.
TLS protocol and certificate renewal
The proxy, not Mattermost, usually negotiates TLS with users, so protocol versions and cipher suites are set in NGINX. Disable legacy protocols, use a certificate chain that clients accept, and confirm the policy your security team requires. Certificate renewal is an operational risk: an expired certificate stops browser and desktop clients at once. Confirm who owns renewal, how renewal is tested, and how a failed renewal is alerted.
Exposure of the admin console and metrics ports
Mattermost listens on its application port, and the cluster and metrics ports are documented separately in the network guidance. A proxy that forwards every path can expose the System Console, API paths or metrics endpoints to the internet. Restrict admin paths by network range, do not publish the metrics port through the proxy, and verify each blocked path from outside your network. Confirm the port list against your firewall rules during review.
Log content and retention of sensitive paths
Access logs record request paths, and file upload and download paths can include file identifiers or tokens that the server itself does not log. Decide which fields NGINX records, whether query strings are kept, and how long logs are retained. Restrict read access to the log files, since they may hold personal data. Confirm the retention period with your compliance owner and test that log rotation keeps the files you expect.
Upload size limits versus file policy
NGINX rejects request bodies above client_max_body_size, and that limit must match the file size policy set in Mattermost. A proxy limit below the server limit returns errors to users with no matching server log entry, while a proxy limit above it accepts files your policy forbids at the edge. Set both values from one written policy, test an upload at the boundary, and document the owner of each setting.
Change control for proxy configuration across upgrades
NGINX configuration often drifts from the Mattermost release notes, especially when a new server version changes required headers, paths or WebSocket behavior. Keep the proxy configuration in version control, record each change with its reason, and retest WebSocket connections, uploads and admin access after every server upgrade. Ask your Mattermost support contact or your DeployOpen team to review the proxy file against each upgrade plan before the change window.
Questions buyers ask about a Mattermost proxy setup
What drives the effort and cost of a Mattermost NGINX proxy setup?
The main drivers are how many network zones sit between users and the server, how many Mattermost nodes will sit behind the proxy, and how much of the proxy configuration already exists in your standards. A single server behind one proxy with a certificate from your own PKI is a small job. Multiple nodes, a load balancer tier, separate internal and external names, and log requirements for file uploads and downloads add review and testing work. Costs have two parts: internal staff time for approvals and change windows, and any partner fee, which follows from a written scope. Ask any quote to list the node count, the certificate source, the logging design and the test plan separately.
How long does the proxy work take, and what does it depend on?
Duration depends on the state of your environment more than on NGINX itself. The work is usually gated by certificate issuance, DNS changes, firewall requests and the change window for the production cutover, and those can run on their own schedules. Mattermost's own release cadence also matters: the server publishes a new binary on the 16th of each month, so a proxy change planned alongside an upgrade needs to be sequenced with it. Ask for a timeline that separates build and test time from the calendar dependencies you must wait on.
What does the proxy work need from our team?
Plan to supply five things before build starts: a certificate and its private key or a path to issue one, DNS records for the public and internal names, network access from the proxy to the Mattermost server port and from clients to the proxy, a named change window for cutover, and an owner who can approve header and logging changes. Confirm the port Mattermost listens on in your build and the firewall rules that apply, using the Mattermost network ports guidance as the baseline. Missing any one of these usually moves the schedule more than the configuration does.
Can one competent engineer configure the proxy without a partner?
Yes, for a single-node deployment with standard TLS, a redirect from HTTP to HTTPS and WebSocket support, a capable Linux engineer who knows NGINX can do the work from the Mattermost documentation. The harder parts are the ones that are easy to get wrong in production: WebSocket upgrade headers, request body size limits for uploads, timeouts for long-running requests, and log formats that record file activity your server does not log. A partner is more useful when someone must also prove those controls to auditors or when the design must be reviewed against your own security baseline. Confirm internal skill before deciding.
When is a partner worth bringing in for the proxy?
A partner is worth it when the proxy is part of a larger platform change, when several teams must sign off on the design, or when the logs and access records must meet a documented compliance expectation. It is also useful when the team has no one who has run NGINX in front of a collaboration server. DeployOpen plans, implements, documents and tests self-hosted platforms in your own infrastructure, and most engagements are fixed-scope, so the scope, deliverables and timeline are agreed in writing before work starts. Ask for a written scope that names the test evidence you will receive.
How does load balancing change when Mattermost runs in high availability?
Once Mattermost runs as a cluster, the proxy becomes part of the redundancy design rather than a single front door. Mattermost's high availability model uses redundant application servers, redundant database servers and redundant load balancers, and it is available only on the Enterprise and Enterprise Advanced plans. Every node must also share file storage on Amazon S3, an S3-compatible service or NAS, because local file storage will not work correctly and risks corrupting files. Your load balancer tier needs health checks, sticky behavior for WebSocket sessions where required, and its own failover. Confirm these choices against the current high availability documentation before you size the design.
Which request logs should the proxy keep for file uploads and downloads?
The Mattermost server does not log every file upload and download, so the proxy access log is often the only record of those requests. Capture the timestamp, the authenticated user identifier if the proxy can see it, the request method, the path, the response status, the bytes transferred and the client address. Decide retention, storage location and who can read the logs before go-live, because those logs may hold personal data. Test the format with a real upload and download in a staging environment, and confirm with your compliance owner which fields meet your records requirements.
How DeployOpen works on this
DeployOpen plans, builds, tests and documents the NGINX layer in front of your Mattermost server inside your own infrastructure, so the proxy behavior your users and security team see is written down and checked. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
How we scope
- Confirm your Mattermost server layout, hostnames, ports and whether one node or a clustered deployment sits behind the proxy
- Record the TLS approach, certificate source and who owns certificate renewal in your environment
- Agree how upload and download request logs will be captured, retained and reviewed by your security team
- Document which proxy features are in scope, such as load balancing, and which are excluded before work starts
How we build
- Write the NGINX configuration for TLS termination, HTTP to HTTPS redirects and WebSocket forwarding for your hostnames
- Set request body size and timeout values to match the file sizes and sessions your users actually transfer
- Configure request logging that records file upload and download activity the Mattermost server does not log
- Test WebSocket connections, file transfers and redirects from client networks before any production change
How we hand over
- Deliver the versioned NGINX configuration files, with comments explaining each setting tied to a Mattermost requirement
- Provide a test record showing redirects, WebSocket behavior, upload limits and log output as verified
- Document the log format, storage location and access path so your team can review entries independently
- Run a walkthrough with your platform and security staff covering changes, rollback and certificate renewal
How we support
- Offer ongoing support and upgrade work for the proxy layer as a retainer, scoped separately from the build
- Retest the proxy after Mattermost server upgrades, since proxy settings may need adjustment for new releases
- Review log retention and proxy configuration drift against the documented baseline on a schedule you agree
- Confirm with your own team the outbound and inbound firewall rules that the proxy depends on in your network

