Repository navigation
Add alios share to expose a project through a Cloudflare Tunnel - #2
Conversation
`alios share` gives the current project a public HTTPS URL. A cloudflared container on alios_internal forwards to Caddy over plain HTTP, and a <project>.share.caddyfile vhost matching the public host proxies on to the project. That vhost file is the only record of a share. - Quick mode (default): one alios_share_<project> container per share, random trycloudflare.com URL, no account needed. - Named mode (ALIOS_SHARE_TUNNEL_TOKEN + ALIOS_SHARE_DOMAIN): one shared alios_share container, stable <project>.<domain> URLs. - `--auth user:pass` puts the share behind basic auth. - `share stop` / `share list`; `stop`, `remove` and `pause` end the project's shares; `status` and `doctor` report them, and doctor flags a share whose tunnel is gone or a half-configured named tunnel. - Caddy adds X-Alios-Share: 1 to shared requests so an image or app can tell them apart. Quick mode is verified end to end on a Laravel project. Named mode is untested, and WordPress isn't supported yet (siteurl/home in the database redirect visitors back to the .test host); docs/SHARING.md says so.
- `alios global restart` restarted quick-tunnel containers, which gave them a new public URL while the vhost kept the old one, so status/doctor showed a dead URL as live. Share tunnels are no longer treated as global services. - Offline, cloudflared logs api.trycloudflare.com in its error, which the URL regex took for the share's URL and reported as a success. That host is now skipped (regression test included). - `alios restart` (and a server-root change) ended the share. The tunnel points at Caddy, not the container, so restart now keeps it. - `share stop` ignored a failed Caddy reload, so with a named tunnel still up for other shares the project stayed public while the command reported success. It now reports the failure. - The --auth password went to `caddy hash-password` as an argument, visible in `ps`; it's sent on stdin now. - Named mode reused an existing tunnel container even after the token was rotated; the container now carries a token fingerprint and is replaced when it differs. A restarted container is also checked for a clean start. - Two projects whose names map to the same public label (my_app, my.app) are refused with a clear error instead of a failed Caddy reload; empty or over-long labels too. - ALIOS_SHARE_DOMAIN accepts the pasted forms "*.acme-dev.com" and "https://acme-dev.com/", and doctor flags a value that isn't a domain. - Docs: restart keeps a share; the token comment and CLAUDE.md no longer claim things the code doesn't do.
Review round 1 (fresh-context reviewer,
|
- `share.StopAll` returned on the first share that failed to stop, skipping the rest and the tunnel-container sweep. Since `share stop` now reports a failed Caddy reload, one broken vhost during `alios pause` could leave another share's tunnel running, and it came back live after `resume`. StopAll now carries on, always sweeps the tunnel containers, and returns every error. - Share tunnels stopped being global services in the previous commit, so `global stop` and `uninstall` no longer stopped them. Both now end every share: with Caddy down nothing can be served, and after an uninstall the named tunnel would otherwise restart with Docker indefinitely. - A restart whose start step fails now ends the share it had kept for the project coming back.
Review round 2The reviewer confirmed all nine round-1 fixes hold, and checked every caller of the changed container listing. It found three new issues, all fixed in 2b67cf9:
|
Review round 3: cleanA focused review of 2b67cf9 found no issues. All three round-2 fixes hold: StopAll continues past errors and always removes the tunnel containers (including the named one), Still untested: named-tunnel mode, and the new paths against a live stack. WordPress is still unsupported, as the docs say. |
What
alios sharegives the current project a public HTTPS URL through a Cloudflare Tunnel.alios_share_<project>container per share, with a randomtrycloudflare.comURL.ALIOS_SHARE_TUNNEL_TOKENandALIOS_SHARE_DOMAINfor stable<project>.<domain>URLs from one sharedalios_sharecontainer.alios share --auth user:passputs the share behind basic auth.alios share stopandalios share list.stop,removeandpauseend the project's shares.statusshows the share.doctorflags a share whose tunnel is gone, and a half-configured named tunnel.Each share is one
<project>.share.caddyfilevhost in thealios_vhostsvolume, and that file is the only record of it. There are no new labels and no config files. The design is indocs/SHARING.md.Testing
--auth.go build ./...andgo vet ./...pass. The repo has no test suite.Known gaps
siteurl/homein the database redirect visitors back to<project>.test. The image-side fix (Serve WordPress from the alios share host in wordpress-dev images docker-php#5) was closed. The docs now say WordPress isn't supported, and Caddy still sendsX-Alios-Share: 1so a future fix can detect shared requests.