Cloudflare Access Setup
This guide covers configuring Cloudflare Access to protect the internal documentation site using GitHub as the identity provider.
Overview
Cloudflare Access provides Zero Trust authentication for the docs site:
- Users authenticate via GitHub OAuth
- Only DocuStack GitHub org members can access
- No authentication code in the application - purely infrastructure
Prerequisites
- Cloudflare account with the domain configured
- Cloudflare Pages project deployed
- GitHub OAuth application (or use Cloudflare's built-in GitHub integration)
Setup Steps
1. Enable Cloudflare Zero Trust
- Go to Cloudflare Zero Trust Dashboard
- Select your account
- Navigate to Access → Applications
2. Create Access Application
- Click Add an application
- Select Self-hosted
- Configure:
- Application name:
DocuStack Internal Docs - Session duration: 24 hours (or as needed)
- Application domain:
docs-internal.docustack.app
- Application name:
3. Configure GitHub Identity Provider
- Go to Settings → Authentication
- Click Add new under Login methods
- Select GitHub
- Configure:
- Use Cloudflare's managed GitHub integration, OR
- Create a GitHub OAuth App and enter credentials
4. Create Access Policy
- In the application settings, go to Policies
- Create a policy:
- Policy name:
GitHub Org Members - Action: Allow
- Include:
- Selector:
GitHub Organizations - Value:
docustack(your GitHub org name)
- Selector:
- Policy name:
5. Verify Configuration
- Open an incognito browser window
- Navigate to
https://docs-internal.docustack.app - You should be redirected to GitHub login
- After authentication, verify access is granted
Cloudflare Pages Integration
The Access policy automatically protects the Pages deployment. No additional configuration needed in the Docusaurus application.
Build Settings (Cloudflare Pages)
| Setting | Value |
|---|---|
| Build command | npm run build |
| Build output directory | build |
| Root directory | / |
| Node.js version | 18 |
Troubleshooting
User Can't Access
- Verify user is a member of the GitHub organization
- Check Access logs in Zero Trust dashboard
- Ensure the policy includes the correct GitHub org
Redirect Loop
- Clear browser cookies for the domain
- Verify the application domain matches exactly
- Check for conflicting Access policies
Security Considerations
- Access tokens are short-lived (configurable session duration)
- All access attempts are logged in Cloudflare
- GitHub org membership is verified on each authentication
- No credentials stored in the application
Cost
Cloudflare Access is free for up to 50 users. For larger teams, see Cloudflare Zero Trust pricing.