Document per-client domain routing: wildcard DNS + Dokploy Domain + site name
Adds the previously-undocumented step between bringing up the stack and creating a site: how a real client actually gets a reachable domain. Decision (discussed with the user): subdomains of box.bettersight.io, dot-hierarchy (client1.box.bettersight.io, not client1-box.bettersight.io) specifically so one wildcard DNS record covers every future client forever, no DNS touched again per onboarding. Folded into Stage 1 (one-time wildcard A record at Namecheap, skipped for local dev and for every client after the first) and Stage 2, split into 2a (Dokploy Domain entry routing the subdomain to frontend:8080 with Let's Encrypt) and 2b (bench new-site using that exact domain, since FRAPPE_SITE_NAME_HEADER=$host means the site folder name must match the Host header verbatim). Deliberately did not renumber Stage 2 onward — too many other files cross-reference exact stage numbers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
This commit is contained in:
parent
b0805a0434
commit
d33281a8e4
|
|
@ -31,8 +31,8 @@ VPS (one docker compose stack = one bench, one Stage 1)
|
|||
│ ├── acme site's database
|
||||
│ └── beta site's database
|
||||
├── sites/ ← one shared volume, one folder per site
|
||||
│ ├── acme.localhost/
|
||||
│ └── beta.localhost/
|
||||
│ ├── acme.box.bettersight.io/ (acme.localhost/ for local dev — see Stage 2)
|
||||
│ └── beta.box.bettersight.io/
|
||||
└── backup.sh → one nightly archive → R2 (every site above, together — see Stage 10)
|
||||
```
|
||||
|
||||
|
|
@ -59,8 +59,9 @@ per-client backup.
|
|||
|
||||
- This repo's structure copied to wherever this VPS's stack will live (skip if it already exists
|
||||
— see "Architecture" above).
|
||||
- Decided: the site name (a real domain in production, `<client>.localhost` for local testing),
|
||||
a DB password, and an Administrator password.
|
||||
- Decided: the site name — in production, `<client-slug>.box.bettersight.io` (see Stage 1's
|
||||
wildcard DNS note and Stage 2 below), `<client>.localhost` for local testing — a DB password,
|
||||
and an Administrator password.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -151,7 +152,56 @@ container, the same way it never touches MariaDB or Redis. If QR codes aren't ge
|
|||
site, confirm this container is actually running (`docker compose ps`) before suspecting the
|
||||
provisioning script.
|
||||
|
||||
## Stage 2 — Create the site
|
||||
**Real client via Dokploy only — one-time per VPS, skip for local dev and skip entirely if
|
||||
already done for this VPS.** Every client site on this box lives under one dedicated subdomain —
|
||||
`box.bettersight.io` — as `<client-slug>.box.bettersight.io`. One wildcard DNS record covers every
|
||||
client forever; new clients never need a new DNS entry, only Stage 2's per-client Dokploy Domain
|
||||
below.
|
||||
|
||||
In Namecheap: Domain List → **Manage** next to `bettersight.io` → **Advanced DNS** tab → **Add New
|
||||
Record**:
|
||||
|
||||
| Type | Host | Value | TTL |
|
||||
|----------|--------|-------------------------------|-----------|
|
||||
| A Record | `*.box` | `<this VPS's public IPv4>` | Automatic |
|
||||
|
||||
Confirm it resolves before moving on — Namecheap propagation is usually fast but can take up to
|
||||
~30 min:
|
||||
```
|
||||
dig +short anything-at-all.box.bettersight.io
|
||||
```
|
||||
should return the VPS's IP.
|
||||
|
||||
⚠ This wildcard matches exactly one label under `box` (`client1.box.bettersight.io`) — it does
|
||||
**not** cover `box.bettersight.io` itself (add a separate, non-wildcard record if that bare
|
||||
domain should resolve to anything, e.g. a shared landing page) and does not cover a second-level
|
||||
label (`a.b.box.bettersight.io`), which this design never needs since every client is exactly one
|
||||
label deep.
|
||||
|
||||
## Stage 2 — Route the domain and create the site
|
||||
|
||||
**Adding another client?** Both steps below are per-client — run them even if Stage 1's wildcard
|
||||
DNS is already in place.
|
||||
|
||||
### 2a. Point this client's domain at Dokploy
|
||||
|
||||
Dokploy dashboard → this Compose application → **Domains** tab → **Add Domain**:
|
||||
|
||||
- **Host**: `<client-slug>.box.bettersight.io`
|
||||
- **Service Name**: `frontend`
|
||||
- **Container Port**: `8080` (`frontend`'s internal port — see `frappe_docker/overrides/compose.noproxy.yaml`; not `HTTP_PUBLISH_PORT`, which is only the *local-dev* host-port mapping)
|
||||
- **HTTPS**: enabled, Certificate: **Let's Encrypt**
|
||||
|
||||
Save, then redeploy. ⚠ **Per Dokploy's own docs (not yet confirmed live against a second real
|
||||
client domain by us):** a Compose app's domain settings are applied as Traefik labels at deploy
|
||||
time, not the moment you click Save — the new domain won't actually route anywhere until the next
|
||||
deploy finishes. Dokploy generates these labels itself; nothing to hand-edit in
|
||||
`docker-compose.yml`/`docker-compose.dokploy.yml` for this.
|
||||
|
||||
Skip this sub-step entirely for local dev — `<client>.localhost` needs no DNS or Dokploy domain,
|
||||
just the site name below.
|
||||
|
||||
### 2b. Create the Frappe site
|
||||
|
||||
```
|
||||
docker compose exec backend bench new-site <site-name> \
|
||||
|
|
@ -162,10 +212,19 @@ docker compose exec backend bench new-site <site-name> \
|
|||
--admin-password '<ADMIN_PASSWORD>'
|
||||
```
|
||||
|
||||
⚠ **The site name must be exactly the domain the browser will send as its Host header** — in
|
||||
production, `<client-slug>.box.bettersight.io` from 2a above, verbatim; for local dev,
|
||||
`<client>.localhost`. `FRAPPE_SITE_NAME_HEADER` defaults to `$host`, so Frappe resolves which
|
||||
site's folder to serve purely off that header — a mismatch (e.g. creating the site as
|
||||
`client1.localhost` in production) means the domain routes through Dokploy fine but Frappe 404s
|
||||
or serves the wrong site underneath it.
|
||||
|
||||
## Stage 3 — Complete the real Setup Wizard — do not script around this
|
||||
|
||||
Log in as Administrator at `http://<site>/login` and walk through the actual browser wizard:
|
||||
company name, abbreviation, currency, country, domain.
|
||||
Log in as Administrator at `<site>/login` (`https://client1.box.bettersight.io/login` in
|
||||
production, once Stage 2a's domain is live — `http://<client>.localhost:8083/login` for local
|
||||
dev) and walk through the actual browser wizard: company name, abbreviation, currency, country,
|
||||
domain.
|
||||
|
||||
**Bypassing this causes confirmed bugs**, all discovered the hard way:
|
||||
1. No default language set → a Frappe locale crash (`UnboundLocalError`). This isn't limited to
|
||||
|
|
|
|||
Loading…
Reference in New Issue