Skip to main content
Fonoster serves the dashboard and API over HTTPS from its first start, with a certificate init.sh generates in config/tls/. That certificate is for getting started: browsers warn about it, and API clients have to trust its ca.pem. Before you go live, use this page to replace it with a real certificate for every name you serve, renewed without touching the machine again. Two rows. Serving: browsers and SDKs reach Envoy over HTTPS at app.example.com and api.example.com; Envoy holds the certificate and passes requests to the dashboard and API over plain HTTP inside. Renewing, from the certbot timer twice a day: a pre hook stops Envoy to free port 80, certbot renews with Let's Encrypt, and a post hook recreates Envoy, which loads the new certificate. Each renewal takes the dashboard and API offline for about 10 seconds; calls don't go through Envoy. Two rows. Serving: browsers and SDKs reach Envoy over HTTPS at app.example.com and api.example.com; Envoy holds the certificate and passes requests to the dashboard and API over plain HTTP inside. Renewing, from the certbot timer twice a day: a pre hook stops Envoy to free port 80, certbot renews with Let's Encrypt, and a post hook recreates Envoy, which loads the new certificate. Each renewal takes the dashboard and API offline for about 10 seconds; calls don't go through Envoy. Whatever tool you use, it takes three things: one certificate that covers every name, its files in .env, and Envoy recreated after each renewal so it loads the new files. This page does them with certbot and Let’s Encrypt. To use other tools, see Other ways.

Before you begin

You need:
  • Fonoster installed with Docker Compose. See Install with Docker Compose.
  • Every name you serve pointing at this machine, for example app.example.com for the dashboard and api.example.com for the SDKs. One name for both works too.
  • Ports 80 and 443 free on this machine and open in any firewall in front of it.
Run the commands on this page as root.

Get a certificate

1

Install certbot

Install certbot from your distribution, and stop Envoy so certbot can use port 80 for the first certificate. On Ubuntu and Debian:
The package also installs a timer that runs renewals twice a day.
2

Get one certificate for every name

Get a certificate with one -d per name. The first name also names the folder the files land in:
The certificate and key are in /etc/letsencrypt/live/app.example.com/ as fullchain.pem and privkey.pem.

Use your certificate

1

Set the three lines in .env

In your fonoster folder, set these lines in .env. PUBLIC_URL is the address people open the dashboard at:
.env
2

Apply it

Recreate the services that read these lines:
Envoy now serves your certificate on 443 and redirects 80 to it. Browsers no longer warn, and API clients don’t need --ca-file. With your certificate, Envoy also tells browsers to keep to HTTPS for this host for a year (HSTS). It never does with the generated certificate, so you can always click through its warning. Browser calls use wss://. Envoy passes them to Routr, which also listens for them on port 5063 inside the stack. You don’t publish or open that port.
3

Check it

Request the dashboard over HTTPS. It answers 200:

Renew automatically

The timer renews the certificate when it has 30 days left. Envoy holds port 80 and reads the certificate only when its container is created, so add two hooks: one stops Envoy before a renewal, the other recreates it after.
1

Add the hooks

Write the two hook scripts. Change /opt/fonoster if your fonoster folder is elsewhere:
2

Try a renewal

Run a renewal against Let’s Encrypt’s test servers, hooks included:
It ends with Congratulations, all simulated renewals succeeded. certbot reports the hooks’ progress lines as “error output”. They aren’t errors.
Each renewal takes the dashboard and API offline for about ten seconds. Calls in progress aren’t affected: SIP and call audio don’t go through Envoy.

Other ways

certbot can prove you own the names through your DNS provider instead of port 80, so Envoy keeps running during renewals. Install your provider’s certbot plugin, issue the certificate with it instead of --standalone, and keep only the post hook.
If a proxy already terminates TLS (Caddy, nginx, Traefik, a cloud load balancer), serve plain HTTP on this machine only and let the proxy hold the certificate:
.env
Run docker compose up -d, then point the proxy at 127.0.0.1:8449. It must forward gRPC (HTTP/2) and WebSocket upgrades on /sip.
Point TLS_CERT and TLS_KEY at your PEM files: the certificate chain and the private key. After you replace them, recreate Envoy with docker compose up -d --force-recreate envoy.

SIP over TLS

SIP stays on UDP and TCP 5060. To also accept SIP over TLS on 5061, for carriers that require it (WhatsApp does), you need a certificate that covers the names carriers connect to, a keystore made from it, and a DNS name in Routr’s externalAddrs.
1

Get a certificate that covers the SIP names

Carriers reach your trunks at <label>.pstn.<domain> (one name per trunk; a linked WhatsApp number gets its own), and they open a second connection to the name Routr writes in Record-Route for mid-call requests such as the carrier’s hangup. The certificate’s names must cover both: the wildcard *.pstn.<domain> and one fixed name under it, such as sip.pstn.<domain>. Your HTTPS certificate covers only app. and api., so request one more. Let’s Encrypt issues wildcards only through the DNS challenge, so use your DNS provider’s certbot plugin (see Other ways) instead of --standalone:
Point the *.pstn.<domain> and sip.pstn.<domain> DNS records at this machine.
2

Build the keystore

Routr reads the certificate as a PKCS#12 keystore:
The keystore is a copy of the certificate, so rebuild it after each renewal: add the openssl line and docker compose up -d --force-recreate routr to that certificate’s post hook.
3

Name the host carriers call back

Routr writes externalAddrs in Record-Route toward carriers. Over TLS the carrier verifies that name against your certificate, so it must be the fixed DNS name from step 1, not the IP address the file has by default (${HOST_IP}). Set it under spec.signaling in config/routr-one.yaml:
config/routr-one.yaml
4

Turn the TLS listener on

Uncomment the routr lines in compose.tls.yaml, add it to COMPOSE_FILE (COMPOSE_FILE=compose.yaml:compose.tls.yaml), uncomment the tls transport in config/routr-edgeport.yaml, set its keyStorePassword to <password>, open 5061/tcp in your firewall, and run docker compose up -d --force-recreate routr. Carriers and softphones then use transport=tls on port 5061.
Routr validates the carrier’s certificate chain against the public CAs the JVM ships, and speaks TLS 1.2 and 1.3 only. A carrier with a private CA needs a truststore holding that CA: set securityContext.trustStore and trustStorePassword in config/routr-edgeport.yaml, then recreate Routr. Over a TLS trunk, call audio is encrypted with SRTP (AES_CM_128_HMAC_SHA1_80, the one suite Routr offers); over 5060 it isn’t.

Troubleshooting

That’s the certificate init.sh generated for getting started. Open the details and continue to the site; the browser remembers it. To make the warning go away, use your own certificate (above).
The browser remembers HSTS for this host from a visit with a real certificate, so it refuses the generated one. In Chrome, open chrome://net-internals/#hsts, delete the host’s domain security policy, and reload. Other browsers clear it with the site’s data.
The client doesn’t trust the generated certificate. Copy config/tls/ca.pem from the server and pass it: --ca-file ca.pem for the CLI and the region agent, the caFile option for the SDK, or FONOSTER_CA_FILE=ca.pem for any of them.
Set both, or neither for the generated certificate. Check that the two paths in .env exist on this machine, and read docker compose logs envoy.
Something holds port 80, usually Envoy. Add the hooks above, or stop Envoy before you issue the first certificate.