Let up name its host and limit its ingress to a source range

Closes #39 (closed)

up now takes the name a browser reaches the lab by and, optionally, the sources allowed to reach it.

  • --host <fqdn> sets the omnibus external_url and caproni's ingress host. {ip} stands for the VM's address, which is only known after create, so --host '{ip}.nip.io' needs no DNS. The caller owns DNS; up prints the address the name must answer.
  • --source-range <cidr>[,<cidr>] (repeatable) limits ports 80 and 443 to those IPv4 ranges. The lab gets <instance>-ingress-allow (priority 90, the ranges) and <instance>-ingress-deny (priority 100, any source), both on the lab's own network tag, created before the VM. The shared allow-http-https is neither created nor changed, so no other lab's reach moves.
  • down removes both rules. down --keep-snapshot removes them too (a suspended lab has no VM to protect), and restore recreates them from state before the VM.
  • TLS is stated, not implied: up prints it, the docs say it, and status --json carries tls (none, https, private-ca). Plain HTTP on 80; 443 answers nothing until https-private-ca runs.
  • status --json is schema_version 10 with external_host, source_ranges and tls.
  • Bad CIDRs (octets above 255, prefix above 32, no prefix, IPv6, 0.0.0.0/0) and bad hosts (IP literal, one label, bad characters) are refused before any VM or rule exists.
flowchart LR
  B[Browser] -->|"HTTP 80 / 443"| GCE{{"GCE firewall"}}
  GCE -->|"priority 90: allow, source in range, tag = lab"| VM[Lab VM]
  GCE -->|"priority 100: deny, any source, tag = lab"| X[Refused]
  GCE -.->|"priority 1000: shared allow-http-https, outranked by the deny for this lab"| VM
  VM --> N[nginx / ingress]
  N -->|"Host = --host, else gitlab.sim.test on caproni"| G[GitLab]

Evidence

Selftests (gce/engine-selftest.sh, gce/bootstrap-omnibus-selftest.sh) pass. Each control was removed in turn and the suite went red: ingress rules not created, the shared rule still created, CIDR validation off, down not deleting the rules.

Live, omnibus CE 19.5 with --source-range <the control machine's /32> --host '{ip}.nip.io' (nip.io supplied the name, since no DNS of ours exists for a throwaway VM):

Source Result
Control machine, inside the range 200 on /users/sign_in
A second VM with an external address, outside the range no answer (curl timeout); the same VM reaches example.com with 200
The same second VM after the lab's two rules were deleted 200, through the shared rule

The last row is the control: the refusal comes from the two rules, not from the second VM's network. Port 443 answered nothing, as stated.

Notes

  • "No allow rule from 0.0.0.0/0" is tested as: no ALLOW rule on 80/443 from 0.0.0.0/0 and no allow-http-https create when a range is given. The deny rule necessarily names 0.0.0.0/0 as its source, because it denies every other source.
  • GCE rules are additive, so a lab cannot narrow the shared allow rule. The per-lab pair on the instance's own tag is what makes a range enforceable without touching it.
  • bootstrap-gitlab-omnibus.sh now probes readiness at 127.0.0.1, because the omnibus external_url can be a name that does not resolve on the VM.
  • Docs: a "Browser reach" section in gce/operations.md, paid for with equal cuts in gce/operations.md and gce/https-private-ca.md; word budget 40484 of 40489.

Merge request reports

Loading
Loading