Files
jcoffey-dev c9245077fa Phase 2: the console and the webmail on the host
--console host and --webmail host install them without containers, from
their releases' tarballs (inbuxa-admin #106, inbuxa-webmail #68), each
checked against a checksum pinned in internal/release.

- The console is files: unpacked into <dir>/console, root-owned and
  readable, and pointed at the server the way its image's entrypoint does
  (the api-base-url meta tag). The managed Caddy serves the directory,
  mounted read-only, or the operator's web server does from the
  configuration --proxy snippets writes; both with the image's rules (app
  routes fall back to index.html, hashed assets cached for good, index.html
  never). With --local or --proxy none nothing would serve it, and the
  plan says so.
- The webmail is the /app its image runs, in <dir>/webmail, owned by root,
  under inbuxa-webmail.service as its own user on the installer's own Node
  (now 26, as its image) in /opt/inbuxa/node, on 127.0.0.1:8080, with the
  container's environment in <dir>/webmail.env. It can't write its own
  files, which is what its IMMUTABLE setting checks. The unit is
  ProtectSystem=strict. A server in a container is reached at its loopback
  port and sees it at the project network's gateway, which is what gets
  exempted from the auto-ban.
- Both unpack beside the old copy and swap only when complete; a re-run
  skips an unchanged release and restarts the webmail only when what it
  reads at start changed. A webmail moved back into a container gives its
  port back first. status and export report them as host.

With all three on the host and --proxy snippets, no container runtime is
installed. The release pins are empty until those releases exist, and the
host shapes say so; INBUXA_CONSOLE_TARBALL and INBUXA_WEBMAIL_TARBALL (and
CONSOLE_TARBALL=, WEBMAIL_TARBALL= in e2e/vm/run.sh) install a local
tarball meanwhile.

Also: the "using docker" line no longer prints when nothing runs in a
container; Verify takes the plan's options and checks a host console by
its files.

Tests: plan (console host needs a web server; host front ends wait for
their releases; the webmail wants the installer's own Node), compose
(console files, the webmail unit, Caddy on the host's network, the
gateway exemption, nginx serving the directory), apply (api-base-url
replaced or inserted, the webmail's environment, unpack's swap and
marker). e2e: webmail-host.sh 18/18 (signing in included), all-host.sh
17/17 (no runtime, behind nginx), both with tarballs taken out of the
current images as the release jobs will; install-local, install-host,
install-public, proxy-snippets, interface, status-export and topology
pass unchanged.
2026-10-12 11:26:03 -07:00

66 lines
1.6 KiB
Cheetah

# Written by the inbuxa installer {{.Version}} for {{.Domain}}.
#
# For the web server already on this machine: Caddy. Import it from your
# Caddyfile (`import {{.Dir}}/proxy/Caddyfile.fragment`) and reload. It has no
# global options block, so it can sit beside your own sites. The installer
# loads nothing and restarts nothing.
#
# Everything is passed to loopback: 8081 the mail server, 8082 the console,
# 8080 the webmail. Caddy gets certificates for the console and the webmail
# itself.
{{- if .ServesServer}}
# The mail server's names. Caddy uses TLS-ALPN-01 for them and leaves HTTP-01
# on port 80 to the mail server, which needs a certificate of its own for
# IMAP and SMTP: so neither answers the other's challenge.
{{join .ServerNames ", "}} {
tls {
issuer acme {
email {{.Email}}
disable_http_challenge
}
}
reverse_proxy 127.0.0.1:8081 {
flush_interval -1
}
}
{{range $i, $n := .ServerNames}}{{if $i}}, {{end}}http://{{$n}}{{end}} {
handle /.well-known/acme-challenge/* {
reverse_proxy 127.0.0.1:8081
}
handle {
redir https://{host}{uri} 308
}
}
{{- end}}
{{- if .Console}}
{{.ConsoleHost}} {
encode zstd gzip
reverse_proxy 127.0.0.1:8082
}
{{- end}}
{{- if .ConsoleFiles}}
# The console, installed on this machine as files.
{{.ConsoleHost}} {
encode zstd gzip
root * {{.ConsoleFiles}}
try_files {path} /index.html
header /assets/* Cache-Control "public, max-age=31536000, immutable"
@page not path /assets/*
header @page Cache-Control "no-cache"
file_server
}
{{- end}}
{{- if .ServesWebmail}}
{{.WebmailHost}} {
encode zstd gzip
reverse_proxy 127.0.0.1:8080 {
flush_interval -1
}
}
{{- end}}