---
title: Free hosting behind Cloudflare · Organization docs
description: The whole platform cannot run on Cloudflare's free compute alone (see What does not run on Workers ). The free route is to run the bundled stack on one…
url: https://spaceworkslabs.tech/docs/organization/deployment-cloudflare/
updated: 2026-11-21
---

[Space Works Organization](https://spaceworkslabs.tech/docs/organization/) Start here
- [Overview](https://spaceworkslabs.tech/docs/organization/overview/)
- [Glossary](https://spaceworkslabs.tech/docs/organization/guides-start-glossary/)
- [Quickstart for members](https://spaceworkslabs.tech/docs/organization/guides-start-quickstart-member/)
- [Quickstart for organisation owners](https://spaceworkslabs.tech/docs/organization/guides-start-quickstart-owner/)
- [Quickstart for platform operators](https://spaceworkslabs.tech/docs/organization/guides-start-quickstart-operator/)
Features
- [Certificates](https://spaceworkslabs.tech/docs/organization/features-certificates/)
- [Groupings](https://spaceworkslabs.tech/docs/organization/features-groupings/)
- [Member cards](https://spaceworkslabs.tech/docs/organization/features-member-cards/)
- [Member portal](https://spaceworkslabs.tech/docs/organization/features-member-portal/)
- [Notifications](https://spaceworkslabs.tech/docs/organization/features-notifications/)
- [Organisations](https://spaceworkslabs.tech/docs/organization/features-organisations/)
- [Payments](https://spaceworkslabs.tech/docs/organization/features-payments/)
- [Plans and join forms](https://spaceworkslabs.tech/docs/organization/features-plans-and-join-forms/)
- [Public page](https://spaceworkslabs.tech/docs/organization/features-public-page/)
- [Receipts and refunds](https://spaceworkslabs.tech/docs/organization/features-receipts-and-refunds/)
- [Renewals](https://spaceworkslabs.tech/docs/organization/features-renewals/)
- [Reports and analytics](https://spaceworkslabs.tech/docs/organization/features-reports-and-analytics/)
- [Self-hosting](https://spaceworkslabs.tech/docs/organization/features-self-hosting/)
- [Sign-in](https://spaceworkslabs.tech/docs/organization/features-sign-in/)
- [Staff and roles](https://spaceworkslabs.tech/docs/organization/features-staff-and-roles/)
- [Units](https://spaceworkslabs.tech/docs/organization/features-units/)
- [Web analytics](https://spaceworkslabs.tech/docs/organization/features-web-analytics/)
- [Payments](https://spaceworkslabs.tech/docs/organization/payments/)
- [Tax on membership payments](https://spaceworkslabs.tech/docs/organization/gst/)
- [Reports](https://spaceworkslabs.tech/docs/organization/reports/)
- [Email and chat notifications](https://spaceworkslabs.tech/docs/organization/notifications/)
Install and run
- [Backups and restore](https://spaceworkslabs.tech/docs/organization/guides-hosting-backups-and-restore/)
- [Choose your hosting](https://spaceworkslabs.tech/docs/organization/guides-hosting-choose-your-hosting/)
- [Monitoring and health](https://spaceworkslabs.tech/docs/organization/guides-hosting-monitoring-and-health/)
- [Updates and rollback](https://spaceworkslabs.tech/docs/organization/guides-hosting-updates-and-rollback/)
- [Deploying on a server (VPS)](https://spaceworkslabs.tech/docs/organization/deployment-vps/)
- [Deploying with managed services (cloud)](https://spaceworkslabs.tech/docs/organization/deployment-cloud/)
- [Free hosting behind Cloudflare](https://spaceworkslabs.tech/docs/organization/deployment-cloudflare/)
- [Hosting the site on Netlify](https://spaceworkslabs.tech/docs/organization/deployment-netlify/)
- [Configuration reference](https://spaceworkslabs.tech/docs/organization/configuration/)
[All docs](https://spaceworkslabs.tech/docs/)

Space Works Organization · Install and run

# Free hosting behind Cloudflare

The whole platform cannot run on Cloudflare's free compute alone (see[What does not run on Workers](#what-does-not-run-on-workers) ). The free route is to run the bundled stack on one always-free virtual machine, or a machine at home, and put Cloudflare in front of it:

| Piece | Where | Why |
| --- | --- | --- |
| The stack (app, worker, beat, PostgreSQL, Redis) | One always-free VM, or a home server | The app needs a long-running Node process, Postgres, Redis and background jobs. |
| HTTPS, DNS, CDN, basic WAF | Cloudflare (free plan) | Terminates HTTPS and shields the server. |
| Cloudflare Tunnel | `cloudflared`container on the server | Dials out to Cloudflare, so the server needs**no open ports**. |
| File storage | Cloudflare R2 | Files live outside the VM and survive its loss. |
| Email | Resend free tier (or Amazon SES) | Needs a verified sending domain. |

Free tiers change. Check each provider's current limits and terms before you rely on them, and watch for idle-resource reclamation rules on always-free VMs.

## 1. Get a server

### Option A: Oracle Cloud Always Free (Arm)
- Create an Oracle Cloud account (a payment card is asked for identity checks; stay inside the Always Free resources).
- Create a compute instance: image**Canonical Ubuntu**(a current LTS), shape**VM.Standard.A1.Flex**(Ampere Arm; check the current Always Free allowance for OCPUs and memory and give the stack as much as it allows), a public IPv4 address, and your SSH public key. Capacity in a region is sometimes full; try again later or in another availability domain.
- Release images support`aarch64`, so Arm is fine.
- Firewall:**you do not need to open any inbound port except SSH.**Leave the security list as it is (SSH only). Oracle's Ubuntu images also ship host firewall rules; keep them. The tunnel only makes outbound connections.
- Update the machine and reboot:`sudo apt update && sudo apt full-upgrade -y && sudo reboot`.

### Option B: a machine at home

Any 64-bit Linux box (x86_64 or arm64) that stays on. Nothing needs forwarding on your router. A home connection that changes IP address is not a problem, because the tunnel dials out.

## 2. Add your domain to Cloudflare

Add your domain to a free Cloudflare account and switch its nameservers to Cloudflare's. You will use a host name such as`members.example.org`.

## 3. Create the tunnel
- In the Cloudflare dashboard open**Zero Trust**(it asks you to pick a plan; choose the free one), then**Networks → Tunnels → Create a tunnel → Cloudflared**.
- Name it, then on the install page choose the**Docker**connector.**Copy only the token**: the long string after`--token`. Do not run the command it shows; the installer starts the connector for you. Treat the token as a secret: anyone who has it can run your tunnel.
- On the**Published application / Public hostname**step add: -**Hostname:** `members.example.org`-**Service type:** `HTTP`-**URL:** `backend:3000`

`backend`is the app's name on the stack's private Docker network, where the connector runs. Cloudflare creates the DNS record (a proxied`CNAME`to the tunnel) for you.

## 4. Install

On the server: `curl -fsSL https://raw.githubusercontent.com/SpaceWorks-Labs/SpaceWorks-Organization/main/install.sh | bash`

Answer the questions (see the README); the choices that matter here:
- **HTTPS:** `4) Cloudflare Tunnel`. Enter your public domain, then paste the tunnel token (it is hidden as you type). The installer writes it only to the owner-only`.env`as`CLOUDFLARE_TUNNEL_TOKEN`; it is never printed, and the app itself never receives it.
- **File storage:** `2) External S3-compatible bucket`, with your R2 details (section 6).
- **Email:**your relay's details (section 7).

The installer chooses`SWO_LAYER='cloudflared'`, which adds`docker/compose.cloudflared.yml`: Caddy is switched off, no port is published, and a pinned`cloudflare/cloudflared`container runs beside the app with a health check. Check the connector with`bash scripts/vps-status.sh`:`cloudflared`should be listed as healthy, and the tunnel shows**Healthy**in the Cloudflare dashboard.

To switch an existing install, edit`.env`(see[Moving between modes](https://spaceworkslabs.tech/docs/organization/deployment-vps/#moving-between-modes) ): `SWO_LAYER='cloudflared' CLOUDFLARE_TUNNEL_TOKEN='<token>' PUBLIC_APP_BASE_URL='https://members.example.org'`

remove`ALLOW_PLAIN_HTTP`, then`scripts/spaceworks-compose.sh bundled up -d`.

## 5. HTTPS and the client address
- **SSL/TLS mode.**With a Tunnel, the browser's HTTPS ends at Cloudflare and the hop to your server is carried inside the tunnel's own encrypted connection, not over the public internet to an origin port. There is no origin certificate to manage, and**Full (strict)**is not needed. Leave the SSL/TLS mode as the dashboard offers and turn on**Always Use HTTPS**.
- **Client address.**The layer sets`TRUSTED_PROXY_IP_HEADER`to`cf-connecting-ip`for the app. This is safe only because the tunnel is the app's sole way in: the app publishes no port, so the header can only come from Cloudflare. Never also expose the app's port directly, or anyone could forge the header and dodge rate limits. The bundled stack's default (`x-real-ip`, set by Caddy) is unchanged for the other layers.
- **Sign-in and card links**use`PUBLIC_APP_BASE_URL`, which must be the`https://`address you published.

## 6. Storage on R2

Create a private R2 bucket and an API token limited to it, exactly as in[Object storage on Cloudflare R2](https://spaceworkslabs.tech/docs/organization/deployment-cloud/#object-storage-on-cloudflare-r2) . In the installer enter`https://<account-id>.r2.cloudflarestorage.com`, region`auto`, the bucket and the key pair. R2 has a free allowance; check Cloudflare's current limits. Files are served through the app, so no public bucket or CORS rules are needed.

## 7. Email with Resend

Cloudflare's free plan does not send transactional email; use Resend's free tier or Amazon SES (check their current limits).
- In Resend,**Domains → Add domain**for your sending domain and add the DNS records it shows (SPF, DKIM) in Cloudflare DNS. Set them to**DNS only**(grey cloud). Wait until Resend shows the domain as verified.
- Create an API key limited to sending.
-  Either: - at install time, use Resend's SMTP relay (`smtp.resend.com`, port`465`, login`resend`, the API key as the password); or - in`.env`set the API provider, then`scripts/spaceworks-compose.sh bundled up -d`: `bash EMAIL_PROVIDER='resend' RESEND_API_KEY='<api key>' EMAIL_FROM='Your Organisation <noreply@example.org>'`4. Bounces and complaints: in Resend add a webhook to`https://members.example.org/api/email/webhooks/resend`for the delivery events, copy its signing secret (`whsec_…`) into`EMAIL_WEBHOOK_SECRET`, and restart. Unverified requests are refused. 5. Send a test message from**Super admin → Settings**.

## 8. Backups to R2

The stack already writes local backups (see[Backups and restore](https://spaceworkslabs.tech/docs/organization/deployment-vps/#backups-and-restore) ). A free VM can be reclaimed or lost, so keep an encrypted copy elsewhere: open the[installer menu](https://spaceworkslabs.tech/docs/organization/deployment-vps/#the-installer-menu) and choose**off-site copies**(option 5, run nightly by`scripts/vps-offsite-backup.sh`). It asks for an S3-compatible bucket: use a**second R2 bucket**and a token limited to it, not the app's file bucket. Everything is encrypted with an`age`key before upload; keep the private key in a password manager, off the server. A restore on a new machine is covered in[Restore on a new server](https://spaceworkslabs.tech/docs/organization/deployment-vps/#restore-on-a-new-server) .

## 9. Cloudflare settings on the free plan

**Block the internal hooks.**The tunnel forwards straight to the app, so Caddy's block of`/api/internal/*`is not in the path. These endpoints also demand the`CRON_SECRET`bearer, but keep them private anyway. In**Security → WAF → Custom rules**add a rule, action**Block**: `(starts_with(http.request.uri.path, "/api/internal/"))`

**Rate limiting.**The app rate limits sign-in, forms and APIs itself, per client address. A Cloudflare rate-limit rule on`/login`and`/start`is an optional extra layer; check which rule types and how many your plan allows. In**Security → Settings**keep**Bot Fight Mode**on, but do not challenge`/api/webhooks/*`or`/api/email/webhooks/*`: payment and email providers call those. If a challenge blocks them, add a skip rule for those paths.

**Caching.**Cloudflare caches only static file types by default, so most dynamic pages are already not cached. Make it explicit with**Caching → Cache Rules**:

| Rule | Action |
| --- | --- |
| Path starts with`/api`,`/dashboard`,`/account`,`/super-admin`,`/pay`,`/verify`,`/login` | **Bypass cache** |
| Path starts with`/_next/static`or`/brand` | **Eligible for cache**, edge TTL: respect origin (the files are fingerprinted and immutable) |

Never cache anything that carries sessions, money state, member records, cards or`/verify`pages. Turn off any setting that rewrites HTML (Rocket Loader, Auto Minify) if it appears; it can break the app's scripts.

## What does not run on Workers

Cloudflare Workers and Pages on the free plan cannot host this app by themselves:
- Workers allow only a small amount of CPU time per request on the free plan (check the current limit); a Next.js server-rendered app with Server Actions and PDF and image work exceeds it.
- Cards and photos use native modules (`sharp`) that do not run in the Workers runtime.
- It needs PostgreSQL 16 and Redis, which Workers cannot run (a hosted database would work only with a different data layer than this one).
- The worker and beat roles are long-running BullMQ processes; Workers are request-driven. On a host that runs only the web service, Inngest or a Worker cron trigger can drive the jobs instead: see[Fully cloud with Inngest](https://spaceworkslabs.tech/docs/organization/deployment-cloud/#fully-cloud-with-inngest) .

Hence the VM plus Tunnel design above.

## Optional and experimental: website on Workers

The split layout in[DEPLOYMENT_NETLIFY.md](https://spaceworkslabs.tech/docs/organization/deployment-netlify/) renders the public site from the`frontend/`workspace and sends data through a signed gateway to the backend. In principle that frontend could be built for Cloudflare Workers with the OpenNext Cloudflare adapter instead of Netlify, with the same environment values (`BACKEND_ORIGIN`,`FRONTEND_GATEWAY_SECRET`, …) and the backend installed with**Website: 2) No, backend only**.**This is experimental and untested here**: no build script, Wrangler configuration or CI covers it, and the frontend may need changes to run in the Workers runtime. Netlify is the supported split target.

## Troubleshooting
- **502 or "Bad gateway":**the tunnel is up but cannot reach`backend:3000`. Check the public hostname's service is`HTTP`with URL`backend:3000`, and`scripts/spaceworks-compose.sh bundled ps`.
- **Tunnel shows Down:** `scripts/spaceworks-compose.sh bundled logs cloudflared`; the server needs outbound access to Cloudflare. A wrong or rotated token fails to connect: update`CLOUDFLARE_TUNNEL_TOKEN`in`.env`and`up -d`.
- **Everyone shares one rate limit or sees "unknown" addresses:**the app is receiving no`cf-connecting-ip`, for example because traffic reached it by another route. Use the tunnel only.

From[SpaceWorks-Organization/docs/DEPLOYMENT_CLOUDFLARE.md](https://github.com/SpaceWorks-Labs/SpaceWorks-Organization/blob/7cd1441838559f323c26e5ddbab0e72181b4bc4d/docs/DEPLOYMENT_CLOUDFLARE.md) at 7cd1441, updated 2026-11-21.[Suggest a change](https://github.com/SpaceWorks-Labs/SpaceWorks-Organization/edit/main/docs/DEPLOYMENT_CLOUDFLARE.md)  [PreviousDeploying with managed services (cloud)](https://spaceworkslabs.tech/docs/organization/deployment-cloud/) [NextHosting the site on Netlify](https://spaceworkslabs.tech/docs/organization/deployment-netlify/)

On this page
- [1. Get a server](#1-get-a-server)
- [Option A: Oracle Cloud Always Free (Arm)](#option-a-oracle-cloud-always-free-arm)
- [Option B: a machine at home](#option-b-a-machine-at-home)
- [2. Add your domain to Cloudflare](#2-add-your-domain-to-cloudflare)
- [3. Create the tunnel](#3-create-the-tunnel)
- [4. Install](#4-install)
- [5. HTTPS and the client address](#5-https-and-the-client-address)
- [6. Storage on R2](#6-storage-on-r2)
- [7. Email with Resend](#7-email-with-resend)
- [8. Backups to R2](#8-backups-to-r2)
- [9. Cloudflare settings on the free plan](#9-cloudflare-settings-on-the-free-plan)
- [What does not run on Workers](#what-does-not-run-on-workers)
- [Optional and experimental: website on Workers](#optional-and-experimental-website-on-workers)
- [Troubleshooting](#troubleshooting)
