Skip to content

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.

HTTPSHTTP, private IPHTTPS + Access loginoutbound tunnelWireGuard:3306

Shopper

Cloudflare edge (optional)
load balancer

nginx :80
storefront server

Admin, browser

Cloudflare Access

cloudflared

Admin, Tailscale app

tailscale

nginx :8081
private admin server

mariadb

Magento admin

RabbitMQ /rabbitmq/

OpenObserve /logs/

ServicePublic internetPrivate admin hostnameServer only
Storefront pages, /api/graphql, mediaYes, with rate limits and Turnstile
Magento adminNo: the admin path on the shop domain answers 403https://<private hostname>/
RabbitMQ managementNo/rabbitmq/
OpenObserve (observability profile)No/logs/127.0.0.1:5080, over an SSH tunnel
MariaDBNo:3306 with Tailscale only127.0.0.1:3306, over an SSH tunnel
OpenSearch, Valkey, OpenTelemetry CollectorNoNoDocker networks only
Stripe webhooksStripe’s published addresses only
AI MCP server and its OAuth endpointsAnthropic’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.

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 needsA browserThe Tailscale app on the computer
HostnameA 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 accessAn email list, an email domain or a login provider group in an Access policy, per path if neededThe user’s role on the Tailscale Users page
EncryptionTLS ends at CloudflareWireGuard end to end
MariaDB from a desktop clientSSH tunnel:3306 over the tailnet
Free plan50 users, request bodies up to 100 MB6 users, plus users shared from other tailnets
Configured inThe Zero Trust dashboard: one tunnel hostnametailscale/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.

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.

  1. 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.

  2. 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>/rabbitmq and <private hostname>/logs with their own policies. The more specific path wins.

  3. Networks > Tunnels > Create a tunnel > Cloudflared. Copy the token from the install command into .env.secrets:

    Terminal window
    TUNNEL_TOKEN="eyJ..."
  4. 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.

  5. Add cloudflare to COMPOSE_PROFILES in .env and start the container. With deputy, add cloudflare to stack.profiles instead (see Deployment). The tunnel shows Healthy in the dashboard and the container turns healthy.

  6. 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.
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 client

The 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.

  1. Create a tailnet at login.tailscale.com, signed in with the store owner’s Google, Microsoft or GitHub account.

  2. On the DNS page, enable MagicDNS and HTTPS certificates.

  3. In Access controls, replace the policy with tailscale/policy.hujson from magenxcommerce-docker. The default policy allows every device to reach every other device.

  4. In Settings > User management, turn on user approval and device approval.

  5. In Settings > OAuth clients, create a client with the scope Auth Keys (write) and the tag tag:magento. Put its secret in .env.secrets and keep the suffix:

    Terminal window
    TS_AUTHKEY="tskey-client-xxxx?ephemeral=false&preauthorized=true"
  6. Add tailscale to COMPOSE_PROFILES in .env (or to deputy’s stack.profiles) and start the container. The node appears as TS_HOSTNAME with the tag tag:magento. Check it on the server:

    Terminal window
    doco exec tailscale tailscale --socket=/tmp/tailscaled.sock status
  7. Point the Magento admin to https://<TS_HOSTNAME>.<tailnet>.ts.net/, see Magento admin URL.

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:

WhoCan 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.

  • 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.

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.

Point the Magento admin to the private hostname. The trailing slash is required. After this, the admin answers there only:

Terminal window
doco run --rm magento config:set admin/url/use_custom 1
doco 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_url and web/secure/base_media_url empty 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.conf empty, so the admin path on the shop domain answers 403 to everyone.
  • The admin path ADMIN_PATH stays random (generated into .env.secrets), so https://<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.

ToolHow to reach itLogin
RabbitMQ managementhttps://<private hostname>/rabbitmq/The RabbitMQ user from .env.secrets
OpenObservehttps://<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
MariaDBTailscale: <TS_HOSTNAME>.<tailnet>.ts.net:3306. Cloudflare: ssh -L 3306:127.0.0.1:3306 user@server, then 127.0.0.1:3306A MariaDB user; prefer a read-only one for reporting
Magento CLI, Composer, n98-magerun2SSH to the server, then doco run --rm magento … (see Deployment)Server SSH key
  • RabbitMQ and OpenObserve serve themselves under /rabbitmq and /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.

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.

FileWhat it controls
allow.confAddresses allowed to the admin path on the shop domain. Empty by default: the admin there answers 403.
deny.confAddresses and ranges that get a 403 on every request.
stripe_webhook.confStripe’s webhook addresses, the only ones allowed to /stripe/webhooks. Keep it in step with Stripe’s list.
claude.confAddresses 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/graphql 10 requests/s (burst 20) plus a concurrency limit, downloads 30 per minute, and other Magento paths 1 request/s (media, static files and /graphql excepted). 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 from X-Forwarded-For, from trusted ranges only (see Overview).
  • Blocked paths: dotfiles (.git, .env, .htaccess), scripts, logs, SQL dumps and archives, composer.json and auth.json, PHP files under media and static, 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.
  • Exactly one of cloudflare or tailscale in COMPOSE_PROFILES (or in deputy’s stack.profiles), and the container is healthy.
  • 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_TOKEN or TS_AUTHKEY lives only in .env.secrets, which is backed up off the server and never committed.
  • stripe_webhook.conf and claude.conf are current; allow.conf is empty.