Mattermost behind Cloudflare: lab findings and recommendations

Hi all,

I set up Mattermost 11.11.4 behind Cloudflare (Free plan) in a throwaway AWS environment and, working with Claude Code, changed one setting at a time while testing the web, desktop and mobile clients. Each finding in the write-up is labelled as either a documented recommendation or a lab observation, with links to the Cloudflare and Mattermost docs.

The file is also written to be useful as context for an AI coding assistant: drop it into Claude Code alongside your own Terraform or server config and ask it to check your setup against it.

:backhand_index_pointing_right: Running Mattermost behind Cloudflare: what I reproduced, and what the docs recommend · GitHub

Running Mattermost behind Cloudflare works well, but there are two specific Cloudflare settings that trip people up on WebSocket connections:

  1. WebSocket Proxy & Timeout:
    Under Cloudflare Network, make sure WebSockets is toggled On. Keep in mind that Cloudflare’s free/Pro tiers close idle WebSocket connections after 100 seconds. In Mattermost config.json, set ServiceSettings.WebsocketPingInterval to 30 (or 60) seconds so the server/client keeps the TCP stream warm and prevents random reconnection drops in desktop/mobile apps.
  2. Real Client IP Logging:
    Cloudflare proxies hide the real user IP unless your upstream reverse proxy (Nginx or Caddy in front of Mattermost) trusts Cloudflare’s IP ranges:
    set_real_ip_from 173.245.48.0/20;
    set_real_ip_from 103.21.244.0/22;
    # ... add full Cloudflare IP list
    real_ip_header CF-Connecting-IP;
    
    Without this, Mattermost audit logs and rate limiters will see Cloudflare edge IPs and could throttle all team members at once during high-activity hours.