Reverse proxies and tunnels
By default Squad listens on ports 80 and 443 and gets its own certificate from Let’s Encrypt. In proxy mode it serves plain HTTP on port 8080, and your reverse proxy or tunnel handles HTTPS in front of it. Voice and video skip the proxy, and always connect to the machine on TCP port 7881 and UDP port 7882.
Turn on proxy mode
Заголовок раздела «Turn on proxy mode»Set FLUXER_EDGE_MODE=proxy in fluxer.env, and publish 127.0.0.1:8080:8080 in place of ports 80 and 443, the same as behind your own proxy with Docker. Your proxy then connects to Squad on 127.0.0.1:8080.
Set this in /etc/fluxer/fluxer.env. Your proxy on the same machine then connects to Squad on 127.0.0.1:8080, the default address in proxy mode. Set FLUXER_EDGE_BIND only when Squad should listen on another address.
FLUXER_EDGE_MODE=proxyThen reload Squad.
systemctl reload fluxerdProxy mode is the chart’s default.
Your Ingress or HTTPRoute connects to the Service on port 8080.
rexctl proxy onSquad then listens on 127.0.0.1:8080, or the address you pass with --bind. rexctl writes ready configs for nginx, Caddy, Apache, Traefik and Cloudflare Tunnel into the proxy folder of the instance, and rexctl proxy config nginx prints one again. rexctl proxy off goes back to serving HTTPS directly. For a tunnel, such as Cloudflare Tunnel, use rexctl proxy on --proxy tunnel in place of the command above.
When the proxy runs on another machine, bind Squad to an address that machine can connect to, and say which address it connects from.
rexctl proxy on --bind 10.0.0.5:8080 --proxy-from 10.0.0.2In proxy mode, Squad trusts the visitor address in X-Forwarded-For from private addresses. To trust only your proxy, set FLUXER_EDGE_TRUSTED_PROXIES to its address. When people open Squad on a port other than 443, set FLUXER_PUBLIC_PORT to that port.
When the proxy runs in a container
Заголовок раздела «When the proxy runs in a container»Inside a container, 127.0.0.1 is the container itself, not the machine. When Traefik, nginx or Caddy runs in Docker and connects to Squad on 127.0.0.1, it fails with a 502 and “connection refused” in its log.
With rexctl, bind Squad to the address of the Docker bridge, which containers can connect to, and allow connections from private addresses. rexctl then writes that address into the configs in the proxy folder.
rexctl proxy on --bind 172.17.0.1:8080 --proxy-from privateWhen the proxy container uses its own network, use the gateway address of that network in place of 172.17.0.1. docker network inspect <network> shows it.
When you run Squad yourself with docker compose, put Squad and the proxy on one Docker network and point the proxy at http://fluxer:8080. Squad then needs no published port for the proxy.
Configs for each proxy
Заголовок раздела «Configs for each proxy»Each config below sends chat.example.com to Squad on 127.0.0.1:8080. Replace both with your own. They are the same configs rexctl proxy config writes.
chat.example.com { reverse_proxy 127.0.0.1:8080}Caddy gets the certificate, forwards WebSockets and sets X-Forwarded-For by itself.
map $http_upgrade $fluxer_connection_upgrade { default upgrade; '' close;}
server { listen 80; listen [::]:80; server_name chat.example.com; return 301 https://$host$request_uri;}
server { listen 443 ssl; listen [::]:443 ssl; server_name chat.example.com;
ssl_certificate /etc/letsencrypt/live/chat.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/chat.example.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3;
client_max_body_size 512m;
location / { proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1;
proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $fluxer_connection_upgrade; proxy_set_header X-Forwarded-For $remote_addr;
proxy_read_timeout 3600s; proxy_send_timeout 3600s; proxy_request_buffering off; proxy_buffering off; }}http: routers: fluxer: rule: "Host(`chat.example.com`)" entryPoints: - websecure service: fluxer tls: certResolver: letsencrypt services: fluxer: loadBalancer: servers: - url: "http://127.0.0.1:8080"This is a file provider config.
Use the entry point and certificate resolver from your own Traefik setup.
<VirtualHost *:80> ServerName chat.example.com Redirect permanent / https://chat.example.com/</VirtualHost>
<VirtualHost *:443> ServerName chat.example.com
SSLEngine on SSLCertificateFile /etc/letsencrypt/live/chat.example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/chat.example.com/privkey.pem SSLProtocol -all +TLSv1.2 +TLSv1.3
AllowEncodedSlashes NoDecode ProxyPreserveHost On RequestHeader unset X-Forwarded-For early LimitRequestBody 536870912
ProxyPass / http://127.0.0.1:8080/ nocanon upgrade=websocket timeout=3600 ProxyPassReverse / http://127.0.0.1:8080/</VirtualHost>It needs mod_ssl, mod_headers, mod_proxy and mod_proxy_http.
tunnel: fluxer
ingress: - hostname: chat.example.com service: http://127.0.0.1:8080 originRequest: connectTimeout: 30s keepAliveTimeout: 1h - service: http_status:404Set FLUXER_EDGE_MODE=tunnel, or run rexctl proxy on --proxy tunnel. Cloudflare’s Free and Pro plans limit one request to 100 MB. The apps send a large file in parts of 10 to 64 MiB, or larger for a file over 625 GiB. A file sent in a single request has to fit in 100 MB.
What any other proxy needs to do
Заголовок раздела «What any other proxy needs to do»- Serve HTTPS with TLS 1.2 and 1.3, because video in the mobile apps needs TLS 1.2.
- Pass WebSockets, paths and query strings through unchanged.
- Set
X-Forwarded-Forto the request’s address, and drop any value the visitor sent. - Accept request bodies of at least 512 MiB, to match the upload limits. Keep idle connections open for an hour, or at least 120 seconds.
- Add no
Content-Security-Policyheader, because Squad sends its own. - Use
/_healthfor health checks.
Your own certificate
Заголовок раздела «Your own certificate»Without a proxy, Squad can also serve HTTPS with a certificate you already have in place of one from Let’s Encrypt. Set FLUXER_EDGE_TLS to the certificate file, with the full chain, and the key file. Squad looks for a file name without a folder in /etc/fluxer/certs.
Put both files in a certs folder next to fluxer.env, then add this line to fluxer.env.
FLUXER_EDGE_TLS=fullchain.pem privkey.pemThen mount the folder with -v ./certs:/etc/fluxer/certs:ro on the docker run line, or with - ./certs:/etc/fluxer/certs:ro under volumes in compose.yaml. Squad runs as user ID 65532 in the container, so the files need to belong to that user ID.
sudo chown 65532:65532 certs/*.pem && sudo chmod 0400 certs/privkey.pemCopy both files into /etc/fluxer/certs, readable by the fluxer group, and add the setting to /etc/fluxer/fluxer.env.
install -o root -g fluxer -m 0640 fullchain.pem privkey.pem /etc/fluxer/certs/FLUXER_EDGE_TLS=fullchain.pem privkey.pemThen reload Squad with systemctl reload fluxerd.
To renew, replace both files and reload Squad with the command for how it runs. Squad then serves the new certificate without a restart.
| How Squad runs | Reload |
|---|---|
| Compose file | docker compose kill -s HUP fluxer |
docker run | docker kill -s HUP fluxer |
| Linux by hand | systemctl reload fluxerd |
With certbot on a systemd install, a deploy hook does this after each renewal.
sudo tee /etc/letsencrypt/renewal-hooks/deploy/fluxer > /dev/null <<'EOF'#!/bin/shinstall -o root -g fluxer -m 0640 "$RENEWED_LINEAGE/fullchain.pem" "$RENEWED_LINEAGE/privkey.pem" /etc/fluxer/certs/systemctl reload fluxerdEOFsudo chmod 0755 /etc/letsencrypt/renewal-hooks/deploy/fluxerCloudflare
Заголовок раздела «Cloudflare»When your domain points at Cloudflare’s proxy and Squad serves HTTPS itself, change these settings in the Cloudflare dashboard.
- Turn Rocket Loader off, because the web app shows a blank page with it on.
- Don’t let a Cache Rule store HTML pages, or people get an old web app after upgrades.
- Turn Bot Fight Mode off and add no challenges for
/api/,/gatewayor/livekit/. The desktop and mobile apps can’t solve them. - Set the SSL/TLS encryption mode to “Full (strict)” in the dashboard.
Cloudflare keeps serving cached media after someone deletes it. To purge it right away, make an API token with the Zone Cache Purge permission and set FLUXER_CACHE_PURGE_ADAPTER=http, FLUXER_CACHE_PURGE_HTTP_ENDPOINT to https://api.cloudflare.com/client/v4/zones/<zone id>/purge_cache and FLUXER_CACHE_PURGE_HTTP_TOKEN to the token.
Calls behind a tunnel
Заголовок раздела «Calls behind a tunnel»A tunnel can’t forward call audio and video. Without ports 7881 and 7882 open on the machine, calls need a TURN server on a machine with a public address, such as coturn on a small VPS, or a voice server on such a machine. Add a TURN server with the FLUXER_LIVEKIT_TURN_SERVERS setting or with rexctl.
rexctl voice turn add --host turn.example.com --secret-file secret.txtWhen calls still don’t connect with a TURN server, check that the router lets the voice server connect out to the relay, or open ports 7881 and 7882.