Deploying to a server¶
The stack from Getting started is built up in compose layers: HTTPS in front of it, siphon-sip and siphon-rtp beside it to take calls, and host networking for production. This page goes through each, then how siphon-pbx captures every call and where its metrics are.
Shipping a build¶
A Rust release build wants more CPU and memory than a small VPS usually has, so build the image where you are and ship it:
./deploy/deploy-remote.sh pbx.example.com # deploys origin/main
./deploy/deploy-remote.sh user@198.51.100.7 v1.2.3 # deploys a tag
It builds a clean checkout of the committed ref, copies the image and the deploy files over, backs the database up, starts the stack and waits for telephony to come up. Nothing is built on the far end, and your working tree is never deployed: only what is committed.
The server keeps its own deploy/.env, which holds its address and its settings and is never part of
what is copied, so a deploy cannot overwrite it. The script's header lists what to put in it the first
time, and refuses to run without it.
That file also decides whether the voice runtime is deployed. When its COMPOSE_FILE names
docker-compose.voice.yml, the script builds the runtime image as well and ships it whenever the server
does not already hold that build; when it does not, nothing about the runtime is built or copied.
It will tell you rather than let you find out later that the media engine publishes amd64 images only, so an arm64 host cannot run this stack. Starting re-renders the SIP service's configuration but restarts the SIP service only when that configuration changed (a new address, the brand's SIP product, the APIBAN key, a trunk's networks), since a restart drops the registrations it holds and the calls in progress. A deploy that changes only the application leaves it running.
Rolling back is retagging the previous image and starting again, which the script prints when it finishes. A release that applied a database migration may need its dump restored as well, and the script says so when migrations ran.
HTTPS¶
deploy/docker-compose.tls.yml puts Caddy in front of siphon-pbx, on ports 80 and 443:
cd deploy
export SIPHON_PBX_PUBLIC_URL=https://pbx.example.com # the operator address
export SIPHON_PBX_PORT=127.0.0.1:8080 # plain HTTP on loopback only
docker compose -f docker-compose.yml -f docker-compose.tls.yml up -d
Point each name at the machine, keep ports 80 and 443 open to everyone, and a name gets its certificate
from Let's Encrypt the first time a browser opens it. Only the operator address and the hostnames
organisations have get one: Caddy asks siphon-pbx before every issuance, so a hostname added in the
console needs nothing else, and a name someone else points at the machine gets nothing. Keep
siphon-pbx's own port on loopback as above, so no password is ever typed over plain HTTP. On a closed
network, SIPHON_PBX_CERTIFICATE_ISSUER=internal issues from Caddy's own authority instead; its root is
caddy/pki/authorities/local/root.crt in the caddy-data volume, for the browsers that should trust
it. The overlay goes on top of the telephony stack below as well, and deploy/e2e/tls.sh runs the two
together.
Taking calls¶
deploy/docker-compose.telephony.yml adds siphon-sip and siphon-rtp on top of the stack above, each pinned
by digest to the release this one was tested with:
cd deploy
export SIPHON_PBX_SIP_ADDRESS=192.0.2.10 # the host phones and trunks reach this machine at, no port
docker compose -f docker-compose.yml -f docker-compose.telephony.yml up -d
docker compose -f docker-compose.yml -f docker-compose.telephony.yml run --rm --no-deps telephony-ready
Run the probe with --no-deps after up. Without it, compose run starts the dependencies again under
a configuration hash of its own and recreates siphon-sip, which drops every phone's registration.
siphon-sip takes SIP on port 5060 (SIPHON_PBX_SIP_PORT publishes another) and hands every call to
siphon-pbx, which runs the live flow of the dialled number, the Request-URI's user part. siphon-pbx
writes siphon-sip's configuration itself, so there is nothing to edit. What a call can do today
is at the top of that file, and deploy/e2e/telephony.sh checks it against the running stack with
SIPp.
Media takes a bounded UDP window, 30000-30063 by default and moved with SIPHON_PBX_MEDIA_PORT_MIN /
SIPHON_PBX_MEDIA_PORT_MAX. The stack publishes exactly those ports and the engine allocates from
them, so open the same window in the host firewall. Each published port costs a docker-proxy
process of its own unless the daemon runs with "userland-proxy": false, which is what a window
wider than a few dozen ports wants.
SIPHON_PBX_APIBAN_KEY is optional and normally unset. Set it and siphon-sip polls the APIBAN community
blocklist, refusing the sources on it before their SIP is parsed, which is the one abuse control that does
not have to watch a source misbehave first. Unset, no such block is written and the other controls are
unchanged. It needs no kernel capability, because the refusal is enforced in userspace, and it can never
catch a configured carrier: every trunk's network is exempt from the feed as well as from the guards. It is
one key for the machine rather than a per-organisation setting, and changing it rewrites siphon-sip's
configuration, so siphon-sip restarts to read it.
SIPHON_PBX_SIP_CREDENTIALS_DATABASE is optional and normally unset. It names where siphon-sip reads the
SIP credentials it checks a REGISTER against, as host:port/database (default postgres:5432/siphon_pbx),
so a node's siphon-sip can read a replica or another database server. The role and its password stay the
stack's own, and the connection is plaintext, because that is what siphon-sip's credential backend speaks.
deploy/docker-compose.host.yml is the other shape, and the one to deploy: every service binds the
machine's own network namespace instead of publishing into it. There is no docker-proxy and no
address translation in front of the media, so the window costs nothing and defaults to 1000 ports —
250 relayed calls at two ports a leg. Add it last:
docker compose -f docker-compose.yml -f docker-compose.telephony.yml -f docker-compose.host.yml up -d
With the TLS proxy, add docker-compose.tls-host.yml after docker-compose.tls.yml: Caddy's
host-mode override lives there so that a stack composed without the proxy does not inherit a Caddy
with no image behind it. The voice runtime is the same: with docker-compose.voice.yml, add
docker-compose.voice-host.yml last, or the runtime stays in a namespace the engine cannot reach.
Only what a phone, a carrier or a browser must reach binds a public address: SIP, the media window, and 80/443/5061 from the TLS layer. Everything else — the console, the control plane, the metrics, the database — binds loopback and says so in that file. Because it takes the machine's real ports, one stack fits per machine: it will refuse to bind next to anything already on 5060, 8080 or 9090.
Capture¶
siphon-pbx is also the capture collector: siphon-sip and siphon-rtp send every SIP message and RTCP
report to it over HEP, continuously, so nothing has to be turned on before a call goes wrong. An
organisation's Calls page shows the calls its own flows took; the operator's shows every call, traffic
no flow took included, with the organisation that took each. Both show a call's SIP ladder, what the
RTCP says about how it sounded (loss, jitter, round trip and an E-model score), and offer the whole
call as a pcap. Packets are kept for
SIPHON_PBX_CAPTURE_RETENTION_DAYS days (7 by default, 366 at most) in a table partitioned by day, so
retention costs a DROP TABLE rather than a delete. OPTIONS keepalives are not stored at all: a trunk
or phone pinging the other end says only that it answered, which the trunk's registration state on the
Trunks page already reports, and on a small deployment it was 38% of every SIP packet stored.
The telephony stack points siphon-sip and siphon-rtp at it already. Anywhere else, both take the collector as an IP address and a port, not a name:
Graphs¶
The stack includes Prometheus, on http://localhost:9090 by default. It scrapes siphon-pbx's
/metrics (its own listener, reachable on the compose network and published nowhere), and in the
telephony stack siphon-sip's and siphon-rtp's too (deploy/prometheus.telephony.yml).