Zero Trust on one hostname: put a login in front of a single subdomain
Zero Trust, Cloudflare Access on one hostname (a self-hosted Access application)
What it is
Cloudflare Access is the part of Cloudflare Zero Trust that puts a sign-in page in front of a website before any request reaches it. You choose one hostname, such as a single subdomain, and write a rule saying who may enter. Everyone else sees a Cloudflare login screen instead of your site, and your Worker, Pages project, or server never receives their request.
The setup is called a self-hosted application. In the Cloudflare dashboard you open Zero Trust, then Access, then Applications (the wording may differ slightly), add a self-hosted application, give it the hostname, and attach a policy. A policy has an action, usually Allow, and a rule such as "emails equal to my own address". You also pick how people prove who they are: the simplest is a one-time PIN, where Cloudflare emails a short code to the address you typed, so you do not need Google or any other login provider set up.
After someone signs in, Cloudflare sets a cookie for that hostname and lets them through for a session length you choose, such as 24 hours. The Zero Trust Free plan covers up to 50 users, which is far more than one doctor and a few staff need. Access only works on names that are proxied (the orange cloud from lesson 1), because the check happens at Cloudflare before the request goes further.
Why it matters
Many of your small apps are for you alone or for your clinic, not the public: a draft dashboard, a notes tool, an admin page. Without Access, anyone who guesses the subdomain can open it. Access adds a real login without writing any login code in the app itself.
It works on one hostname at a time, so you can protect a single private subdomain and leave every public site, such as this tutor or your blogs, exactly as it is. Removing the Access application later makes the site public again, with nothing to change in the app.
A login in front of a page is a strong first layer, but it is not the whole story for health information. Never put real patient records in a learning app, even behind Access.
On your account
From your own setup: suppose you built a private page on a drkotha.com subdomain that only you should open, for example a draft version of a clinic tool. A self-hosted Access application on just that one hostname, with an Allow policy for your own email address and the one-time PIN login method, would mean that visiting it shows a Cloudflare screen asking for your email, sends you a code, and only then shows the page.
Your public sites on kosan.xyz, such as cloudflare.kosan.xyz, aiweekly.kosan.xyz, and ainews.kosan.xyz, would be untouched, because an Access application covers only the hostname you type into it.
This tutor stays public and does not use Access. Nothing in this lesson creates an Access application or policy, or changes cloudflare-tutor, ainews, aiweekly, any redirect rule, or any other Worker or DNS record.
Do this yourself
These stay in the dashboard, on your side. This site does not change DNS, routes, or other Workers.
- In the Cloudflare dashboard, open Zero Trust, then Access, then Applications (wording may differ slightly), start adding a self-hosted application, and write down the fields it asks for (application name, session duration, the hostname with its subdomain and domain boxes, and the policy and login method screens that follow) before pressing Cancel. Only look; do not save an application or policy for any hostname.