Staging Web App Access
The staging web app, https://app.qubital-test.com, is open only to the team: a person signs in with Cloudflare Access, using the same email-code sign-in as this docs site. Northflank, where the app runs, refuses connections from the internet that don't come through Cloudflare, so a stranger can't reach the app directly; the remaining gaps are under "What this doesn't protect". The production web app is public and uses none of this.
Words used on this page
- Origin: the server that really holds the app. Here it's the
webappservice on Northflank (nginx serving the web build). - Ingress: Northflank's public front door,
35.198.178.75. It receives every request for every public Northflank service and routes it by the requested name.api.qubital-test.comuses the same address. - Proxied (Cloudflare's orange cloud): visitors connect to Cloudflare, and Cloudflare connects to the origin for them. DNS only (grey cloud) means visitors connect to the origin directly.
- Smoke check: the quick check the staging deploy runs at the end. It fetches the site and compares what it serves with what was deployed.
How a request gets in
Three locks work together: the first checks who you are, the other two close the direct routes around it. One route from the internet stays open:
Northflank sees where a connection comes from, not whose Cloudflare account sent it, so it lets in whatever Cloudflare sends. Our Cloudflare sends only what Access lets through. Cloudflare uses its published addresses, the ones the allow list accepts, only when it fetches a site for one of its customers; its other products, such as the WARP app, use other addresses. So nobody can simply connect from one themselves, but anyone can become a customer: someone could set up their own Cloudflare account so that Cloudflare connects to our origin for them, and that traffic never meets our Access. That's the dashed line; what it can reach is under "What this doesn't protect" below.
Lock 1: Cloudflare Access checks who you are
app.qubital-test.com is proxied, so every request reaches Cloudflare first. Cloudflare Access sits there and lets a request through only when it carries a valid sign-in.
- People sign in with their email. Cloudflare sends a one-time code only to addresses on the team's list (the Access policy
email-access-policy); any other address gets no email at all. It's the same Zero Trust organisation asdocs.qubital.space. - The sign-in lasts one month in that browser, then Access asks again.
- CI has no inbox. The smoke check sends a service token instead: two headers,
CF-Access-Client-IdandCF-Access-Client-Secret. The token isci-staging-web-smoke, allowed by the Service Auth policyci-service-token. Its values live only inqubital-apps' GitHub secrets (STAGING_ACCESS_CLIENT_ID,STAGING_ACCESS_CLIENT_SECRET) and the password manager.
Example. Open https://app.qubital-test.com in a private window. You get Cloudflare's sign-in page, not the app. Enter your work email, then the code from the email, and the app loads. No email arriving means the address isn't on the list, or a spam filter caught it (the code comes from noreply@notify.cloudflare.com).
Adding, removing and signing out are in Manage Staging Web App Access.
Lock 2: the origin answers only Cloudflare
Access only sees traffic that goes through Cloudflare. Northflank's ingress is a public address, so without a second lock anyone could connect to it directly, ask for app.qubital-test.com, and never meet the sign-in page.
So the web app's port in Northflank has an IP allow list: it accepts connections only from Cloudflare's published IPv4 ranges (15 ranges). Northflank answers every other address with 401 Unauthorized before the request reaches the app. Because the record is proxied, real visitors never connect to Northflank themselves: Cloudflare does, from those ranges.
Example. Ask the ingress directly, from any machine:
# --resolve sends the request straight to Northflank's address, skipping Cloudflare.
curl -sI --resolve app.qubital-test.com:443:35.198.178.75 https://app.qubital-test.com/
# HTTP/2 401
Faking the address doesn't help. Headers that claim a Cloudflare address, such as X-Forwarded-For: 104.16.0.1 or CF-Connecting-IP: 104.16.0.1, still get 401. Northflank checks where the connection really comes from, not what a header says.
IPv4 only is enough: Northflank's ingress has no IPv6 address, and its IP rules take only IPv4. If Cloudflare ever adds a range, requests from it are refused rather than let in. The list is copied from Cloudflare into qubital-infra (staging/webapp.json), and is changed by pull request.
Lock 3: fewer doors, and no plain text
- Northflank's own address is off. Every public Northflank port also gets a
*.code.runaddress. The allow list covers it too, but the web app's port has it turned off (disableNfDomain), so it answers404: one door fewer to think about. - Plain HTTP only redirects. Northflank answers an
http://request for the app with a301to thehttps://address and serves nothing over plain HTTP. - HTTPS requests stay encrypted all the way, with the certificate checked. A Cloudflare Configuration Rule,
staging-webapp, sets SSL to Strict for this host: Cloudflare connects to Northflank over HTTPS and accepts only a valid certificate forapp.qubital-test.com. - The certificate renews without opening a door. Northflank gets it from Let's Encrypt through a DNS record (DCV, domain control validation: the
_acme-challenge.appCNAME in Cloudflare), so renewal never needs a request to pass the allow list. Keep that record: without it the certificate isn't renewed, and Cloudflare then shows error 526. The current certificate expires on 2027-02-15. Northflank should renew it from about 2027-01-16; that first renewal is worth checking.
What this doesn't protect
- The data. The web app is only the screens: static files and a small public config (
/config.js). The data lives behind the staging API,api.qubital-test.com, which is public on purpose and protected by its own sign-in. Access keeps outsiders and search engines away from the staging site and its unreleased screens; it doesn't guard the API. - Requests through another Cloudflare account (the dashed line in the diagram). Cloudflare's addresses are shared by every Cloudflare customer, so someone could set up their own Cloudflare account to fetch our origin, and the allow list would let it through. They would get the static files and the public config, nothing else. Cloudflare rates an IP allow list "moderately secure". The stronger option is a Cloudflare Tunnel, which leaves no public origin at all; it's planned for when staging holds anything but test data, or when a second internal tool needs the same protection.
- Northflank's private network. Access and the allow list guard the public side only. Other services in the
qubital-stagingproject, such asapiandcentrifugo, reachwebapp:8080directly, and so does a team member with Northflank access throughnorthflank forward. - Whoever holds CI's token. The service token opens the site like a sign-in does. It's a secret, kept only in GitHub and the password manager.
- A person's inbox. The sign-in is as strong as the email account that receives the code.
- Leavers, until revoked. Removing an email from the list stops new sign-ins, but an open session lasts up to a month unless it's revoked.
Where each piece lives
| Piece | Where | Changed by |
|---|---|---|
Who may sign in (email-access-policy), the Access application, CI's policy ci-service-token | Cloudflare Zero Trust | The owner, in the dashboard |
| CI's service token | Cloudflare Zero Trust; its values in qubital-apps GitHub secrets and the password manager | The owner; refreshed before it expires each year |
The app DNS record (proxied) and the DCV record _acme-challenge.app | Cloudflare dashboard, zone qubital-test.com | The owner |
The Configuration Rule staging-webapp: SSL Strict, Rocket Loader off (it would rewrite the script tags, including /config.js's), Real User Monitoring off (the app's content security policy would block its script) | Cloudflare dashboard, zone qubital-test.com | The owner |
Zone settings for every proxied host of qubital-test.com: Browser Cache TTL "Respect Existing Headers" (otherwise Cloudflare tells browsers to keep the app's pages and /config.js for 4 hours after a deploy), Bot Fight Mode off (it may challenge the smoke check, an automated client) | Cloudflare dashboard, zone qubital-test.com | The owner |
The port: public, the domain, disableNfDomain, the IP allow list | qubital-infra, staging/webapp.json | A pull request |
| The certificate | Northflank, by DCV | Renewed automatically |
How it was checked
On 2026-11-17, from a machine that isn't a Cloudflare address, with the record still DNS only:
| Request | Result |
|---|---|
HTTPS straight to the ingress, asking for app.qubital-test.com | 401 from Northflank |
The same, with X-Forwarded-For, CF-Connecting-IP, X-Real-IP or True-Client-IP set to a Cloudflare address | 401 |
| Plain HTTP to the ingress | 301 to HTTPS, empty body |
The port's old code.run address | 404 |
The certificate served for app.qubital-test.com | Let's Encrypt, valid |
Then, on the same day, after the record was proxied:
| Request | Result |
|---|---|
https://app.qubital-test.com/ (or /config.js) without signing in | 302 to the Access sign-in page |
Plain http://app.qubital-test.com/ | 301 to HTTPS |
| A made-up service token | 401 (strict service token authentication is on, so a wrong token is refused outright instead of being sent to the sign-in page) |
CI's real service token, on /healthz | 200 |
| A browser, signed in with the email code | The app loads; /version.json names the deployed commit |
Straight to Northflank again, with and without a faked X-Forwarded-For | 401 |
- The setup was read back: Northflank's stored template equals
staging/webapp.json, and the running service shows the public port, the domain,disableNfDomainand the 15-range policy. - The 15 ranges really are Cloudflare's: each one was checked with the internet registries. Every range is registered to Cloudflare, Inc. or one of its regional companies, and only Cloudflare's own networks route them.
The design is in qubital-infra's architecture, under "Web app (D19)".