README: add CloudPanel setup section
Run kernelwatch outside the site user's htdocs, create the site as a Reverse Proxy to a free local port (8080 may be taken by Varnish's backend), and check the generated vhost forwards Host and X-Forwarded-For and doesn't serve /static from the empty docroot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
16d647cf9c
commit
818a2e7a1c
1 file changed
+54
@@ -108,6 +108,60 @@ root cert with `--ca` (below).
|
|||||||
You can expose only `/api/v1/report` to the fleet network and keep the
|
You can expose only `/api/v1/report` to the fleet network and keep the
|
||||||
dashboard on a VPN or tailnet. That's a proxy rule, not a kernelwatch setting.
|
dashboard on a VPN or tailnet. That's a proxy rule, not a kernelwatch setting.
|
||||||
|
|
||||||
|
### CloudPanel
|
||||||
|
|
||||||
|
CloudPanel gives each site its own Linux user and a document root at
|
||||||
|
`/home/<site-user>/htdocs/<domain>/`. kernelwatch doesn't use that directory.
|
||||||
|
nginx forwards requests to the app; it doesn't serve kernelwatch's files. Install
|
||||||
|
with `server/install.sh` as above, so the app runs as the `kernelwatch` user
|
||||||
|
with its data in `/var/lib/kernelwatch`, outside every site user's home. Leave
|
||||||
|
the document root empty, and keep your clone of this repo out of `htdocs`.
|
||||||
|
|
||||||
|
1. **Pick a free port.** CloudPanel's Varnish setup can run an nginx backend
|
||||||
|
on 8080. Check with `ss -ltnp | grep ':8080\b'`. If it's taken, set another port
|
||||||
|
in `/etc/kernelwatch/server.toml` and restart (`sudo systemctl restart kernelwatch`):
|
||||||
|
|
||||||
|
```toml
|
||||||
|
listen_port = 8095
|
||||||
|
trust_proxy_headers = true
|
||||||
|
```
|
||||||
|
|
||||||
|
Check it: `curl -s http://127.0.0.1:8095/healthz` should print `ok`.
|
||||||
|
|
||||||
|
2. **Create the site as a Reverse Proxy.** In CloudPanel: *Add Site → Create a
|
||||||
|
Reverse Proxy*, with your domain and Reverse Proxy URL
|
||||||
|
`http://127.0.0.1:8095`. CloudPanel can't change an existing site's type. If
|
||||||
|
the domain already exists as a PHP or static site, delete and recreate it.
|
||||||
|
Deleting a site also removes its site user and home directory, so move
|
||||||
|
anything you need out first.
|
||||||
|
|
||||||
|
3. **TLS.** In the site's *SSL/TLS* tab, issue a Let's Encrypt certificate. Agents
|
||||||
|
then need no `--ca`.
|
||||||
|
|
||||||
|
4. **Check the generated vhost** (the site's *Vhost* tab). The `location`
|
||||||
|
that proxies to the app should pass the original `Host` header and the
|
||||||
|
client address:
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
```
|
||||||
|
|
||||||
|
Add them if they're missing. Without `Host`, logins fail the origin check
|
||||||
|
with "cross-origin request refused". Without `X-Forwarded-For`, every login
|
||||||
|
appears to come from 127.0.0.1, so one person's failed attempts lock everyone out.
|
||||||
|
Also check that the login page is styled. If `/static/style.css` returns 404,
|
||||||
|
a static-file `location` in the template is looking in the empty document root
|
||||||
|
instead of proxying. Make it fall through to the proxy, or remove it.
|
||||||
|
|
||||||
|
5. **Optionally restrict the dashboard.** The site's domain is public, so the
|
||||||
|
login page is reachable from the internet unless you limit it. Agents only
|
||||||
|
need `/api/v1/report`. In the Vhost tab, add an `allow <your IP>; deny all;`
|
||||||
|
to `location /` and a separate unrestricted
|
||||||
|
`location = /api/v1/report { proxy_pass http://127.0.0.1:8095; }`.
|
||||||
|
Changes made in the Vhost tab persist. Back them up before
|
||||||
|
recreating the site.
|
||||||
|
|
||||||
## Adding a host
|
## Adding a host
|
||||||
|
|
||||||
On the server:
|
On the server:
|
||||||
|
|||||||
Reference in new issue
Block a user