Skip to main content
Version: 0.7

Outside address

This chapter is for a server's administrators. It shows how to give Leafen an address that phones, the people you work with and AI apps on the internet can open: through Tailscale, your own domain, or a temporary link. What the server does when the address changes, reverse proxies, the network proxy and the setup for a closed network are in Self-hosting: Remote access for agents, Reverse proxy and Network proxy.

What you start with​

Nothing opens to the internet by itself. A new server answers only on this computer, or on your network at the address it listens on: a desktop app at 127.0.0.1, a Docker server at the port it is published on. Agents on the same computer connect there, and the server's own pages work as usual.

While a server has only that address, places that make a link or a QR code for another device, such as Add a device, invitations and a page's share link, say that it opens only on the computer Leafen runs on, so other people and devices can't open it, with a way to turn on outside access. Publishing a site or opening a form to anyone with its link warns the same way, in a box of its own. Once there is an outside address, they use it.

Choose an address​

Leafen asks once, in the Open Leafen from anywhere? window, when something first needs an outside address: the first run's address step (on a server set up with leafen setup, the first time a browser logs in), choosing to start with an agent at the first run, or Turn on a public address in Settings → Features → Agents → The text and other ways. Only administrators are asked. The window offers:

  • Make an address with Tailscale (Recommended): a fixed public https address from your own free Tailscale account. Nothing to install.
  • Under Other ways:
    • Use my own domain (Recommended for company & home servers): an address you already have, a Cloudflare tunnel of your own, or port forwarding.
    • Try it for a while, no account: a Cloudflare quick tunnel, whose address changes each time it starts.
  • Later: nothing changes, and the question comes back the next time something needs an address.

A company's server is offered Use a company address first instead once the server can tell it is a company's: when the administrator's account has an email on a company's domain rather than a common free mail service, or an organization on the server has verified a domain. The first run asks only for a language and a name, so its window can't tell yet and shows Tailscale first to everyone: a company's administrator opens Other ways and chooses Use my own domain for the company's own domain or Cloudflare tunnel. When Tailscale can't be reached from the server, the window says why and offers Ask an agent, which copies a prompt with what the server measured about its network, or Do it yourself, which opens the guide in Self-hosting: Do it yourself.

When an address works, the window says Leafen has an internet address, with a QR code: scan it with your phone to sign the phone in there.

The same choice is in Settings → Server → Access from outside → How it connects, where you can change it or turn it Off at any time.

Tailscale​

  1. Choose Make an address with Tailscale, or choose Tailscale (free public address) in How it connects and press Apply.
  2. Log in to Tailscale in any browser: Open Tailscale opens its login page, and Log in on a phone shows it as a QR code. From How it connects, Leafen opens the page in a new tab itself, and Open again opens it again. Create a Tailscale account there if you have none; until you log in, the screen waits at this step. Leafen notices when you are done.
  3. Press Open Tailscale and allow Leafen's address there (Tailscale calls this HTTPS and Funnel). Allow on a phone shows it as a QR code. The screen moves on by itself.
  4. Tailscale puts the address on the internet. The first time can take a few minutes.

The address looks like https://<name>.<tailnet>.ts.net. The first part is the server's name in plain letters — the English word of its alias, or the name its administrators gave it if that is in such letters — or leafen; the part after it is your Tailscale network's name, which you can change in Tailscale's DNS settings before you share links. Connections pass through Tailscale but are decrypted on your server. Log out of Tailscale in Access from outside ends it.

Tailscale's free plan is for personal, non-commercial use; a company needs its own paid Tailscale plan. On a server without a screen, leafen tailscale prints where to log in and allow the address, and waits.

Your own domain​

Use this when your own reverse proxy or a port forward already serves an https address for this server. Connections are decrypted on your proxy or on this server.

  1. Choose Use my own domain (in the window or in How it connects), type the https address, such as https://wiki.example.com, and press Apply. The window then says This address is saved. In the window, an address a Cloudflare tunnel of your own brings here takes that tunnel's token too, under Comes through a Cloudflare tunnel of your own? (see Your own Cloudflare tunnel).
  2. The server checks the address: that its name resolves, which certificate answers there, until when, whether this computer trusts it, and that it is this Leafen answering there. The result reads Checked: …, for example that the name doesn't resolve yet, that nothing answers HTTPS there yet, or that something other than this Leafen answers there — a Cloudflare tunnel that isn't connected answers with Cloudflare's own error. Until it is this server, the window offers no phone QR and Back returns to the address; the server checks again by itself.
  3. This server's address: … in Access from outside shows the address in use. Open it on a phone to try it.

The HTTPS row under the address says who takes HTTPS there:

  • My own proxy: your reverse proxy does, and Leafen takes no port. An address saved before this row came stays this way.
  • Leafen gets the certificate: with just the domain, Leafen gets its certificate from Let's Encrypt, renews it, and takes HTTPS itself. Point the domain's DNS record at the public IP of the server's network and have your router send outside port 443 to the port the row names (443 on a computer; in Docker, the port compose.yaml publishes). Leafen changes neither your router nor your DNS. If another program already uses that port, Leafen leaves it alone and names the program. From the command line: leafen address --address https://wiki.example.com --automatic-certificate. Ask an agent copies those two steps, with the values filled in, for your agent to do while you only log in to the router and the DNS provider.

Doing those two steps by hand, check two things. If your domain's DNS is at Cloudflare, turn that record's proxy off (DNS only): proxied, Let's Encrypt's check reaches Cloudflare instead of your server. And compare the WAN IP your router's admin page shows with your public IP (the one a "what is my IP" page shows): if they differ, a modem or another router is in front (double NAT) or your carrier shares one IP among its customers (CGNAT), and a port forward on your router alone isn't reached from outside — forward on the modem too or put it in bridge mode, and with CGNAT use Tailscale or your own Cloudflare tunnel.

For the server to take HTTPS itself with a certificate you have, run leafen address --address https://wiki.example.com --cert chain.pem --key key.pem --port 443. More is in Self-hosting.

An address on another port, such as https://wiki.example.com:8443, works for browsers, Leafen's apps and agents such as Claude Code, but not for Claude's custom connector, which connects only on port 443. Settings → Features → Agents says so beside the connector's address. For a connector, use Tailscale, your own Cloudflare tunnel, or an address opened on port 443. How to set up a proxy, port forwarding or a closed network is in Self-hosting.

Try it for a while, no account opens a Cloudflare quick tunnel in seconds, with no account. Its address changes each time the tunnel starts, so agents connected through it must connect again and browsers log in again at the new address. A link to one of the server's pages written at an earlier quick tunnel's address (for 30 days) or at 127.0.0.1 still opens that page at the address in use now, and an export writes it as that page. It takes up to 200 requests at once, with no guarantee, and it is decrypted at Cloudflare. Use it to try Leafen from a phone, not for daily use.

Your own Cloudflare tunnel​

Your own Cloudflare tunnel in How it connects takes the Tunnel token of a tunnel you made in your Cloudflare account and the Address its route serves; in the window, it is Use my own domain with the token under Comes through a Cloudflare tunnel of your own?. Leafen runs the tunnel and reconnects it by itself when the server starts. Once it connects, the address is checked as your own domain is. In Cloudflare, set the tunnel's service to the address the screen shows: the server's tunnel port, the port after its own (LEAFEN_TUNNEL_DOOR_PORT sets another). Only requests through that port carry each person's own IP address; the screen warns while the tunnel still reaches the server's main port. Like the temporary link, it is decrypted at Cloudflare.

When the address changes​

The chosen address is used everywhere: page, share and site links, invitations and mails, agent connection texts, device codes and the address to register with a login provider. When it changes to another, the old one forwards to the new one for 90 days, and Access from outside shows until when and what still uses it. A quick tunnel's address is not forwarded. Everything else that happens then is in Self-hosting: Changing the address.

A server started with LEAFEN_PUBLIC_URL uses that address while How it connects is off: Access from outside says This server uses the address from its start settings (LEAFEN_PUBLIC_URL). Every way is still offered; choose another and the server uses its address instead. On Railway, which Leafen knows by the variables Railway sets, the off choice reads Railway’s address: Railway keeps the server open from outside, and there is nothing more to set up.

The desktop and phone apps​

The desktop app's own server is reachable only while the computer is on and awake. While it serves other devices, closing its window keeps it running in the menu bar or tray, as Desktop and phone apps shows. A phone's own Leafen stops when the app closes, so it opens no outside address; to reach it from outside, move it to a computer or server that stays on.

Names, limits and defaults​

NameLimit or defaultNotes
How it connectsOffOff, Tailscale, your own domain, a quick tunnel or your own Cloudflare tunnel.
Tailscale address<name>.<tailnet>.ts.net on port 443Free plan for personal, non-commercial use only.
Quick tunnelUp to 200 requests at onceNew address each start; not forwarded when it changes.
Old address after a changeForwards for 90 daysAnd 30 days past its last request, up to a year.
Tunnel portThe port after the server's ownLEAFEN_TUNNEL_DOOR_PORT sets it.
LEAFEN_PUBLIC_URLNot setWhen set, it is the only address.

For agents and the API​

An administrator's agent connection (not an MCP token) uses leafen_remote_access: status reads how remote access stands; tailscale starts the Tailscale address and answers the pages for the person to log in and allow it; set_address makes an https address the person and the agent set up the server's own, with automatic_certificate for the certificate Leafen gets itself, or a certificate and key, when the server takes HTTPS itself; own_domain answers what is left for such an address — the DNS record and the router's port forward — with the values the server measured. The person logs in to Tailscale and pays for anything themselves; the agent asks before each change to the network, security or money. When the server's address carries a port other than 443, status and set_address add that a Claude connector can't connect there while everything else does, for the agent to tell the person.

Differences from Notion​

  • Notion is a website you open at Notion's address. Leafen runs on your own computer or server, and it opens to the internet only when an administrator chooses how.