4.0.1: serve the chat through nginx on GL.iNet, https://<name>/ support
- GL.iNet: nginx terminates https with the web admin's certificate and
serves static files (conf.d/zz-cabinchat.conf, after gl.conf so the
admin stays nginx's default server); /cgi-bin/ goes to uhttpd on
127.0.0.1 (fcgiwrap is shared with the admin and runs only 4 scripts)
- --name <host>: also serve https://<host>/ on port 443 plus an http
redirect, add the name to dnsmasq; guessed from dnsmasq entries that
contain "chat" and match the certificate; server_name as regex since
GL's server_names_hash_bucket_size is too small
- config checked with nginx -t, falls back to uhttpd; kept on firmware
updates via /etc/sysupgrade.conf
- fix: TLS detection failed when /usr/lib/libustream-ssl.so is missing
- fix: previous version read from the wrong place ("upgrading 1.x")
- fix: photos of expired messages and deleted accounts were never
removed (file name check rejected ".jpg")
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8928ae7077
commit
907a54eb57
@@ -27,24 +27,41 @@ Or copy it over from a checkout:
|
||||
scp -O dist/install-cabinchat.sh root@192.168.8.1:/tmp/
|
||||
ssh root@192.168.8.1 sh /tmp/install-cabinchat.sh
|
||||
|
||||
Open `https://192.168.8.1:8088` (or `https://chat.lan:8088`) on the router's WiFi.
|
||||
Open `https://192.168.8.1:8088` (or `https://chat.lan:8088`) on the router's
|
||||
WiFi, or `https://<name>` if you set up a name (see below). The installer prints
|
||||
the addresses at the end.
|
||||
|
||||
Running a newer installer over an existing install upgrades it and keeps
|
||||
accounts, messages, photos, the port and the http/https choice. Options:
|
||||
accounts, messages, photos and the settings below. Options:
|
||||
|
||||
-p <port> port (default 8088)
|
||||
--http plain http instead of https (kept on upgrades;
|
||||
--https switches back)
|
||||
--cert <file> --key <file> https with your own certificate (PEM, kept on upgrades)
|
||||
--name <host> also serve https://<host>/ (GL.iNet/nginx only)
|
||||
--no-name forget the name
|
||||
--http plain http instead of https (--https switches back)
|
||||
--cert <file> --key <file> https with your own certificate (PEM)
|
||||
--no-nginx GL.iNet: use uhttpd alone (--nginx switches back)
|
||||
wipe delete all messages and photos (accounts stay)
|
||||
uninstall remove everything
|
||||
|
||||
## HTTPS, app install and notifications
|
||||
|
||||
By default the chat uses https with the certificate of the router's web admin
|
||||
(GL.iNet: the one nginx uses). That certificate is self-signed, so every
|
||||
browser shows a warning once; accept it to continue. If the router has no
|
||||
certificate or uhttpd lacks TLS support, the installer falls back to http.
|
||||
By default the chat uses https with the certificate of the router's web admin.
|
||||
|
||||
On GL.iNet firmware the web admin runs on nginx. The installer adds
|
||||
`/etc/nginx/conf.d/zz-cabinchat.conf`: nginx does https with the admin's
|
||||
certificate (`/etc/nginx/nginx.cer`) and serves the static files on port 8088,
|
||||
and passes `/cgi-bin/chat` to a small uhttpd instance that only listens on
|
||||
`127.0.0.1:8088`. (nginx's own CGI helper, fcgiwrap, runs only 4 scripts at a
|
||||
time and is shared with the web admin; the chat keeps one waiting request per
|
||||
open browser, so it gets its own.) The config is checked with `nginx -t`
|
||||
first; if nginx refuses it, the installer falls back to uhttpd alone.
|
||||
|
||||
On other OpenWrt routers uhttpd does https itself (needs `libustream-ssl`).
|
||||
If the router has no certificate or no TLS support, the installer falls back
|
||||
to http.
|
||||
|
||||
The router's factory certificate is self-signed, so every browser shows a
|
||||
warning once; accept it to continue.
|
||||
|
||||
Browsers only offer some features on a *trusted* https connection:
|
||||
|
||||
@@ -55,11 +72,24 @@ Browsers only offer some features on a *trusted* https connection:
|
||||
| Add to Home Screen (iOS) | ✓ | ✓ | ✓ |
|
||||
| notifications | ✓ | usually blocked (browser-dependent) | no |
|
||||
|
||||
To get everything, give the installer a certificate the phones trust, e.g. a
|
||||
Let's Encrypt certificate for a name in a domain you own (obtained at home via
|
||||
DNS challenge), and point that name at the router:
|
||||
`uci add_list dhcp.@dnsmasq[0].address='/chat.example.com/192.168.8.1'`.
|
||||
Checking a certificate needs no internet, so this works in the air.
|
||||
To get everything, use a certificate the phones trust, e.g. a Let's Encrypt
|
||||
certificate for a domain you own (obtained at home via DNS challenge, a
|
||||
wildcard `*.example.com` is handy). On GL.iNet, install it as the web admin's
|
||||
certificate (`/etc/nginx/nginx.cer` with the full chain, and `nginx.key`),
|
||||
then run the installer with `--name chat.example.com`. nginx then also
|
||||
serves the chat on `https://chat.example.com/` (port 443, next to the web
|
||||
admin, which keeps answering on the IP address and other names), redirects
|
||||
http to https, and the installer adds the name to the router's DNS so it
|
||||
resolves without internet. Checking a certificate needs no internet either,
|
||||
so this works in the air. If the router's DNS already has a name that
|
||||
contains "chat" and matches the certificate, the installer picks it without
|
||||
`--name`. Elsewhere, pass the certificate with `--cert`/`--key`.
|
||||
|
||||
**Firmware updates** (GL.iNet, with "keep settings"): the installer adds
|
||||
`/www-chat/` and the nginx config file to `/etc/sysupgrade.conf`, so they are
|
||||
kept along with the uhttpd and DNS settings and the web admin's certificate.
|
||||
If a future firmware's nginx should reject the chat's config file, run the
|
||||
installer again (or delete `/etc/nginx/conf.d/zz-cabinchat.conf`).
|
||||
|
||||
Notifications work while the chat is open in the background: in another tab,
|
||||
or minimized with the screen on. Real push to a closed app needs the browser
|
||||
@@ -117,7 +147,8 @@ router.
|
||||
On the router's flash, outside the web root: `/www-chat/data/messages` (one
|
||||
line per message), `seq`, `gen`, and `accounts/`, `names/`, `sessions/`,
|
||||
`avatars/` (one small file per account, name, logged-in device and profile
|
||||
picture); photos in `/www-chat/htdocs/img/` with random file names. Messages
|
||||
picture); photos in `/www-chat/htdocs/img/` with random file names. Installer settings:
|
||||
`hostname`, `http-only`, `no-nginx`, `tls/` in the same data folder. Messages
|
||||
older than 24 h are dropped on the fly. Photos are refused once they pass
|
||||
50 MB. Presence, typing notices, device-link codes and the long-poll event
|
||||
token live in RAM under `/tmp/cabinchat/`. Limits are at the top of
|
||||
|
||||
Reference in New Issue
Block a user