Field Notes

OpenClaw Multiplayer Behind Cloudflare Access

An end-to-end setup for per-user identity, agent routing, roles, device enrollment, and Docker sandboxing on a shared OpenClaw Gateway.

I got this working over a weekend. The individual pieces are documented, but the complete path is scattered across identity, proxy, authorization, and sandboxing guides.

This is the exact sequence that worked with OpenClaw 2026.9.2 on Ubuntu 24.04 in an unprivileged Proxmox LXC. It keeps the final working configuration, the failures that still have diagnostic value, and the checks I used to prove the boundary was real.

OpenClaw is moving quickly. Check your version before copying it.

openclaw --version

The finished path

Browser
  -> Cloudflare Access
     -> one-time PIN or Google authentication
     -> exact-email allow policy
  -> Cloudflare Tunnel
     -> cf-access-authenticated-user-email
  -> 127.0.0.1:18789
  -> OpenClaw trusted-proxy authentication
     -> identity scope grant
     -> explicit agent routing
     -> role ceiling
     -> allowed team agent
     -> required Docker sandbox

There is no multiplayer switch. Multiplayer starts when the Gateway stops treating everyone as the same owner and starts receiving a verified identity for each person.

1. Verify the existing Gateway

This starts with an installed, onboarded Gateway running as a service. Confirm that it is healthy and that you are editing the configuration used by the service account.

openclaw doctor
openclaw gateway status
openclaw config file
systemctl --user status openclaw-gateway

Keep the Gateway on loopback. The tunnel should be its only ingress.

openclaw config set gateway.bind '"loopback"'
openclaw gateway restart

Confirm that it is listening on 127.0.0.1:18789, not a LAN or public interface.

ss -ltnp | grep 18789

Verify linger instead of assuming it

On Linux, the Gateway runs as a systemd --user service. That service needs linger enabled to survive the end of the SSH session.

Do not assume the installer handled this. I found Linger=yes on one instance and Linger=no on another built through the same process.

loginctl show-user "$(whoami)" --property=Linger

If it reports Linger=no, enable it and check again:

loginctl enable-linger "$(whoami)"
loginctl show-user "$(whoami)" --property=Linger

Run loginctl enable-linger with elevated privileges if your account cannot change the setting.

The failure is misleading: the Gateway works while SSH is connected, then the public URL returns a Cloudflare page saying it cannot reach the host or origin after you disconnect. It looks like a tunnel problem. The Gateway process is gone.

2. Create the Cloudflare Tunnel connector

I used a remotely managed tunnel created in the Cloudflare dashboard. There is no local config.yml or tunnel credentials JSON file in this setup.

  1. In Cloudflare, go to Networking -> Tunnels.
  2. Select Create a tunnel.
  3. Choose cloudflared, name the tunnel, and create it.
  4. On Install and run connectors, select the operating system and architecture for the Gateway host. I used Debian and 64-bit for Ubuntu 24.04.
  5. If cloudflared is not installed, run the package installation block Cloudflare generates for that host.
  6. Copy Cloudflare’s service-install command and run it on the Gateway host. Its shape is:
sudo cloudflared service install <TUNNEL_TOKEN_FROM_CLOUDFLARE>

<TUNNEL_TOKEN_FROM_CLOUDFLARE> is intentionally fake. Use the complete command generated for your tunnel. The token is a credential that allows a connector to run that tunnel; paste it into the host, not source control or documentation.

Verify both sides:

sudo systemctl status cloudflared --no-pager
cloudflared --version

The Cloudflare tunnel page should show the connector as Healthy before you continue.

Stop there for now. Do not add the published application route yet. Section 3 establishes the Access policy first; after that, route the protected hostname to http://127.0.0.1:18789.

Do not open port 18789 in the host firewall or forward it from your router. cloudflared connects outward to Cloudflare; the Gateway remains on loopback.

3. Protect the hostname with Cloudflare Access

In Cloudflare Zero Trust:

  1. Go to Access controls -> Applications.
  2. Add a Self-hosted application.
  3. Set the public hostname to <gateway-hostname> and leave the path blank.
  4. Add an Allow policy with an Include rule:
    • Selector: Emails
    • Value: Add each permitted email address explicitly.
  5. Do not grant access using Everyone, Emails ending in, or Login Methods = One-time PIN. One-time PIN can be enabled as an authentication method, but the exact-email rule should determine who is allowed through.

The policy determines who may reach the Gateway. The login method determines how an allowed person proves their identity. Cloudflare Access is the first authorization boundary; OpenClaw’s allowUsers list will repeat the same restriction behind it.

Option A: one-time PIN

This is the shortest path. One-time PIN requires no external identity provider or Google Cloud project.

  1. Go to Integrations -> Identity providers.
  2. Add One-time PIN if it is not already available.
  3. Enable it as a login method on the Access application.
  4. Test with one of the exact addresses in the Access policy.

Cloudflare sends a single-use PIN only after the address passes the Access policy. The PIN expires after ten minutes. If an email security product follows the link first, request a new code and allowlist noreply@notify.cloudflare.com.

Option B: Google authentication

In Google Cloud:

  1. Create or select a project.
  2. Open Google Auth Platform and configure the consent screen.
  3. Choose an External audience for ordinary Gmail accounts.
  4. If the app remains in testing, add every permitted account under Audience -> Test users.
  5. Create an OAuth client with application type Web application.
  6. Add this authorized JavaScript origin:
https://<team-name>.cloudflareaccess.com
  1. Add this authorized redirect URI:
https://<team-name>.cloudflareaccess.com/cdn-cgi/access/callback
  1. Record the client ID and client secret.

Back in Cloudflare Zero Trust:

  1. Go to Integrations -> Identity providers.
  2. Add Google.
  3. Enter the client ID and client secret.
  4. Save it, then use Cloudflare’s Test action.
  5. Enable Google as a login method on the Access application.

Google provides the authentication method. The exact-email Access policy still decides whether that authenticated person can reach the Gateway.

Publish the protected hostname

After the Access application and at least one login method are configured:

  1. Go to Networking -> Tunnels and select the tunnel.
  2. On Routes, add a Published application route.
  3. Set the hostname to the same <gateway-hostname> protected by the Access application.
  4. Set the service URL to:
http://127.0.0.1:18789
  1. Save the route.

Open https://<gateway-hostname> in a private browser window. Cloudflare should require authentication before any OpenClaw page is returned.

4. Make Cloudflare identity authoritative in OpenClaw

Set trusted-proxy mode and trust only the loopback connection used by cloudflared.

openclaw config set gateway.auth.mode '"trusted-proxy"'
openclaw config set gateway.trustedProxies '["127.0.0.1", "::1"]'
openclaw config set gateway.auth.trustedProxy.allowLoopback true
openclaw config set gateway.auth.trustedProxy.userHeader '"cf-access-authenticated-user-email"'
openclaw config set gateway.auth.trustedProxy.requiredHeaders '["cf-access-jwt-assertion"]'
openclaw config set gateway.controlUi.allowedOrigins '["https://<gateway-hostname>"]'
openclaw config set gateway.auth.trustedProxy.allowUsers '["<admin-email>", "<user-email>"]'

Give the administrator an identity-based scope grant:

openclaw config set gateway.auth.identityScopes '{
  "<admin-email>": ["operator.admin"]
}'

openclaw gateway restart

Open https://<gateway-hostname> in a private browser window and sign in as <admin-email>. Confirm that Settings is visible.

If the UI loads without Settings or Plugins, the proxy identity reached OpenClaw but received no authority. Check the exact email returned by Cloudflare and the matching identityScopes key.

Why allowLoopback matters

cloudflared reaches the Gateway from 127.0.0.1, so this topology requires allowLoopback.

The cost is real: any process on the host that can reach port 18789 can send the same identity header. The proxy must overwrite client-supplied forwarding and identity headers, the Gateway must remain bound to loopback, and agent execution must be sandboxed. Trusted-proxy authentication without sandboxing gives an agent a path to impersonate another user.

5. Configure device enrollment

Without auto-approval, every new browser requires manual device approval. Enable it with a deliberately narrow persistent grant:

openclaw config set gateway.auth.trustedProxy.deviceAutoApprove.enabled true
openclaw config set gateway.auth.trustedProxy.deviceAutoApprove.scopes '[
  "operator.read",
  "operator.write",
  "operator.questions"
]'

Add operator.approvals only if those users should approve tool execution.

Never add operator.admin here. Device approval creates a persistent credential. Removing someone from Cloudflare Access blocks the normal browser path but does not erase a previously issued device credential.

Changing the auto-approval scope list is forward-only. Existing devices keep their old scopes. Remove and re-enroll any device created under a broader policy.

openclaw devices list --json
openclaw devices remove <device-id> --json

6. Preserve local CLI access without Tailscale

This section matters only if you are enabling named roles and cannot use Tailscale. Named roles reject operator connections that have no verified human identity. The local CLI normally authenticates with a device or bootstrap token that is not bound to a person, so enabling roles can break Gateway RPC calls with:

operator role policies require a verified user identity for this authentication method

The cleaner solution is Tailscale identity: the CLI receives a verified user identity without introducing a shared secret. If Tailscale is available in your environment, use it and skip this section.

Tailscale was not available in this deployment. The fallback is a Gateway password. Put it in the service environment rather than openclaw.json, then load the same value into the administrative shell. The Gateway needs the password to validate the connection; the CLI needs it to authenticate.

Generate a password and store it outside openclaw.json:

openssl rand -base64 36
install -m 600 /dev/null ~/.openclaw/gateway.env

Put one line in ~/.openclaw/gateway.env:

OPENCLAW_GATEWAY_PASSWORD=<generated-value>

Create a systemd drop-in instead of editing the OpenClaw unit, which installers can replace:

mkdir -p ~/.config/systemd/user/openclaw-gateway.service.d

Create ~/.config/systemd/user/openclaw-gateway.service.d/override.conf:

[Service]
EnvironmentFile=%h/.openclaw/gateway.env

Load it and restart:

systemctl --user daemon-reload
openclaw gateway restart
systemctl --user cat openclaw-gateway
systemctl --user show openclaw-gateway -p EnvironmentFiles

The CLI is a separate process. It needs the same value in its own environment:

set -a
. ~/.openclaw/gateway.env
set +a

Put that sourcing command in the login shell configuration used for administrative work. Cron jobs, non-interactive SSH commands, and other automation do not necessarily load the same shell file; source the environment explicitly in those callers.

This is not encryption. It keeps the password out of the configuration file most likely to be read, backed up, or pasted during troubleshooting.

7. Give non-admin users somewhere useful to land

Authentication can work while the product experience is still broken.

My first non-admin user signed in successfully and landed in main, the original administrative agent. The role policy correctly blocked the first thing they tried to do. That was a secure denial, but it was a bad landing experience: the UI had placed them inside an agent they were not supposed to use.

Fix the agent roster and the default route together. Keep main for administrative work, create a separate team agent, and make ownership explicit:

openclaw config set agents.ownership '"explicit"'

openclaw config set agents.entries.main.identity.name '"Admin Core"'

openclaw config set agents.entries.team '{
  "identity": {
    "name": "Team Workspace",
    "theme": "Shared operational work"
  },
  "sandbox": {
    "mode": "all"
  }
}'

This example inherits the deployment’s default model. Set agents.entries.team.model separately when the team agent needs a different model. Do not publish an account-specific authentication profile or setup identifier with the model name.

Set the team agent as the system agent:

openclaw config set agents.defaults.systemAgent.agentId '"team"'
openclaw gateway restart

agents.defaults.systemAgent.agentId supplies the default owner for the Control UI, unscoped session routing, and other ambient Gateway work. Existing sessions keep their original owner; test with a new browser session.

Do not confuse this with acp.defaultAgent. That setting selects an ACP harness when an ACP session is spawned without an agentId; it does not control the normal browser landing agent.

The default route decides where a new user starts. It does not hide main. Agent visibility comes from the role ceiling.

8. Limit each role to the agents it should expose

Cloudflare Access establishes identity. Device approval and identityScopes establish grants. Roles put a ceiling over those grants.

That ceiling mattered sooner than I expected: a new user started probing escape boundaries within minutes of receiving access. Roles do not turn one Gateway into hostile multi-tenant infrastructure, but they limit control-plane authority, session access, and whether a session must be sandboxed.

This deployment uses two roles:

  • admin: can configure the Gateway and use every agent.
  • crew: can collaborate in shared sessions, but can only create or run sessions on team.

The role names are not important. The agent list, session access, scope ceiling, and sandbox requirement are.

openclaw config set gateway.roles '{
  "default": "crew",
  "definitions": {
    "admin": {
      "sessions": {"others": "write"},
      "agents": "*",
      "scopes": ["operator.admin"]
    },
    "crew": {
      "sessions": {"others": "write"},
      "agents": ["team"],
      "sandbox": "required",
      "scopes": [
        "operator.read",
        "operator.write",
        "operator.questions"
      ]
    }
  }
}'

openclaw gateway restart

Roles only reduce existing grants; they cannot create authority. An admin role over an empty grant is still empty.

Assign admin only to a browser profile that should configure the Gateway:

openclaw users list

openclaw gateway call users.setRole \
  --params '{"profileId":"<profile-uuid>","role":"admin"}' --json

The password-authenticated local CLI uses the special gateway-owner profile and does not need an assignable personal admin role. Use role: null with users.setRole to clear an assignment back to the default. Role changes close that profile’s active connections so the new ceiling applies on reconnect.

operator.admin already implies every operator.* scope. Listing lower scopes beside it adds nothing.

The combined result is the intended experience:

UserLanding agentAgent pickerExecution
AdministratorConfigurableAdmin Core and Team WorkspaceHost access on main; sandboxed on team
Crew memberTeam WorkspaceTeam Workspace onlyAlways sandboxed

9. Install the Docker sandbox backend

Sandboxing is not optional in this topology. allowLoopback trusts local callers; an unsandboxed agent is a local caller.

Install Docker Engine from Docker’s official Ubuntu repository. On an unprivileged Proxmox LXC, enable nesting in the LXC configuration first. Then verify the engine:

systemctl status docker
docker run --rm hello-world

Build the default OpenClaw sandbox image. The helper script exists in a source checkout but is not shipped in the npm package, so this inline build works for either installation:

docker build -t openclaw-sandbox:bookworm-slim - <<'DOCKERFILE'
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
  bash ca-certificates curl git jq python3 ripgrep \
  && rm -rf /var/lib/apt/lists/*
RUN useradd --create-home --shell /bin/bash sandbox
USER sandbox
WORKDIR /home/sandbox
CMD ["sleep", "infinity"]
DOCKERFILE

docker images openclaw-sandbox

Enable Docker sandboxing for non-main sessions and avoid one shared runtime for the entire agent:

openclaw config set agents.defaults.sandbox.mode '"non-main"'
openclaw config set agents.defaults.sandbox.backend '"docker"'
openclaw config set agents.defaults.sandbox.scope '"session"'
openclaw gateway restart

OpenClaw currently documents durable-profile isolation behavior in addition to the configured scope. Do not treat scope: session as hostile tenant isolation or promise that every tab receives a permanently separate environment. It is still the correct setting to avoid an intentionally shared sandbox.

Do not copy docker.user blindly

On 2026.9.2, explicitly setting agents.defaults.sandbox.docker.user to 1000:1000 produced a root-owned /workspace that the container user could not write. New sandboxes were seeded as root, so manually changing ownership did not survive recreation.

Leave docker.user unset unless you have verified a newer release seeds the workspace with matching ownership. The remaining boundaries still matter: no host filesystem, no network by default, capDrop: ALL, and, in this deployment, an unprivileged outer LXC.

10. Verify the complete setup

Run the host-side checks:

openclaw security audit
openclaw users list
openclaw devices list --json
openclaw config get gateway.roles
openclaw sandbox explain

The security audit intentionally reports trusted-proxy authentication as critical. It should also warn about the deliberate loopback trust and device auto-approval. Those warnings do not prove the configuration is wrong; they identify the boundary you now own.

The audit does not validate whether gateway.roles.default is too permissive. Check it yourself.

Sign in as a non-admin user in a fresh browser session and verify the user-facing path before testing commands:

  1. The new session opens on Team Workspace.
  2. Admin Core does not appear in the agent picker.
  3. The user can create and participate in shared team sessions.
  4. Administrative settings and approval authority remain unavailable.

Create a non-main session as a non-admin user and ask the agent to execute these exact commands:

CommandExpected resultWhat it proves
pwd/workspaceExecution is inside the container
id -uContainer UIDThe command actually ran
curl -s -m 5 https://example.comDNS or network failureDefault network isolation is active
ls /rootContainer root, not host dataHost root is not mounted
ls -la /workspaceSeeded agent filesThe isolated workspace exists

Then verify on the host:

openclaw sandbox list
ls -la ~/.openclaw/sandboxes/

Ask for the commands explicitly. A question such as “who am I?” can be answered from the agent’s identity context without executing anything.

Trust the actual error, not the agent’s summary. EACCES means a permission problem. EROFS means a read-only mount. They require different fixes.

Failure recovery

SymptomCauseFix
Gateway dies after SSH logoutThe user service has no lingerloginctl enable-linger "$(whoami)"
trusted_proxy_loopback_sourceLoopback proxy was not explicitly trustedAdd loopback to trustedProxies and enable allowLoopback
UI opens but Settings is missingIdentity arrived with no scope grantMatch the exact email in gateway.auth.identityScopes
Google returns a 403 for an unverified appAccount is absent from the Google test-user listAdd it under Google Auth Platform -> Audience
Local CLI says roles require verified identityCLI and Gateway do not share the fallback passwordLoad the same OPENCLAW_GATEWAY_PASSWORD into the service and shell
Existing user keeps broader permissionsDevice scope changes are not retroactiveRemove the device and have the user enroll again
User signs in but lands in the blocked admin agentThe explicit roster has no team system agentSet agents.defaults.systemAgent.agentId to the team agent and start a new session
Non-admin user can see mainTheir role allows every agentReplace agents: "*" with the allowed team agent IDs
sandbox list is emptySandboxes are created lazilyExecute a tool in a non-main session first
/workspace is not writabledocker.user and seeded ownership do not matchUnset agents.defaults.sandbox.docker.user, then recreate
Sandbox change has no effectExisting containers retain old configurationopenclaw sandbox recreate --all

If role configuration locks out the local CLI, file-backed configuration still works. Restore a password directly, restart, and then fix both sides of the environment setup:

openclaw config set gateway.auth.password '"<recovery-password>"'
openclaw gateway restart

Remove it from openclaw.json after the environment path is verified:

openclaw config unset gateway.auth.password
openclaw gateway restart
openclaw users list
openclaw security audit

What this does not provide

This is one trusted operator domain. Roles limit control-plane authority, session visibility, agent availability, and sandbox requirements. They do not turn one Gateway into secure infrastructure for mutually hostile users, customers, or organizations.

Run separate Gateways under separate operating-system identities or hosts when the people using them should not share a trust boundary.

References