Security and admin access
The storefront is public. The Magento admin, RabbitMQ management, OpenObserve and the database are not: they sit on a separate, admin-only nginx server that is never published on the host, and admins reach it through one of two private access containers, Cloudflare Tunnel or Tailscale. Who gets in is decided by an identity login (Cloudflare Access or the tailnet), before any request reaches the server, and not by IP allowlists. The container hardening underneath (hardened images, read-only filesystems, no capabilities, signed images) is in Docker stack.
What is reachable from where
Section titled “What is reachable from where”| Service | Public internet | Private admin hostname | Server only |
|---|---|---|---|
Storefront pages, /api/graphql, media | Yes, with rate limits and Turnstile | ||
| Magento admin | No: the admin path on the shop domain answers 403 | https://<private hostname>/ | |
| RabbitMQ management | No | /rabbitmq/ | |
OpenObserve (observability profile) | No | /logs/ | 127.0.0.1:5080, over an SSH tunnel |
| MariaDB | No | :3306 with Tailscale only | 127.0.0.1:3306, over an SSH tunnel |
| OpenSearch, Valkey, OpenTelemetry Collector | No | No | Docker networks only |
| Stripe webhooks | Stripe’s published addresses only | ||
| AI MCP server and its OAuth endpoints | Anthropic’s addresses and the admins’ addresses only |
The private admin server (nginx:8081) answers only for the admin path, the static files and media the admin pages load, /rabbitmq/ and /logs/. Every other path is a 404, so the storefront is never served there, and the admin is never served on the shop domain.
Choose Cloudflare or Tailscale
Section titled “Choose Cloudflare or Tailscale”Both are compose profiles in magenxcommerce-docker. Start one of them with COMPOSE_PROFILES in .env (comma separated, next to observability). cloudflare is the default.
cloudflare (default) | tailscale | |
|---|---|---|
| The admin needs | A browser | The Tailscale app on the computer |
| Hostname | A hostname on the shop’s domain, in public DNS, behind a Cloudflare Access login | <TS_HOSTNAME>.<tailnet>.ts.net, resolves inside the tailnet only |
| Who gets access | An email list, an email domain or a login provider group in an Access policy, per path if needed | The user’s role on the Tailscale Users page |
| Encryption | TLS ends at Cloudflare | WireGuard end to end |
| MariaDB from a desktop client | SSH tunnel | :3306 over the tailnet |
| Free plan | 50 users, request bodies up to 100 MB | 6 users, plus users shared from other tailnets |
| Configured in | The Zero Trust dashboard: one tunnel hostname | tailscale/serve.json, built into the image |
Pick Cloudflare when the shop’s DNS is already on Cloudflare and admins should need nothing but a browser. Pick Tailscale for end-to-end encryption, a hostname that isn’t in public DNS or certificate logs, and direct database access for developers.
Neither container publishes a port on the host. Both run as non-root with a read-only root filesystem and all capabilities dropped, like the rest of the stack, and both images are built on Docker Hardened Images, scanned, signed and pinned by digest in each release.
Set up Cloudflare Tunnel
Section titled “Set up Cloudflare Tunnel”admin browser --HTTPS--> Cloudflare edge (Access login) --tunnel--> cloudflared (outbound only) https://<private hostname> -> http://nginx:8081 Magento admin, /rabbitmq/, /logs/The cloudflared container joins the frontend network only and opens an outbound connection to Cloudflare. The tunnel is managed in the dashboard. Its settings are the TUNNEL_* variables in .env, and the tunnel token is TUNNEL_TOKEN in .env.secrets.
-
In Cloudflare Zero Trust, create the organization (team name) on the free plan. One-time PIN by email is on by default. Add Google, Microsoft or GitHub under Settings > Authentication if you want admins to sign in with those.
-
Access > Applications > Add an application > Self-hosted: an application for the private hostname, with a policy whose action is Allow and that names the admins’ emails, an email domain or a login provider group. Keep the session duration to a working day or less.
To give fewer people RabbitMQ or OpenObserve, add applications for
<private hostname>/rabbitmqand<private hostname>/logswith their own policies. The more specific path wins. -
Networks > Tunnels > Create a tunnel > Cloudflared. Copy the token from the install command into
.env.secrets:Terminal window TUNNEL_TOKEN="eyJ..." -
On the tunnel, under Public hostnames, add the private hostname with service type HTTP and URL
nginx:8081. Add it only after the Access application from step 2 exists, so the hostname is never open without a login. -
Add
cloudflaretoCOMPOSE_PROFILESin.envand start the container. With deputy, addcloudflaretostack.profilesinstead (see Deployment). The tunnel shows Healthy in the dashboard and the container turnshealthy. -
Point the Magento admin to the private hostname, see Magento admin URL.
- The hostname is in public DNS and in certificate transparency logs. Requests without an accepted Access login stop at Cloudflare and never reach the server. Pick a neutral name, not
admin.. - If admin pages fail on blocked XHR requests, check Security > Events for challenges on the private hostname and add a WAF skip rule for it.
- MariaDB has no browser path here. Use an SSH tunnel, see Operator tools.
Set up Tailscale
Section titled “Set up Tailscale”admin computer (Tailscale app) --WireGuard--> tailscale container, tag:magento (Tailscale Serve, *.ts.net certificate) https://<TS_HOSTNAME>.<tailnet>.ts.net :443 -> nginx:8081 Magento admin, /rabbitmq/, /logs/ :3306 -> mariadb:3306 MariaDB, for a desktop database clientThe tailscale container uses userspace networking: no NET_ADMIN, no /dev/net/tun, no host port. It joins frontend (for nginx) and backend (for MariaDB) and forwards only the ports listed in tailscale/serve.json. It doesn’t route between the networks. serve.json is built into the image, so a port change ships with a release. Its settings are the TS_* variables in .env, and the auth key is TS_AUTHKEY in .env.secrets.
-
Create a tailnet at login.tailscale.com, signed in with the store owner’s Google, Microsoft or GitHub account.
-
On the DNS page, enable MagicDNS and HTTPS certificates.
-
In Access controls, replace the policy with
tailscale/policy.hujsonfrom magenxcommerce-docker. The default policy allows every device to reach every other device. -
In Settings > User management, turn on user approval and device approval.
-
In Settings > OAuth clients, create a client with the scope Auth Keys (write) and the tag
tag:magento. Put its secret in.env.secretsand keep the suffix:Terminal window TS_AUTHKEY="tskey-client-xxxx?ephemeral=false&preauthorized=true" -
Add
tailscaletoCOMPOSE_PROFILESin.env(or to deputy’sstack.profiles) and start the container. The node appears asTS_HOSTNAMEwith the tagtag:magento. Check it on the server:Terminal window doco exec tailscale tailscale --socket=/tmp/tailscaled.sock status -
Point the Magento admin to
https://<TS_HOSTNAME>.<tailnet>.ts.net/, see Magento admin URL.
Tailnet access controls
Section titled “Tailnet access controls”The policy in tailscale/policy.hujson gives access by the user’s role on the Users page, so adding or removing an admin never needs a policy edit:
| Who | Can reach |
|---|---|
| Member | :443: the Magento admin, /rabbitmq/ and /logs/, each with its own login |
| Owner, Admin, IT admin | :443 and MariaDB on :3306 |
| Users of another tailnet the node is shared with | :443 |
Only admins of the tailnet may apply tag:magento to a device, and the policy uses no groups, so it fits the free plan.
Manage admins
Section titled “Manage admins”- Add: add the email (or group) to the Access policy. The admin opens the private hostname, signs in with a one-time PIN or the login provider, then with their Magento account.
- Remove: remove them from the policy, then revoke their active sessions on their user page in Zero Trust. Remove or disable their Magento admin user too.
- Agency or contractor: add their email domain or their login provider group, ideally to a separate policy you can remove in one step.
- Add: Users > Invite users. The admin installs the Tailscale app (Windows, macOS, Linux), signs in with the invited account and opens
https://<TS_HOSTNAME>.<tailnet>.ts.net/. The Magento admin login is still required. - Remove: Users > Remove or Suspend. Access ends at once, on every device of that user. Remove or disable their Magento admin user too.
- Agency or contractor with their own tailnet: Machines >
TS_HOSTNAME> Share. Revoke the share to end access.
The private access layer only decides who reaches the login page. Each admin still needs their own Magento admin user, and Admin Activity records what they do there.
Magento admin URL
Section titled “Magento admin URL”Point the Magento admin to the private hostname. The trailing slash is required. After this, the admin answers there only:
doco run --rm magento config:set admin/url/use_custom 1doco run --rm magento config:set admin/url/custom https://<private hostname>/doco run --rm magento cache:flush- Magento also stores the custom URL as the base URL of the admin store, so admin static files and media load from the private hostname too, with no CORS. Keep
web/secure/base_static_urlandweb/secure/base_media_urlempty or on{{secure_base_url}}: an absolute URL to the shop domain or a CDN breaks the admin, because its templates and fonts would need CORS. - Leave
nginx/templates/ipset/allow.confempty, so the admin path on the shop domain answers 403 to everyone. - The admin path
ADMIN_PATHstays random (generated into.env.secrets), sohttps://<private hostname>/redirects to/<ADMIN_PATH>/.
To move the admin back to the shop domain, set admin/url/use_custom to 0, delete the admin store’s web/secure/base_url and web/unsecure/base_url rows if they still hold the private hostname, flush the cache, and add the admins’ addresses to ipset/allow.conf again.
Operator tools
Section titled “Operator tools”| Tool | How to reach it | Login |
|---|---|---|
| RabbitMQ management | https://<private hostname>/rabbitmq/ | The RabbitMQ user from .env.secrets |
| OpenObserve | https://<private hostname>/logs/, or ssh -L 5080:127.0.0.1:5080 user@server and http://localhost:5080/logs/ | ZO_ROOT_USER_EMAIL and ZO_ROOT_USER_PASSWORD from .env.secrets |
| MariaDB | Tailscale: <TS_HOSTNAME>.<tailnet>.ts.net:3306. Cloudflare: ssh -L 3306:127.0.0.1:3306 user@server, then 127.0.0.1:3306 | A MariaDB user; prefer a read-only one for reporting |
| Magento CLI, Composer, n98-magerun2 | SSH to the server, then doco run --rm magento … (see Deployment) | Server SSH key |
- RabbitMQ and OpenObserve serve themselves under
/rabbitmqand/logs, so nginx passes requests through unchanged. Both keep their own login behind the private access layer. - No database web UI ships with the stack. nginx blocks the usual phpMyAdmin, Adminer and similar paths, and Magento’s admin backup page, on every server.
- With Cloudflare, use Access applications per path to give RabbitMQ and OpenObserve to fewer people than the admin.
nginx access controls
Section titled “nginx access controls”The public storefront server applies these on top of the private admin access. Each list is a file under nginx/templates/ipset/ in the customer’s stack repository, so a change ships with a release.
| File | What it controls |
|---|---|
allow.conf | Addresses allowed to the admin path on the shop domain. Empty by default: the admin there answers 403. |
deny.conf | Addresses and ranges that get a 403 on every request. |
stripe_webhook.conf | Stripe’s webhook addresses, the only ones allowed to /stripe/webhooks. Keep it in step with Stripe’s list. |
claude.conf | Addresses allowed to the AI MCP server and its OAuth endpoints: Anthropic’s range plus the admins’ own addresses, because the OAuth authorize step runs in the admin’s browser. |
Other protections on the public server:
- Rate limits per client IP: storefront pages 10 requests/s (burst 50),
/api/graphql10 requests/s (burst 20) plus a concurrency limit, downloads 30 per minute, and other Magento paths 1 request/s (media, static files and/graphqlexcepted). Over the limit, nginx answers 429. The admin,/rabbitmq/and/logs/are exempt, because their pages fire many requests at once and they are already behind a login. The client IP comes fromX-Forwarded-For, from trusted ranges only (see Overview). - Blocked paths: dotfiles (
.git,.env,.htaccess), scripts, logs, SQL dumps and archives,composer.jsonandauth.json, PHP files undermediaandstatic, and the usual database tool and installer paths. - Bot user agents get a 403, and the storefront’s abuse-prone forms need a Cloudflare Turnstile token, checked by the GraphQL proxy.
Checklist
Section titled “Checklist”- Exactly one of
cloudflareortailscaleinCOMPOSE_PROFILES(or in deputy’sstack.profiles), and the container ishealthy. - The Magento admin URL points to the private hostname, and the admin path on the shop domain answers 403.
- Cloudflare: an Access application exists for the hostname before the tunnel publishes it; session duration a working day or less; few people with Zero Trust dashboard roles.
- Tailscale: the default policy is replaced with
tailscale/policy.hujson; user and device approval are on. - Every admin has their own Magento admin user; leavers are removed from Access or the tailnet and from Magento.
TUNNEL_TOKENorTS_AUTHKEYlives only in.env.secrets, which is backed up off the server and never committed.stripe_webhook.confandclaude.confare current;allow.confis empty.