Watch
0
0
Fork
You've already forked hyperhive
0

forge: its own netns, HTTP on a unix socket, git over HTTPS only

The hive-forge container leaves the host netns and listens on no TCP port: Forgejo serves HTTP on a unix socket the gateway proxies to, and the built-in SSH server is off. The httpPort, sshPort and openFirewall options are removed with a message each.
This commit is contained in:
maia 2026-11-22 19:44:19 +01:00 • committed by mara
commit fc70f538ac
2 changed files with 153 additions and 117 deletions

View file

@ -157,31 +157,19 @@ Agents poll `HIVE_FORGE_URL` for Forgejo notifications and run every `hive-forge
## hive-forge container shape
Private Forgejo in a nixos-container named `hive-forge` (not `h-*`, so c0re's lifecycle scanner leaves it alone; manage it with the standard `nixos-container` CLI). The container keeps it from colliding with any `services.forgejo` the operator already runs on the host: separate systemd namespace, separate state dir, separate port.
Private Forgejo in a nixos-container named `hive-forge` (not `h-*`, so c0re's lifecycle scanner leaves it alone; manage it with the standard `nixos-container` CLI). The container keeps it from colliding with any `services.forgejo` the operator already runs on the host: separate systemd namespace, separate state dir, no host port.
It shares the host network namespace (`privateNetwork = false`): the container is for state and unit isolation, not network isolation. Agent containers, by contrast, are network-isolated and reach the forge through the gateway ([`HIVE_FORGE_URL`](#hive_forge_url-agents-reach-the-forge-via-the-gateway-by-domain)).
It has a network namespace of its own on the hive bridge (`privateNetwork = true`), like the other service containers. It listens on no TCP port at all: Forgejo serves HTTP on a unix socket, `/run/hive-forge/forgejo.sock`, in a directory the host bind-mounts into the container (mode `0770`, group `nginx`, so only the gateway and Forgejo itself get in). The vhost's `proxyPass` and the `= /metrics` location both name that socket. Agent containers reach the forge the same way an operator's browser does, through the gateway ([`HIVE_FORGE_URL`](#hive_forge_url-agents-reach-the-forge-via-the-gateway-by-domain)).
State lives at `/var/lib/nixos-containers/hive-forge/var/lib/forgejo/` and survives restarts and reboots; destroy the container to wipe it.
Only the swarm's forge host runs it (`services.hyperhive.deploy.forgejo.enable`, see [`2-handbook/swarm/services.md`](../../2-handbook/swarm/services.md)). Every other hive reaches that host's gateway by `forge.<swarm-domain>`.
### Network and port configuration
### Git over HTTPS only
```nix
# The SSH port is swarm-wide: every hive dials it. The HTTP port and whether
# THIS host opens them in its firewall are this host's deployment decisions.
services.hyperhive = {
swarm.forge.sshPort = 2222; # default — git-over-SSH, off the host's openssh on 22
deploy.forgejo = {
httpPort = 3000; # default — outside hyperhive's 7000 / 8100-8999
openFirewall = false; # default
};
};
```
The forge has no SSH server and no port options. Clone, push and pull over `https://<domain>/<owner>/<repo>.git`, through the gateway's vhost; no clone URL the forge shows offers SSH. Whether the gateway answers from outside the host is the gateway's own `openFirewall` option.
`sshPort` serves `git clone/push/pull` over SSH (`git@<domain>:owner/repo.git` with `-p 2222`). SSH goes straight to Forgejo, not through nginx.
`openFirewall` (default `false`) opens `httpPort` and `sshPort` on the host. Agents don't need it — they come through the gateway. Set it for a browser reaching `http://<host>:<httpPort>/` directly, or for external git clients pushing over SSH. Forge's gateway vhost doesn't need `openFirewall` — the gateway's own `openFirewall` option covers that path.
The old `swarm.forge.sshPort`, `swarm.forge.httpPort`, `deploy.forgejo.httpPort` and `deploy.forgejo.openFirewall` options no longer exist. A configuration that still sets one fails at evaluation with a message saying so.
### `rootUrl` override

View file

@ -22,12 +22,11 @@ that touches it.
│ uplink NIC — NAT MASQUERADE for the
│ bridge subnet (10.42.0.0/24 default)
┌──────────────────────────┴─────────────────────────────────────────┐
│ host netns — the host itself plus gateway / forge │
│ host netns — the host itself plus the gateway │
│ │
│ nginx :80/:443 [hive-gateway] │
│ dnsmasq 10.42.0.1:53 (DNS) + :67 (DHCP) [hive-gateway] │
│ squid 10.42.0.1:3128 (egress proxy) [hive-squid] │
│ forgejo :3000 http, :2222 git-ssh [hive-forge] │
│ hive-c0re dashboard 127.0.0.1:7000 (host service) │
│ │
│ hive-br0 10.42.0.1/24 │
@ -45,7 +44,7 @@ that touches it.
| ------------------------- | ----------------------- | -------------- | ----------------------------------------------------------------------------------------------- |
| gateway (host) | host | host addresses | nginx `:80`/`:443` (every vhost); dnsmasq `bridgeIp:53` + DHCP `:67` on the bridge |
| egress proxy (host) | host | `bridgeIp` | squid `bridgeIp:3128`; agents with a credential send HTTP and HTTPS through it |
| `hive-forge` | host (shared) | host addresses | forgejo `:3000` http, `:2222` git-ssh; fronted by the `forge.<swarm-domain>` vhost |
| `hive-forge` | private, veth on bridge | DHCP pool | forgejo on UDS `/run/hive-forge/forgejo.sock` → the `forge.<swarm-domain>` vhost; no SSH |
| `hive-matrix` | private, veth on bridge | DHCP pool | tuwunel on UDS `/run/hive-matrix/tuwunel.sock` → the matrix vhost; out to store, SSO, peers |
| `swarm-ci-runner` | private, veth on bridge | DHCP pool | outbound only (runner → forge); no inbound surface |
| `swarm-review-classifier` | private, veth on bridge | DHCP pool | outbound only (classifier → queue, secret store, swarm collector); no inbound surface |
@ -66,9 +65,8 @@ The flows, end to end:
only on the bridge.
- **HTTP** — `forge.` and `chat.` (under `swarm.domain`) plus the hive's
own dashboard name resolve to the bridge IP, land on nginx
`:80`/`:443`, and proxy to forgejo
`:3000`, tuwunel's unix socket, hive-c0re `127.0.0.1:7000`, or a per-agent
UI unix socket.
`:80`/`:443`, and proxy to forgejo's and tuwunel's unix sockets, hive-c0re
`127.0.0.1:7000`, or a per-agent UI unix socket.
- **Internet egress** — agent default route points at the bridge IP;
the host forwards + masquerades out its uplink.
- **Swarm** — peer hives reach each other's gateway and forge over HTTPS, and
@ -181,8 +179,8 @@ agent containers.
UI proxies, and any other HTTP services.
The **host** firewall is the only firewall. The swarm service
containers that share the host netns (forge, bao, the
metrics and log stores) run with `networking.firewall.enable = false`
containers that share the host netns (bao, the
queue) run with `networking.firewall.enable = false`
(`nix/container-modules/swarm-container.nix`): a NixOS firewall inside a
shared-netns container runs against the _host_ ruleset — at container
boot its `firewall-start` flushes the `nixos-fw` chains, rebuilds them