Loading
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 omnibusexternal_urland 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;upprints 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 sharedallow-http-httpsis neither created nor changed, so no other lab's reach moves.downremoves both rules.down --keep-snapshotremoves them too (a suspended lab has no VM to protect), andrestorerecreates them from state before the VM.- TLS is stated, not implied:
upprints it, the docs say it, andstatus --jsoncarriestls(none,https,private-ca). Plain HTTP on 80; 443 answers nothing untilhttps-private-caruns. status --jsonisschema_version10 withexternal_host,source_rangesandtls.- 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 from0.0.0.0/0and noallow-http-httpscreate when a range is given. The deny rule necessarily names0.0.0.0/0as 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.shnow probes readiness at127.0.0.1, because the omnibusexternal_urlcan be a name that does not resolve on the VM.- Docs: a "Browser reach" section in
gce/operations.md, paid for with equal cuts ingce/operations.mdandgce/https-private-ca.md; word budget 40484 of 40489.