NAME
website — run
httpd, get HTTPS, share it
DESCRIPTION
Every VM has https://name.chroot.run with a valid certificate. The proxy terminates TLS and forwards to one port on the VM, 80 by default. It is private: only you, and the users you add, get through. A name that does not exist answers as a private VM you cannot reach.
That covers only this path. The VM's public IPv6 address is open
to the internet on every port, so
httpd(8) listening on
‘*’ answers there to anyone, share or
not. Filter the public address with
pf.conf(5) in the VM; see
new(1).
SERVE A PAGE
Create a VM and run httpd(8) on port 8080:
$ ssh chroot.dev new -n web -w $ ssh vm+web@chroot.run web$ printf 'server "web" {\n\tlisten on * port 8080\n}\n' | doas tee /etc/httpd.conf >/dev/null web$ echo 'hi g33ks =]' | doas tee /var/www/htdocs/index.html >/dev/null web$ doas rcctl enable httpd && doas rcctl start httpd
Point the proxy at 8080:
$ ssh chroot.dev share port web 8080
OPEN IT IN A BROWSER
The browser has no ssh key, so it logs in with a one-time link. After that the proxy knows you on every VM you can reach:
$ ssh chroot.dev browser
SHARE IT
# one user $ ssh chroot.dev share add web bob # everyone, without login $ ssh chroot.dev share set-public web # everyone, and point the proxy at 8080 in the same command $ ssh chroot.dev share set-public web 8080 # back to you and the users added $ ssh chroot.dev share set-private web
YOUR OWN DOMAIN
Lead ‘app.example.com’ to
the VM and create the records it prints at the DNS of example.com:
$ ssh chroot.dev domain add app.example.com web
Once ‘ssh chroot.dev domain
ls’ says ‘active’,
https://app.example.com/
is the same page, with a certificate of its own; see
domain(1).
WHO IS ASKING
Requests reach the VM with the logged-in user in
‘X-Fcm-User’, and its numeric id in
‘X-Fcm-Userid’, so an application
behind the proxy can skip its own login. The VM's owner is sent without
asking. On another owner's VM, shared or public, a user is sent only after
agreeing on a page at chroot.dev, once per browser session; see
browser(1). The proxy removes any
‘X-Fcm-*’ header sent by the client,
and the cookies named ‘__Host-fcm’ or
starting with ‘__Host-fcm-’, which are
its own. Request headers whose name contains an underscore, and request
trailers, are not passed to the VM.
A request from a page of another origin, another VM included, that
changes state (not GET, HEAD or OPTIONS) or opens a websocket arrives
without the login: a public VM gets it without
‘X-Fcm-User’, a private VM refuses it.
Forms and scripts of the VM's own pages are not affected.
The proxy also sets
‘X-Forwarded-For’ to the client's
address as the proxy sees it, in place of any value the client sent,
‘X-Forwarded-Proto’ to
‘https’ and
‘X-Forwarded-Host’ to the host and
port the client asked for.
‘X-Forwarded-For’ holds that one
address, never a list; an IPv4 client appears as IPv4.
‘X-Real-IP’ holds the same address,
and ‘Forwarded’ holds one element with
that address, the protocol and the host, as in
‘for=198.51.100.7;proto=https;host="name.chroot.run"’.
Before setting them, the proxy removes the client's values of
these headers, of any other header whose name starts with
‘X-Forwarded-’, and of
‘True-Client-IP’,
‘X-Client-IP’,
‘Client-IP’,
‘CF-Connecting-IP’,
‘Fastly-Client-IP’ and
‘X-Cluster-Client-IP’.
Responses carry
‘Strict-Transport-Security’ (two
years, includeSubDomains, preload) in place of the VM's own.
LIMITS
At most 256 requests are open at once on each VM, a websocket for as long as it lasts; past that, the proxy answers 503. A request whose response status and headers do not come from the VM within 60 s gets 504.
SEE ALSO
browser(1), domain(1), new(1), share(1), pf.conf(5), httpd(8)