Domain, DNS and HTTPS

Browsers allow the microphone, the camera and screen sharing only on HTTPS pages, and a certificate needs a name. This page gets you both, and the reverse proxy that holds the certificate.

A name

A domain costs about ten euros a year, or you take a free name from a dynamic-DNS service. Use a sub-domain such as chat.example.com so the rest of the domain stays free for other things.

At home, your address changes? Use dynamic DNS: a name that always points to your current address, such as the one your router vendor offers or a free service like DuckDNS. The server can look the name up again by itself.

The DNS record

Create an A record for chat.example.com that points to your public IPv4 address: the VPS's address, or your router's WAN address at home. An AAAA record is not needed; the server announces IPv4 addresses for voice.

Check it from any computer:

nslookup chat.example.com

The reverse proxy

A reverse proxy is a small web server in front of Mnema Talk. It owns the HTTPS certificate, accepts connections on port 443 and passes them to the app on 127.0.0.1:8080. It carries the page, the API and the WebSocket; it does not carry voice.

Your machineUse
A VPS or any Linux boxCaddy (gets the certificate by itself)
Synology NASThe DSM reverse proxy
UnraidNginx Proxy Manager from Community Applications
You already run nginxA server block

Caddy

The shortest way: Caddy requests and renews a Let's Encrypt certificate without further setup. Install it from caddyserver.com/docs/install, then put this in /etc/caddy/Caddyfile:

chat.example.com {
	reverse_proxy 127.0.0.1:8080
}

8080 is the PORT value in .env; change both together. Then reload it and open ports 80 and 443:

sudo systemctl reload caddysudo ufw allow 80,443/tcp

Caddy passes WebSocket upgrades and the X-Forwarded-For header by default.

Synology (DSM reverse proxy)

  1. Control Panel > Login Portal > Advanced > Reverse Proxy > Create.
  2. Source: protocol HTTPS, host name chat.example.com, port 443. Destination: protocol HTTP, host name localhost, port 8080.
  3. Open the Custom Header tab of the same entry and press Create > WebSocket. This adds the Upgrade and Connection headers. Do not skip it.
  4. Certificate: Control Panel > Security > Certificate > Add > Get a certificate from Let's Encrypt for chat.example.com. DSM needs TCP port 80 reachable while it issues and renews. Then press Configure and assign the certificate to the entry.

Nginx Proxy Manager (Unraid)

  1. Hosts > Proxy Hosts > Add Proxy Host.
  2. Details: Domain Names chat.example.com; Scheme http; Forward Hostname / IP: the Unraid server's LAN address; Forward Port 8080; switch on Websockets Support.
  3. SSL: "Request a new SSL Certificate", switch on Force SSL, enter your e-mail address, agree, Save. Port 80 must reach NPM.

NPM runs in its own container and cannot reach the host's loopback address: set PUBLISH_ADDR=0.0.0.0 (or the Unraid LAN address) in .env, list NPM's address in TRUSTED_PROXY_CIDRS (Admin > Status names it), run docker compose up -d, and keep 8080 closed on the router.

nginx

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen 443 ssl;
    server_name chat.example.com;
    # ssl_certificate and ssl_certificate_key for this name

    client_max_body_size 60m;          # >= MAX_UPLOAD_SIZE_MB (the ceiling), plus framing

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_read_timeout 300s;        # the WebSocket stays open
    }
}

Get the certificate with certbot --nginx -d chat.example.com. Forward every path to the app, invite links and /join/ links included, without rewrite rules.

The WebSocket check

After sign-in the browser opens a WebSocket to /api/ws and keeps it open for new messages, typing, presence and call signalling. To see it yourself: open the developer tools (F12), Network, filter "WS", reload. /api/ws must have status 101 Switching Protocols. 400, 426 or 502 mean the proxy dropped the Upgrade and Connection headers. Admin > Status has a WebSocket item that turns green once your session got through.

Certificates

Let's Encrypt usually proves you own the name by fetching a file over plain HTTP, so TCP 80 must reach the proxy while the certificate is issued and renewed, about every 60 days. If your provider blocks port 80, ask the proxy for a DNS challenge instead (Nginx Proxy Manager supports it for many DNS providers; Caddy needs a DNS plugin).

Test from outside your network:

curl -I https://chat.example.com

It should print HTTP/2 200 (or 302) without a certificate error.

The browser saysCauseFix
Name mismatchThe certificate is for another nameIssue it for exactly chat.example.com and use it in the proxy entry
Not trusted / self-signedA self-made or default certificateUse Let's Encrypt; the desktop app accepts only trusted certificates
ExpiredRenewal failed (port 80 closed) or a wrong clockOpen port 80, renew, check the clocks

Once https://chat.example.com shows the sign-in page and the WebSocket is green, the web part is done. If Admin > Status later shows Reverse proxy in amber, copy the TRUSTED_PROXY_CIDRS= value it names into .env and run docker compose up -d.

Something wrong on this page? Tell us.