# Reaching your Hub

> How your devices reach the Hub, why it only listens on 127.0.0.1 by default, and how to choose between Tailscale, a reverse proxy, Cloudflare Tunnel, LAN only and the Hub's own TLS.

Source: https://docs.posternmail.app/reach/

This page explains how your phone, your laptop and your browser get to the Hub, compares the
ways to make that happen and helps you pick one. Each way has its own step-by-step page.

## With the installer

The [installer](https://docs.posternmail.app/setup/) asks how you want to reach the Hub and sets it up. Each choice has a
page here for doing the same by hand, or for changing it:

| Installer choice | What it sets up | By hand |
|---|---|---|
| **This machine's address on your network** | The Hub listens on the network at `http://<address>:8080`. | [LAN only](https://docs.posternmail.app/reach/lan/) |
| **A domain with HTTPS (Caddy)** | Caddy in front of the Hub, with a Let's Encrypt certificate. | [Reverse proxy](https://docs.posternmail.app/reach/reverse-proxy/#caddy) |
| **Behind my own reverse proxy** | The Hub's side; it prints what to add to your proxy. | [Reverse proxy](https://docs.posternmail.app/reach/reverse-proxy/) |
| **Only on Tailscale** | Tailscale and `tailscale serve`, at `https://<machine>.<tailnet>.ts.net`. | [Tailscale](https://docs.posternmail.app/reach/tailscale/) |
| **Cloudflare Tunnel** | `cloudflared` with your tunnel token. | [Cloudflare Tunnel](https://docs.posternmail.app/reach/cloudflare/) |

To switch, run the installer again and choose **Change how it is set up**. Your data and
accounts stay. Passkeys are tied to the Hub's domain, so they stop working when the domain
changes: see [Changing the domain later](https://docs.posternmail.app/reach/https/#changing-the-domain-later).

## Why the Hub only listens on 127.0.0.1

After a fresh install the Hub answers only on the machine it runs on:

**Docker Compose:**
`compose.yaml` publishes the Hub's port as `127.0.0.1:8080` on the host (the `POSTERN_BIND`
setting in `.env`: `/opt/postern/.env` with the installer, `~/postern/.env` in these pages). Inside the container the Hub listens on `:8080`, but Docker only
forwards connections that arrive on the host's loopback address.
**Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS:**
The systemd unit and `/etc/postern/hub.env` set `POSTERN_LISTEN=127.0.0.1:8080`. Only programs
on the same machine can connect.
**Desktop app (built-in Hub):**
The desktop app starts its built-in Hub on `127.0.0.1` with a port it picks itself, and sets the
Hub's address to `http://localhost:<port>`. Nothing outside your computer can connect to it, and
none of the options on this page change that. If you want your phone or a second computer to
use your Hub, move the Hub to a server: see [Set up Postern](https://docs.posternmail.app/setup/). The rest of this page
is about Hubs installed with Docker or systemd.

This is on purpose. Out of the box the Hub speaks plain HTTP, and plain HTTP carries your
password, your session and your mail readable by anyone on the way. A Hub that is reachable
before you finish the setup wizard can also be claimed by someone else (the setup code
protects against that, but there is no reason to take the chance). So the Hub stays private
until you put something in front of it that adds encryption, or decide that your home network
is enough.

The Hub never needs inbound connections for mail. It connects out to your mail providers and
to the push relay. That is why it works behind a home router, behind CGNAT and on a laptop. The
only thing that needs a way in is your own devices.

## The options

| | [Tailscale](https://docs.posternmail.app/reach/tailscale/) | [Reverse proxy and a domain](https://docs.posternmail.app/reach/reverse-proxy/) | [Cloudflare Tunnel](https://docs.posternmail.app/reach/cloudflare/) | [LAN only](https://docs.posternmail.app/reach/lan/) | [Built-in TLS](https://docs.posternmail.app/reach/https/) |
|---|---|---|---|---|---|
| **Who can reach the Hub** | Only devices signed in to your tailnet | Anyone on the internet (then the Hub's sign-in) | Anyone on the internet, or only you with Cloudflare Access | Devices on your home network | Anyone on the internet |
| **HTTPS** | Yes, a real certificate for `*.ts.net` | Yes (Let's Encrypt through Caddy, certbot or Traefik) | Yes, Cloudflare's certificate | No | Yes (Let's Encrypt, or your own certificate) |
| **Passkeys, Google sign-in, Web Push** | Yes | Yes | Yes | No | Yes |
| **Phones away from home** | Yes, with the Tailscale app on the phone | Yes | Yes | No | Yes |
| **Open ports on your router** | None | 80 and 443 | None | None | 80 and 443 |
| **You need** | A free Tailscale account | A domain, a public IP address | A domain on Cloudflare | Nothing | A domain, a public IP address |
| **Who sees your traffic** | Nobody (end to end WireGuard) | Nobody | Cloudflare (it decrypts in transit) | Anyone on your network | Nobody |
| **Effort** | Low | Medium | Medium | Lowest | Medium |

[HTTPS and passkeys](https://docs.posternmail.app/reach/https/) also covers your own certificates and why self-signed
certificates do not work with the apps.

## What needs HTTPS

Several features only work when the Hub is reached over HTTPS, or on `localhost` of the same
machine:

| Feature | Without HTTPS | Why |
|---|---|---|
| **Passkeys** | Not offered. Settings → Security says "Passkeys only work when your Hub is opened over a secure (https) address." The Hub answers a passkey request with "Passkeys need a secure connection: open the Hub over HTTPS (set POSTERN_PUBLIC_URL) or via localhost." | Browsers only allow WebAuthn in a secure context, bound to a domain name. The Hub never offers passkeys on an IP address, even over HTTPS. |
| **Google sign-in for Gmail** (your own OAuth client) | "Google sign-in needs the Hub to be reachable over HTTPS (or on localhost). Use an app password with IMAP instead, or set up HTTPS." | Google only accepts `https://` redirect addresses, or loopback. |
| **Microsoft sign-in in the browser** | "Microsoft sign-in in the browser needs the Hub to be reachable over HTTPS (or on localhost). Use the sign-in with a code instead." | Same rule for redirect addresses. The code sign-in still works. |
| **Web Push** (browser notifications) and the web app's service worker | The browser does not offer them. | Browsers only allow both in a secure context. |
| **Phones** | Possible only on your home network, and with limits (see [LAN only](https://docs.posternmail.app/reach/lan/)). | iOS and Android refuse plain HTTP to most addresses. |

Password with TOTP works everywhere, also over plain HTTP.

## Two settings you need with every option

### POSTERN_PUBLIC_URL

The address people type to open your Hub: scheme, host name and, if it is not 443 or 80, the
port. No trailing slash, no path. Examples: `https://mail.example.com`,
`https://hub.tailnet-1234.ts.net`, `http://192.168.1.20:8080`.

The Hub uses it for:

- links in invites and in pairing QR codes,
- the redirect addresses for Google, Microsoft and single sign-on,
- passkeys (the host name becomes the passkey's domain),
- the same-origin check that protects every change you make in the web app. A request whose
  `Origin` does not match this host is refused with "Cross-origin request rejected".

When it is empty the Hub guesses the address from each request. That works on `localhost`, but
invite links then use whatever address the inviting browser used, passkeys only work on
localhost, and `postern-hub doctor` warns: "POSTERN_PUBLIC_URL is not set: invite and pairing
links use whatever address a browser used, and passkeys only work on localhost". The Hub refuses
to start with a value that is not an absolute `http://` or `https://` URL:

```text
error: POSTERN_PUBLIC_URL must be an absolute http(s) URL, got "mail.example.com"
```

### POSTERN_TRUST_PROXY

Off by default. Turn it on (`true`) when something in front of the Hub passes requests on to it:
`tailscale serve`, Caddy, nginx, Traefik or `cloudflared`. The Hub then believes the
`X-Forwarded-Proto`, `X-Forwarded-Host` and `X-Forwarded-For` headers that the proxy adds, so it
knows that the browser used HTTPS, which host name it used, and which IP address the visitor
has (for rate limits, the security log and the device list).

It only believes those headers from the addresses in `POSTERN_TRUSTED_PROXIES` (by default
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`).
Leave `POSTERN_TRUST_PROXY` off when nothing proxies the Hub, for example with
[LAN only](https://docs.posternmail.app/reach/lan/) or [built-in TLS](https://docs.posternmail.app/reach/https/). Otherwise any device that talks to
the Hub directly could claim to be someone else. The full rules are in
[Configuration](https://docs.posternmail.app/configuration/).

### Where to set them

**Docker Compose:**
Both are passed through by `compose.yaml`, so they go into `~/postern/.env`:

```sh
POSTERN_PUBLIC_URL=https://mail.example.com
POSTERN_TRUST_PROXY=true
```

Apply with:

```sh
cd ~/postern && docker compose up -d
```

Other variables (`POSTERN_TRUSTED_PROXIES`, `POSTERN_CLIENT_IP_HEADER`, the TLS and Access
settings) are not passed through by `compose.yaml`. Put them into `~/postern/compose.override.yaml`:

```yaml
services:
  hub:
    environment:
      POSTERN_CLIENT_IP_HEADER: CF-Connecting-IP
```
**Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS:**
Edit `/etc/postern/hub.env`:

```sh
sudoedit /etc/postern/hub.env
```

```ini
POSTERN_PUBLIC_URL=https://mail.example.com
POSTERN_TRUST_PROXY=true
```

One `KEY=value` per line, and no comments after a value (systemd would keep them as part of
the value). Apply with:

```sh
sudo systemctl restart postern-hub
```
**Desktop app (built-in Hub):**
The desktop app sets these itself and you cannot change them. Its Hub is only for this
computer.

## How to decide

1. **Do you only want to use Postern on one computer?** The desktop app's built-in Hub is
   enough. You do not need anything on this page.
2. **Should only your own devices reach the Hub?** Use [Tailscale](https://docs.posternmail.app/reach/tailscale/). It is
   the recommended choice: nothing is exposed to the internet, you get a real certificate, and
   it works on phones on mobile data. Everyone who uses the Hub needs the Tailscale app.
3. **Do you want a normal web address that works from any browser, without an app?** Use a
   [reverse proxy with your own domain](https://docs.posternmail.app/reach/reverse-proxy/) if you can open ports 80 and
   443 on your router or run the Hub on a VPS. If you cannot open ports (CGNAT, a landlord's
   router), use [Cloudflare Tunnel](https://docs.posternmail.app/reach/cloudflare/) and accept that Cloudflare sees the
   traffic. Add Cloudflare Access to keep strangers away from the sign-in page.
4. **Is the Hub on a server with a public IP and nothing else on ports 80 and 443?** The Hub's
   [built-in TLS](https://docs.posternmail.app/reach/https/) saves you a separate proxy.
5. **Is everything at home and you do not care about passkeys or Google sign-in?**
   [LAN only](https://docs.posternmail.app/reach/lan/) is the quickest. Phones only sync at home.

You can change your mind later. Switching means a new `POSTERN_PUBLIC_URL`. Two things move with
it: devices must be pointed at the new address (sign them in again or pair them again), and
passkeys are tied to the old host name, so add new ones. See
[Changing the domain later](https://docs.posternmail.app/reach/https/#changing-the-domain-later).

## Check what the Hub thinks

Two places show how the Hub sees itself:

- In the web app, **Settings → Admin → Status** lists **Web address** (your `POSTERN_PUBLIC_URL`
  or "Not set") and **Secure connection (https)**. Warnings appear above, for example "No HTTPS
  public URL: passkeys and Google sign-in unavailable."
- `postern-hub doctor` fetches `POSTERN_PUBLIC_URL/api/v1/info` from the server itself and
  checks the certificate:

**Docker Compose:**
```sh
cd ~/postern && docker compose exec hub postern-hub doctor
```
**Debian and Ubuntu, Fedora and RHEL and Raspberry Pi OS:**
```sh
sudo -u postern sh -c 'set -a; . /etc/postern/hub.env; exec postern-hub doctor'
```
**Desktop app (built-in Hub):**
Not available for the built-in Hub. Its address is always `http://localhost:<port>`.

Look at the **Network** section:

```text
Network
✓ https://mail.example.com is reachable (Hub 0.9.0)
✓ TLS certificate for mail.example.com valid until 2027-03-02
```

`✓` is fine, `!` is a warning, `✗` is a problem. More about the report:
[Doctor](https://docs.posternmail.app/admin/doctor/).
