Self-host Otto on your own domain
Run Otto's server under your own domain. You add DNS records, name your domain in one file, deploy, and sign in with a passkey. Below, example.org stands for your domain and SERVER_IP for your server's address.
Before you start
- A server with Otto installed from your checkout of the Otto repository, which your Mac reaches over SSH through an alias in
~/.ssh/config. Below, that is your server's SSH alias. - A domain whose DNS records you can change.
- Ports 80 and 443 open to the internet. The server gets its certificates from Let's Encrypt.
Set it up
-
Add the DNS records
At your DNS provider, point four names at the server:
Name Type Value Serves example.org(@)A SERVER_IPThe public website wwwA SERVER_IPThe website's wwwnamemyA SERVER_IPThe Otto web app *.previewA SERVER_IPPhone previews, one name per repo If your server has an IPv6 address, add the same four as AAAA records.
-
Write domain.env
On the server, as root, create
/etc/otto-deploy/domain.envwith your domain:sudo install -d /etc/otto-deploy echo 'OTTO_DOMAIN=example.org' | sudo tee /etc/otto-deploy/domain.envThe app lives at
my.example.organd previews underpreview.example.org. To use other names, add the optional keys. The reference lists them all. -
Deploy
On your Mac, in your Otto checkout, run:
OTTO_VPS=myserver yarn deploy:vps allOTTO_VPSis your server's SSH alias. Leave it out and the deploy usesotto-vps. The deploy reads the file and gives each service its names. Without the file, or withoutOTTO_DOMAINin it, it stops before it builds or restarts any service.When it finishes, it tells you that no passkey is enrolled yet.
-
Enroll your first passkey
Nobody can sign in until a passkey exists. Mint a one-time enrollment link, valid for 15 minutes:
yarn vps:auth enrollThis runs through
otto-vpsby default. With your own alias, runssh myserver docker exec otto-auth node cli.mjs enroll.Open the link on the device you will sign in from, usually your phone, and follow its prompt. The passkey is tied to
my.example.organd saved asowner. To pick another name, setOTTO_PASSKEY_USERindomain.envbefore you deploy. -
Check it
Open
https://my.example.organd sign in with the passkey. The first visit to a preview name takes a moment longer while its certificate is issued.
If something is off
- The page does not load, or the certificate fails. The DNS records have not reached your resolver yet, or a port is closed. Check with
dig my.example.org. - You changed domain.env and nothing happened. A change needs a full redeploy: run
OTTO_VPS=myserver yarn deploy:vps allagain. - Your passkey stopped working after you renamed the app host. A passkey belongs to the host it was enrolled on. Enroll a new one.