Skip to content

Overview

A deployment has four parts: a load balancer that terminates TLS, an nginx router, the Next.js storefront, and Magento as a GraphQL-only backend on a private network. Browsers only ever reach the load balancer (or a CDN in front of it); nginx and everything behind it have no public address.

HTTPSHTTPSHTTP, private IPserver-side queries/api/graphql (allowlisted)PURGE on data change/api/revalidate

Browser

Cloudflare (optional)
DNS proxy · WAF
Turnstile · access rules

Load balancer
TLS certificate · health checks

nginx
HTTP :80 · routing
micro-cache

Next.js
pages · /api/graphql proxy

Magento GraphQL
FrankenPHP worker
PHP-FPM fallback

MariaDB · Redis
OpenSearch · RabbitMQ

Private network: MagentoPrivate network: storefrontPublic edge

The nginx config in magenxcommerce-docker has no TLS settings. It listens on plain HTTP and expects a load balancer in front of it to own the certificate and the public address.

  • Load balancer. For example a Hetzner Cloud Load Balancer: it holds the TLS certificate, redirects HTTP to HTTPS, health-checks the server and forwards to nginx on the server’s private IP. The server itself needs no public ports, which hides it from direct scans and attacks.
  • Cloudflare (optional). With the DNS record proxied, Cloudflare answers for the domain, so the load balancer’s address is hidden too. It adds its own TLS, WAF and firewall rules, bot and DDoS protection, caching of static assets, and Cloudflare Access (SSO) in front of the private admin hostname, which the stack serves through Cloudflare Tunnel instead of the public domain (see Security and admin access). The storefront already uses Cloudflare Turnstile for abuse-prone forms.
  • Certificates with Cloudflare. Set SSL/TLS mode to Full (strict), and give the load balancer a certificate Cloudflare trusts, such as a Cloudflare Origin CA certificate uploaded to it. Then allow only Cloudflare’s IP ranges to reach the load balancer, so it can’t be used to bypass Cloudflare.
  • Client IP. Behind a load balancer, nginx sees the balancer’s private address as the peer. The balancer and Cloudflare add the visitor’s address to X-Forwarded-For, and nginx restores it from there (nginx/templates/http.d/real_ip.conf.template, which trusts private ranges and Cloudflare’s ranges). Keep that list current when Cloudflare publishes new ranges.
  • Pages (/en/...): the load balancer forwards them to nginx, which passes them to Next.js. Guest HTML can be micro-cached at nginx; signed-in customers always bypass it.
  • Browser GraphQL: the browser posts to /api/graphql on the storefront, never to Magento. The proxy only forwards operations the storefront itself defines. See GraphQL proxy.
  • Server-side GraphQL: server components query Magento over the private network.
  • Magento’s own /graphql returns 404 on the public host. Magento is reachable only from inside the private network.
  • Payment webhooks: Stripe (/stripe/webhooks) and Mollie (/mollie/checkout/webhook) call Magento through the load balancer and nginx, so any WAF or firewall rule in front must let them through. See Payments.
  • Cache refresh: when data changes, Magento sends its standard cache PURGE. nginx turns it into a call to /api/revalidate, which refreshes the affected pages. See Caching.

The customer’s Magento token is kept in an httpOnly cookie (magenx_ct), so page scripts can’t read it. nginx adds it to GraphQL requests as a Bearer header. The same cookie makes nginx skip the guest HTML cache.

RouteRendering
Home and CMS pagesPre-rendered, refreshed on demand
Category and search pagesIncremental: cached, refreshed when Magento data changes
Product pagesPre-rendered and refreshed on price or stock change
Cart, checkout, accountRendered in the browser, never cached
Payment return pages (/order/stripe-return, /order/mollie-return, /order/paypal-return)Rendered in the browser; confirm the payment with Magento

Magento data fetched with "use cache" and rendered page shells are kept by the storefront process. With more than one storefront instance, set SF_CACHE_NEXT=1 and REDIS_URL (or NEXT_CACHE_REDIS_URL): both then live in Valkey under sf:v1:, with one tag state, so a purge from Magento reaches every instance and a new instance starts warm. Page shells are keyed by build id, so a deploy never serves a shell from the previous build. If Valkey stops answering, each instance falls back to its own memory for 30 seconds at a time.

FolderWhat it is
packages/engine@magenxcommerce/engine: Apollo client, GraphQL documents and types, cart and wishlist state, agentic-commerce handlers. No styling.
apps/themeThe reference shop: Next.js pages, components and magenx.config.ts.
magento/schemasCopies of the companion modules’ GraphQL schemas, used to test the storefront’s queries.
docs/This documentation.

The Docker stack (nginx, Magento, MariaDB, Valkey, OpenSearch, RabbitMQ, the storefront container and the observability profile) lives in magenxcommerce-docker. See Docker stack for what runs on the server and Deployment for how it gets there. The companion modules live in their own repositories and are installed into Magento with Composer. See Companion modules.