Reaching your Hub
Reach your Hub through a reverse proxy
Put Caddy, nginx or Traefik in front of the Hub to reach it at your own domain over HTTPS, with the full configuration files, firewall commands and checks.
How you run the Hub
Commands on every page follow this choice.
This page has instructions for several ways of running the Hub. Each is shown under its name.
This page publishes your Hub at your own domain, for example https://mail.example.com, with a
certificate from Let's Encrypt. A reverse proxy (Caddy, nginx or Traefik) accepts HTTPS from the
internet and passes requests to the Hub on 127.0.0.1:8080. Use this when you want a normal web
address that works in any browser without installing anything. For other options see
Reaching your Hub.
Tip
Used the installer? It does this for you when you choose A domain with
HTTPS (Caddy). It installs Caddy and writes its configuration. With Behind my own reverse
proxy it sets up the Hub's side and prints what to add to your proxy. To switch later, run the
installer again and choose Change how it is set up.
This page is for doing it by hand, or for understanding what was set up. With the installer, the
Docker files are in /opt/postern instead of ~/postern, and the program is
/usr/local/bin/postern-hub.
You need:
- a domain (or subdomain) whose DNS you control,
- a public IP address on the Hub machine, or a router where you can forward ports 80 and 443 to it (not possible behind CGNAT: use Tailscale or Cloudflare Tunnel then),
- nothing else listening on ports 80 and 443 on that machine, unless it is the proxy you configure here.
Once this works, the Hub's sign-in page is on the public internet. That is fine for a Hub that is kept up to date and whose users have strong passwords with TOTP or passkeys. Read Hardening too.
Docker Compose
With Docker Compose the simplest path is the caddy profile that is already in
compose.yaml (step 3, Caddy). nginx or Traefik on the host work too.
Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
Pick one proxy. Caddy is the least work: it gets and renews certificates by itself. Take nginx if you already run it, or Traefik if you already run it.
Desktop app (built-in Hub)
This does not work with the desktop app's built-in Hub: it only accepts connections from your
own computer, and its address is fixed to http://localhost:<port>. To reach a Hub from other
devices, run it on a server as described in Set up Postern, then pick that
method above.
Requirements for any proxy #
The ready-made configurations below do all of this. If you write your own, it must:
| Requirement | Why | Hub setting |
|---|---|---|
Pass WebSocket upgrades on /api/v1/ws (Upgrade and Connection headers, HTTP/1.1 to the Hub) |
Live updates in the web and desktop apps. Without it, new mail only appears after a reload. | none |
Pass the original Host header, or set X-Forwarded-Host |
The Hub's same-origin check compares the browser's Origin with this host. |
POSTERN_PUBLIC_URL, POSTERN_TRUST_PROXY=true |
Set X-Forwarded-Proto: https |
So the Hub knows the browser used HTTPS (security headers, HSTS). | POSTERN_TRUST_PROXY=true |
Set X-Forwarded-For (appending to what is there) or X-Real-IP |
The visitor's IP for rate limits, the security log and the device list. | POSTERN_TRUSTED_PROXIES |
| Allow request bodies of at least 30 MB | Attachments up to POSTERN_MAX_UPLOAD_MB (25 MB by default) plus MIME overhead. Raise both together. |
POSTERN_MAX_UPLOAD_MB |
| Keep WebSocket connections open for an hour or more | Clients ping every 30 seconds; the Hub closes a connection after 2 minutes of silence. A proxy timeout of 60 seconds drops it constantly. | none |
| Do not buffer responses or uploads | Downloads and uploads stream through. | none |
| No password prompt (HTTP basic authentication) in front of the Hub | The apps cannot pass it. The desktop app says "asks for a password first". Use Tailscale or Cloudflare Access instead. | none |
The Hub sets its own security headers (HSTS, X-Frame-Options, Referrer-Policy and others).
Do not add a second, different set in the proxy.
POSTERN_TRUSTED_PROXIES #
With POSTERN_TRUST_PROXY=true the Hub reads the visitor's IP from the forwarding headers, but
only for requests that come from an address in POSTERN_TRUSTED_PROXIES. It reads
X-Forwarded-For from the right and takes the first address that is not a trusted proxy, so an
address a visitor makes up on the left is never used. The default trusts loopback and private
networks (127.0.0.0/8,::1/128,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7).
| Setup | Setting |
|---|---|
| Proxy on the same machine, Hub installed with systemd | POSTERN_TRUSTED_PROXIES=127.0.0.1,::1 |
| Hub in Docker, proxy on the host or in the same Compose project | leave it unset (Docker's networks are private addresses) |
| Proxy on another machine | that machine's IP address, for example 192.168.1.5 |
1. Point your domain at the server #
At your DNS provider, create records for the name you want to use:
| Type | Name | Value |
|---|---|---|
A |
mail (for mail.example.com) |
the server's public IPv4 address |
AAAA |
mail |
the server's public IPv6 address, if it has one |
At home, the public IPv4 address is your router's. Find it with curl -4 https://ifconfig.me
on the Hub machine. If it changes from time to time, use your router's dynamic DNS feature or
your DNS provider's updater. Only add an AAAA record if IPv6 actually reaches the server;
a wrong one breaks certificates for clients that prefer IPv6.
Check: dig +short mail.example.com (or nslookup mail.example.com) prints the address
you entered. DNS changes can take a few minutes.
If it did not work: check for typos in the record name. Some DNS providers want the full
name (mail.example.com.), others only the part before the domain.
2. Open ports 80 and 443 #
Let's Encrypt checks your domain over port 80 (or 443), and visitors use 443. At home, forward TCP ports 80 and 443 on your router to the Hub machine's LAN address (give it a fixed address in the router first, see LAN only). Never forward port 8080: that is the Hub's plain HTTP port.
Then open the ports in the machine's firewall:
Docker Compose
With the Caddy profile or Traefik, Docker publishes ports 80 and 443 and adds its own firewall rules for them. Docker's rules bypass ufw and firewalld, so there is nothing to open. With nginx on the host, open the ports like on any server: on Debian, Ubuntu or Raspberry Pi OS, if you use ufw:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcpOn Fedora (firewalld):
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reloadDebian and Ubuntu and Raspberry Pi OS
Debian and Raspberry Pi OS have no firewall turned on by default; Ubuntu has ufw, inactive
until you enable it. If you use ufw:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcpIf you do not use a firewall on this machine, there is nothing to do.
Fedora and RHEL
Fedora uses firewalld:
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reloadDesktop app (built-in Hub)
Not applicable to the built-in Hub.
Check: sudo ss -tlnp lists nothing on ports 80 and 443 yet, or only the proxy you are
about to configure.
If it did not work: if another web server already uses the ports, put the Hub behind that
one instead (add a site for mail.example.com that proxies to 127.0.0.1:8080), or stop it.
3. Set up the proxy #
Choose one of the three. Each section has the complete configuration from the repository's
deploy/ folder.
Caddy #
Caddy gets a certificate for your domain on its first start and renews it by itself.
Docker Compose
compose.yaml has a caddy service in the profile caddy. It runs
caddy reverse-proxy --from $POSTERN_DOMAIN --to hub:8080, which does the same as
deploy/caddy/Caddyfile: automatic HTTPS, WebSockets and the
X-Forwarded-* headers. It publishes ports 80 and 443 (and 443/udp for HTTP/3) and keeps its
certificates in the volume caddy-data.
Add to ~/postern/.env:
POSTERN_DOMAIN=mail.example.com
POSTERN_PUBLIC_URL=https://mail.example.com
POSTERN_TRUST_PROXY=trueStart the Hub and Caddy together:
cd ~/postern && docker compose --profile caddy up -dFrom now on, always add --profile caddy when you run docker compose up -d, or Caddy stops
being managed. Caddy reaches the Hub over the Compose network, so the Hub's port does not need
to be published on the host; leaving POSTERN_BIND at its default 127.0.0.1:8080 does no
harm.
Watch Caddy get the certificate:
cd ~/postern && docker compose logs -f caddyIf POSTERN_DOMAIN is missing, Caddy stops at once with "caddy profile: set POSTERN_DOMAIN in .env".
Debian and Ubuntu and Raspberry Pi OS
Install Caddy. Debian 12 and later (and Raspberry Pi OS based on it) and Ubuntu 24.04 have a
caddy package:
sudo apt update
sudo apt install caddyOn older releases, or for the newest version, add Caddy's own repository as described on https://caddyserver.com/docs/install.
Fedora and RHEL
Install Caddy from Fedora's repositories:
sudo dnf install caddy
sudo systemctl enable --now caddyOn RHEL and its relatives, follow https://caddyserver.com/docs/install.
Desktop app (built-in Hub)
Not applicable to the built-in Hub.
Configure Caddy #
Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
Replace the contents of /etc/caddy/Caddyfile with this file
(deploy/caddy/Caddyfile) and change mail.example.com:
# Postern Hub behind Caddy (automatic HTTPS).
#
# 1. Point mail.example.com at this server; open ports 80 and 443.
# 2. Replace mail.example.com below and copy this file to /etc/caddy/Caddyfile.
# 3. In /etc/postern/hub.env (or the container environment) set:
# POSTERN_PUBLIC_URL=https://mail.example.com
# POSTERN_TRUST_PROXY=true
# POSTERN_LISTEN=127.0.0.1:8080
# 4. sudo systemctl reload caddy
#
# Caddy proxies WebSockets (/api/v1/ws) and sets X-Forwarded-For/-Proto/-Host
# automatically. With Docker Compose, use the "caddy" profile instead
# (deploy/docker/compose.yaml): it runs the same configuration.
mail.example.com {
encode zstd gzip
# Attachments up to POSTERN_MAX_UPLOAD_MB (default 25 MB) plus MIME overhead.
request_body {
max_size 40MB
}
reverse_proxy 127.0.0.1:8080 {
# Stream responses (downloads, long-lived requests) without buffering.
flush_interval -1
}
# No access log on purpose: request URLs can carry signed image-proxy tokens.
# Add a `log` block if you need one.
}Check the file and load it:
caddy validate --config /etc/caddy/Caddyfile
sudo systemctl reload caddyWatch Caddy get the certificate:
sudo journalctl -u caddy -fThen set the Hub's settings in step 4.
Docker Compose
The caddy profile needs no Caddyfile. Continue with the check below.
Desktop app (built-in Hub)
Not applicable to the built-in Hub.
Check: curl -sI https://mail.example.com/api/v1/info from any machine prints
HTTP/2 200 (or HTTP/1.1 200 OK), and Caddy's log contains "certificate obtained
successfully".
If it did not work:
- Caddy's log shows an ACME error mentioning a timeout or "connection refused": Let's Encrypt cannot reach port 80 or 443 from the internet. Check the router's port forwarding, the firewall (step 2) and the DNS record (step 1).
- "too many certificates" or "rateLimited": Let's Encrypt limits how often you can request certificates. Wait as long as the message says; do not restart Caddy in a loop.
502 Bad Gateway: Caddy runs, the Hub does not answer on127.0.0.1:8080(orhub:8080in Docker). Check the Hub's log.
nginx #
nginx does not get certificates by itself. Use certbot from Let's Encrypt to get one first, then add the Hub's configuration.
Docker Compose
Install nginx on the host, with certbot and its nginx plugin. On Debian, Ubuntu or Raspberry Pi OS:
sudo apt update
sudo apt install nginx certbot python3-certbot-nginxOn Fedora, use sudo dnf install nginx certbot python3-certbot-nginx, then
sudo systemctl enable --now nginx and sudo setsebool -P httpd_can_network_connect 1 (see
the Fedora variant of this step for why).
Debian and Ubuntu and Raspberry Pi OS
Install nginx and certbot with its nginx plugin:
sudo apt update
sudo apt install nginx certbot python3-certbot-nginxFedora and RHEL
Install nginx and certbot with its nginx plugin, and start nginx:
sudo dnf install nginx certbot python3-certbot-nginx
sudo systemctl enable --now nginxSELinux blocks nginx from connecting to the Hub's port until you allow it:
sudo setsebool -P httpd_can_network_connect 1Without this, every request ends in 502 Bad Gateway and nginx's error log says
"connect() to 127.0.0.1:8080 failed (13: Permission denied)".
Desktop app (built-in Hub)
Not applicable to the built-in Hub.
Get a certificate and configure nginx #
Docker Compose, Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
Get the certificate. nginx must be running and reachable on port 80:
sudo certbot certonly --nginx -d mail.example.comcertbot stores it in /etc/letsencrypt/live/mail.example.com/ and installs a timer that renews
it. Now create /etc/nginx/conf.d/postern.conf with this file
(deploy/nginx/postern.conf) and change both
mail.example.com lines and the certificate paths:
# Postern Hub behind nginx.
#
# 1. Get a certificate (e.g. `certbot certonly --nginx -d mail.example.com`).
# 2. Replace mail.example.com and the certificate paths below, then copy this file to
# /etc/nginx/conf.d/postern.conf (or sites-available + symlink on Debian).
# 3. In /etc/postern/hub.env set:
# POSTERN_PUBLIC_URL=https://mail.example.com
# POSTERN_TRUST_PROXY=true # required: the Hub must honor X-Forwarded-*
# POSTERN_LISTEN=127.0.0.1:8080
# 4. sudo nginx -t && sudo systemctl reload nginx
# WebSocket upgrade: send "Connection: upgrade" only when the client asks for it.
map $http_upgrade $postern_connection_upgrade {
default upgrade;
'' '';
}
upstream postern_hub {
server 127.0.0.1:8080;
keepalive 32;
}
server {
listen 80;
listen [::]:80;
server_name mail.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name mail.example.com;
ssl_certificate /etc/letsencrypt/live/mail.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mail.example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
ssl_session_cache shared:postern:10m;
ssl_session_timeout 1d;
# Attachments up to POSTERN_MAX_UPLOAD_MB (default 25 MB) plus MIME overhead.
client_max_body_size 30m;
# The Hub sets its own security headers (HSTS, CSP, X-Frame-Options, ...).
location / {
proxy_pass http://postern_hub;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
# WebSocket (/api/v1/ws) and keep-alive to the upstream.
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $postern_connection_upgrade;
# WebSocket connections stay open for hours; clients ping every 30 s.
proxy_read_timeout 1h;
proxy_send_timeout 1h;
# Stream uploads and downloads instead of buffering them on disk.
proxy_request_buffering off;
proxy_buffering off;
}
}Important
http2 on; needs nginx 1.25.1 or later. Debian 12, Raspberry Pi OS 12 and Ubuntu 24.04 ship
older versions, and nginx -t then fails with unknown directive "http2". On those, delete
the line http2 on; and write the two listen lines as listen 443 ssl http2; and
listen [::]:443 ssl http2;. Check your version with nginx -v.
Test and load the configuration:
sudo nginx -t
sudo systemctl reload nginxWith Docker Compose this works unchanged: compose.yaml publishes the Hub on
127.0.0.1:8080 of the host, which is where the upstream points.
Desktop app (built-in Hub)
Not applicable to the built-in Hub.
Check: curl -sI https://mail.example.com/api/v1/info prints status 200, and
curl -sI http://mail.example.com/ answers 301 with a Location: https://... header.
If it did not work:
nginx -tcomplains about a missing certificate file: certbot did not finish. Run the certbot command again and read its message.502 Bad Gateway: the Hub does not listen on127.0.0.1:8080, or (on Fedora) the SELinux switch above is off.sudo tail /var/log/nginx/error.logsays which.413 Request Entity Too Largewhen sending an attachment: raiseclient_max_body_size(andPOSTERN_MAX_UPLOAD_MBif you want larger attachments).- The web app shows mail but never updates by itself: the
UpgradeandConnectionlines are missing or themapblock was not loaded.
Traefik #
Use Traefik if you already run Traefik v3. The repository has a Compose file with Docker labels for it.
Docker Compose
deploy/traefik/compose.traefik.yaml runs the Hub
without publishing any port and attaches it to Traefik's network. It assumes:
- an entrypoint named
websecure(port 443), - a certificate resolver named
letsencrypt, - Traefik's Docker provider watching an external network named
traefik.
Rename these in the labels if your Traefik uses other names. The file:
# Postern Hub behind Traefik v3 (Docker labels).
#
# Assumes an existing Traefik with:
# - an entrypoint named "websecure" (:443) and a certificate resolver named "letsencrypt"
# - the Docker provider watching an external network named "traefik"
# Adjust the names to your setup. Start with:
# POSTERN_DOMAIN=mail.example.com docker compose -f compose.traefik.yaml up -d
#
# Traefik forwards WebSockets and X-Forwarded-* headers by default.
name: postern
services:
hub:
image: ghcr.io/theoriuhd/postern-hub:${POSTERN_VERSION:-${MAILCLIENT_VERSION:-latest}}
restart: unless-stopped
environment:
POSTERN_PUBLIC_URL: https://${POSTERN_DOMAIN:-${MAILCLIENT_DOMAIN:-mail.example.com}}
POSTERN_TRUST_PROXY: "true"
POSTERN_RELAY_URL: ${POSTERN_RELAY_URL:-${MC_RELAY_URL:-}}
volumes:
- postern-data:/data
- postern-key:/key
read_only: true
tmpfs:
- /tmp
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
networks:
- traefik
labels:
traefik.enable: "true"
traefik.docker.network: traefik
traefik.http.routers.postern.rule: Host(`${POSTERN_DOMAIN:-${MAILCLIENT_DOMAIN:-mail.example.com}}`)
traefik.http.routers.postern.entrypoints: websecure
traefik.http.routers.postern.tls: "true"
traefik.http.routers.postern.tls.certresolver: letsencrypt
traefik.http.services.postern.loadbalancer.server.port: "8080"
volumes:
# Installs from before the rename: POSTERN_DATA_VOLUME=mailclient_mailclient-data and
# POSTERN_KEY_VOLUME=mailclient_mailclient-key keep the old volumes (docs/migrating-from-mailclient.md).
postern-data:
name: ${POSTERN_DATA_VOLUME:-postern_postern-data}
postern-key:
name: ${POSTERN_KEY_VOLUME:-postern_postern-key}
networks:
traefik:
external: trueIt uses the same volumes as compose.yaml, so your data stays. Stop the normal stack first,
copy the file next to your .env, and set the domain there:
cd ~/postern && docker compose downCopy deploy/traefik/compose.traefik.yaml from your source checkout into ~/postern/. Then add to ~/postern/.env
(keep POSTERN_VERSION=local, the image you built; there is no published image yet):
POSTERN_DOMAIN=mail.example.comStart it:
cd ~/postern && docker compose -f compose.traefik.yaml up -dFrom now on, pass -f compose.traefik.yaml to every docker compose command (exec, logs,
up), or Compose uses compose.yaml again. The file sets POSTERN_PUBLIC_URL and
POSTERN_TRUST_PROXY=true itself. Variables you add in compose.override.yaml are not picked
up with -f; add them to the environment: block of this file instead.
Traefik forwards WebSockets and X-Forwarded-* headers without extra settings and does not
limit request bodies. If you added a buffering middleware, allow at least 30 MB
(maxRequestBodyBytes: 31457280).
Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
The repository has no ready-made Traefik configuration for a Hub installed with systemd. If Traefik already runs on this machine, add a router and a service to its file provider (a dynamic configuration file), with your entrypoint and certificate resolver names:
http:
routers:
postern:
rule: Host(`mail.example.com`)
entryPoints:
- websecure
tls:
certResolver: letsencrypt
service: postern
services:
postern:
loadBalancer:
servers:
- url: http://127.0.0.1:8080Then set the Hub's settings in step 4. If you do not run Traefik yet, use Caddy instead: it is less to set up.
Desktop app (built-in Hub)
Not applicable to the built-in Hub.
Check: Traefik's dashboard lists the router postern without errors, and
curl -sI https://mail.example.com/api/v1/info prints status 200.
If it did not work:
404 page not foundfrom Traefik: the router rule does not match. CheckPOSTERN_DOMAINand that the Hub container is on thetraefiknetwork.pull access deniedormanifest unknownforghcr.io/theoriuhd/postern-hub:POSTERN_VERSION=localis missing from.env, so Compose looks for a published image that does not exist yet.- A certificate error: the resolver name in the labels does not exist in your Traefik.
4. Tell the Hub its address #
Docker Compose
With the Caddy profile or Traefik you already set this. With nginx on the host, add to
~/postern/.env:
POSTERN_PUBLIC_URL=https://mail.example.com
POSTERN_TRUST_PROXY=trueand apply:
cd ~/postern && docker compose up -dLeave POSTERN_TRUSTED_PROXIES unset: the proxy's requests reach the Hub from a private Docker
address, which the default trusts.
Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS
Add to /etc/postern/hub.env (sudoedit /etc/postern/hub.env):
POSTERN_LISTEN=127.0.0.1:8080
POSTERN_PUBLIC_URL=https://mail.example.com
POSTERN_TRUST_PROXY=true
POSTERN_TRUSTED_PROXIES=127.0.0.1,::1and apply:
sudo systemctl restart postern-hubDesktop app (built-in Hub)
Not applicable to the built-in Hub.
Check: postern-hub doctor (the command for your install is on Doctor)
shows in its Network section ✓ https://mail.example.com is reachable and
✓ TLS certificate for mail.example.com valid until .... Open https://mail.example.com in a
browser, sign in, and star a message: it works without "Cross-origin request rejected".
If it did not work:
- "Cross-origin request rejected" when you change something:
POSTERN_PUBLIC_URLdiffers from the address in the browser's address bar, or the proxy does not passHost. - Settings → Security says passkeys only work over https although you use HTTPS:
POSTERN_PUBLIC_URLis missing or starts withhttp://. - Security log and device list show
127.0.0.1or172.xfor everyone:POSTERN_TRUST_PROXYis off, or the proxy's address is not inPOSTERN_TRUSTED_PROXIES.
5. Connect your apps #
Open https://mail.example.com in a browser and, if the Hub is new, follow the setup wizard
(Set up Postern). Connect the desktop and mobile apps to the same address, or pair
phones with a QR code (Pairing).
If you used another address before (LAN or Tailscale), signed-in devices keep the old one. Sign them in again with the new address, and add new passkeys: passkeys are tied to the host name (Changing the domain later).