Strapi with Traefik in Docker

Traefik can route public traffic to a Strapi container and request certificates from labels alone, but Strapi must also trust the forwarded headers and know its public URL. This page covers both sides and the checks that confirm them.

On this page

Strapi with Traefik in Docker: how routing and certificates fit together

Traefik can route traffic to a Strapi container on port 1337 and request certificates through Docker labels, but Strapi also needs its public URL and proxy trust set correctly, or it will generate links, cookies and redirects that point at the wrong origin. Traefik handles the edge and Strapi handles its own identity on that edge. A team running Strapi in Docker on a host it controls, with HTTPS on a real domain, should plan both halves together rather than treating the reverse proxy as finished once the certificate is issued.

In Traefik, entry points listen on ports such as 80 and 443, routers match incoming hostnames and paths, services point at the container's internal port, and the TLS settings decide how certificates are obtained and renewed. Labels on the Strapi container declare these pieces, so the router, service and certificate resolver live beside the application they serve. Inside Strapi, the server URL, the trust of forwarded headers and the admin URL decide what the application believes its public address is. Those values sit in the project configuration and must agree with the hostname Traefik serves.

Teams usually pick Traefik over a hand-written Nginx or Caddy file when their containers already change often and they want routing to follow container lifecycle through the Docker provider. A hand-written file is easier to audit line by line, so teams with a strict change process may prefer it. Before use, check the exact label names, certificate resolver options and Strapi config keys against the current Traefik and Strapi documentation, since both projects change between releases.

Traefik choices for a Strapi container and when each fits

This table compares the main Traefik decisions for putting a Strapi container on port 1337 behind HTTPS. Read each row for what the choice changes on the Strapi side, such as server.url, forwarded headers and admin panel placement, and the environment where it fits best.

DecisionWhat it changes for StrapiWhen it fits
Label-based Docker providerRoutes are declared as labels on the Strapi container, so the route moves with the container and is reviewed alongside the Compose fileSingle host Compose deployments where one team owns both the Strapi service and its routing
File providerRoutes and TLS options live in a separate dynamic config file, so Strapi's container labels stay free of routing detailsTeams that manage routing centrally or need one reviewed file for several services on the same proxy
HTTP-01 challengeTraefik answers a challenge on port 80 for each hostname, so the API hostname must resolve publicly and port 80 must reach TraefikA single public hostname such as an API subdomain with inbound ports 80 and 443 open
DNS-01 challengeTraefik proves control of the domain by writing a DNS record through a provider API, so no inbound port 80 is needed for issuanceWildcard certificates, or hosts with no public inbound port where DNS is managed by a supported provider
TLS terminated at TraefikTraefik handles HTTPS and forwards plain HTTP to Strapi, so Strapi must trust forwarded proto and host headers and server.url must match the public URLThe common case: one public TLS edge in front of the Strapi container
TLS passed throughTraefik forwards encrypted traffic without decrypting it, so Strapi itself must serve TLS and manage the certificateRare for Strapi; fits only when policy requires end-to-end encryption to the container
API on a subdomainStrapi runs at the root of its own hostname, so cookies, CORS origins and the admin URL are simpler to reason aboutSeparate API and admin hostnames, or when the front end is on another domain
API on a path prefixStrapi sits under a prefix, so Strapi's path settings, asset URLs and admin build paths must match the prefix exactlySingle hostname setups where a subdomain is not available; test admin asset paths carefully
Traefik dashboard exposedThe dashboard shows routers and services, so it should sit behind authentication or on a private addressRarely on a public port; use it on an internal network or disable it in production

How a browser request reaches Strapi through Traefik

The request starts in the browser and enters Traefik on ports 80 and 443, where TLS terminates and the router rule matches the host. Traefik forwards the request into the Docker network to the Strapi container on port 1337, adding forwarded headers that Strapi must trust through its proxy settings. Strapi then reads or writes the database and, where uploads are configured, the upload provider. The separate certificate branch shows Traefik requesting certificates from the certificate authority over ACME, so check that the public hostname resolves to the server before the first request.

Request path from browser to Strapi, with the certificate branch and trust boundary.

Setting up Traefik labels for the Strapi container

This sequence puts a Strapi container behind Traefik on a shared Docker network, routes a public hostname to port 1337, and issues a TLS certificate for that hostname. Each step ends with a check so the reader knows the route works before moving on.

  1. Create a shared Docker network for Traefik and Strapi

    The platform engineer creates a user-defined Docker bridge network, for example with docker network create proxy, and attaches both the Traefik container and the Strapi container to it. Traefik can only reach containers it shares a network with, so the Strapi database and other internal services should stay on a separate internal network that Traefik does not join. Confirm the step is done by running docker network inspect proxy and seeing both containers listed under Containers.

  2. Start Traefik with the Docker provider and entry points

    The engineer runs Traefik with the Docker provider enabled, so it reads labels from containers, and defines a web entry point on port 80 and a websecure entry point on port 443. Traefik needs read access to the Docker socket, which is a sensitive permission, so the team should decide whether to use a socket proxy and confirm the provider settings against the Traefik version in use. Confirm the step by opening the Traefik dashboard or API and checking that the entry points are listed and no routers exist yet.

  3. Enable Traefik for the Strapi service with labels

    In the Compose file or run command for the Strapi service, the engineer adds the label traefik.enable=true so Traefik includes the container in routing. The Strapi service should not publish port 1337 to the host, because Traefik reaches it over the shared network. Confirm the step by running docker compose config to check that the labels are rendered on the Strapi service and that no host port mapping exists for 1337.

  4. Define the router rule on the public hostname

    The engineer adds a router label such as traefik.http.routers.strapi.rule=Host("cms.example.com"), using the hostname the organization has chosen, and sets the entry point to websecure. The hostname must resolve to the Traefik host in DNS before certificates can be issued. Confirm the step by checking the Traefik dashboard or API for a router named strapi with the expected rule, which shows the rule is parsed even before TLS is attached.

  5. Point the router at Strapi port 1337

    The engineer sets traefik.http.services.strapi.loadbalancer.server.port=1337 so Traefik sends traffic to the port Strapi listens on inside the container. If the team runs several Strapi containers later, the same service can balance across them, but the shared state rules in the Strapi deployment guidance still apply. Confirm the step by checking that the strapi service in the Traefik dashboard shows a healthy backend address on port 1337 for the container.

  6. Configure the certificate resolver and storage file

    The engineer defines a certificate resolver in the static Traefik configuration, choosing the ACME challenge the environment can satisfy, such as HTTP-01 on port 80 or DNS-01 through a DNS provider, and sets a storage file, for example acme.json, that Traefik uses to keep issued certificates. The file must have restrictive permissions, typically 600, or Traefik will refuse to use it. Confirm the resolver settings against the Traefik documentation for the installed version, then check that Traefik starts without errors about the resolver or storage file.

  7. Attach TLS and the resolver to the router

    The engineer adds traefik.http.routers.strapi.tls=true and traefik.http.routers.strapi.tls.certresolver set to the resolver name, so the router requests a certificate for the hostname. After the change, Traefik should be recreated or reloaded with the new labels. Confirm the step by checking Traefik logs for a successful certificate issuance for the hostname, then confirming in the dashboard or with a TLS inspection tool that the certificate matches the hostname.

  8. Confirm the Strapi admin login page loads through the route

    From a machine outside the Docker host, the engineer requests ` and expects the Strapi admin login page. If the page loads but assets or redirects point to an internal address, the proxy settings in the Strapi configuration, including the public server URL and forwarded header trust, need correction before go-live. Confirm the step by seeing the login page render over valid HTTPS with no mixed-content or redirect errors in the browser console.

Which Strapi settings must match the Traefik edge

Strapi builds absolute links, admin redirects and OAuth or SSO callbacks from its own idea of where it is served. The public URL of the API, set through the url key in config/server.js or the URL environment variable (confirm the exact key for your installed version), must match the address Traefik exposes to browsers, including the https scheme and the real hostname. If Strapi believes it is served on inside the Docker network, it will generate links and redirects that browsers refuse to follow from an HTTPS page, and callback URLs will not match what the identity provider has registered. Treat this value as part of the deployment contract: the Traefik router Host()` rule, the Strapi URL and the identity provider redirect list should all be written from the same hostname.

Traefik terminates TLS and forwards plain HTTP to the container on port 1337, so Strapi needs to trust the forwarded headers Traefik adds, principally X-Forwarded-Proto and X-Forwarded-Host. The proxy trust setting in config/server.js (its key name and default should be checked against the configuration reference for your Strapi version) tells Strapi to accept those headers from the proxy. When it is off, Strapi sees every request as plain HTTP and can issue redirects to http URLs, which produces redirect loops behind a TLS edge. When the scheme or host it sees differs from what the browser uses, the symptoms are mixed-content errors on the admin panel and session cookies that are set with the wrong secure flag or domain, so the admin login appears to succeed and then never persists. Trust should be limited to the proxy network, not opened to all clients. Confirm the trusted proxy setting and the cookie options for your version before you test login.

Where the admin panel is served from the same host as the API, the admin URL and the server URL must agree, because the admin single-page application builds its API calls from them. Confirm the admin path and the admin URL keys in the configuration reference for your installed version, then check the result in a browser with the developer tools open, looking for requests to an internal hostname, http resources on an HTTPS page, or a login that loops back to the sign-in screen. Hosting the admin panel on a separate hostname changes these rules and is covered on its own page. Before go-live, record the final public URL, the trusted proxy setting and the admin URL in your deployment documentation, and repeat the login and redirect checks after each Traefik label or Strapi version change.

Security settings to review at the Traefik edge

Traefik sits in front of Strapi and decides what the internet can reach, which certificates exist and where they live, and which client-supplied headers Strapi believes. Each card below names one setting to verify before go-live and the operator decision it drives.

Traefik dashboard and API exposure

The Traefik dashboard and API expose routers, services and configuration, and they are easy to publish by accident when the api.dashboard setting is enabled on a public entrypoint. Confirm the dashboard is either disabled or bound to an internal entrypoint with its own authentication, and that no router sends the dashboard path to the public web entrypoint. Decide who may change routing before a label change reaches production.

ACME storage file permissions

Traefik stores issued certificates and private keys in the ACME JSON file named by the certificatesResolvers storage option, usually acme.json. Anyone who can read that file can copy the private keys, so it must be readable only by the Traefik process and its operators. Mount it from a protected host path, set the file mode to owner-only, and keep it out of the Git repository and image layers.

Strapi port 1337 publication

Strapi listens on port 1337 inside its container. If the Compose file publishes that port with a ports mapping, clients can bypass Traefik, TLS and any routing rules by reaching the host directly. Keep the Strapi service on the internal Docker network only, let Traefik reach it by container name, and publish nothing except the Traefik entrypoints. Confirm this with a direct request to the host address on port 1337 from outside the network.

Trusted forwarded headers

Strapi builds absolute URLs and decides whether a request is secure from forwarded headers. Set server.proxy and its trusted proxy settings so that only the Traefik address is trusted, and let Traefik overwrite X-Forwarded-Proto and X-Forwarded-For rather than pass client values through. Without this, a client can send a forged protocol header and affect cookie flags, redirects and generated links. Test by sending a spoofed header directly and checking the response.

Upload size limits at two layers

A large request can be stopped by Traefik, by Strapi, or by both, and the two limits must agree. Traefik enforces body size through a buffering middleware, while Strapi enforces its own upload limit in the body parser and upload provider settings. Set the Traefik limit slightly above the Strapi limit so Strapi returns the application error, and confirm the chosen value matches what editors expect for media.

Access logs without sensitive query strings

Traefik access logs record the request path and query string by default, and Strapi endpoints can carry tokens, email addresses or filter values in the query. Decide which fields the access log keeps, drop or redact query parameters where they can hold secrets, and set a retention period that your privacy and security policy allows. Confirm the log destination and who can read it before enabling access logs in production.

How the Traefik setup changes by deployment shape

On a single virtual machine running one Strapi container, Traefik is the only public entry point and talks to Strapi over the Docker network on port 1337. The labels define one router, one service and one certificate resolver, and the trusted proxy scope is narrow: Strapi only needs to trust the Traefik container. Health checks can be simple, and local uploads and in-process sessions are acceptable because only one instance writes to them.

  • Labels: Set the router rule for your hostname, point the service port at 1337, and attach the certificate resolver to the router.
  • Trusted proxies: Limit trust to the Docker network address of the Traefik container, not to the whole internal range.
  • Health checks: Use the Strapi health endpoint for container checks, and confirm Traefik only routes to the container once it reports healthy.
  • Certificates: Traefik stores issued certificates in its ACME file, so back up that file and keep it on a persistent volume.
  • Shared state: Local uploads on the VM volume are acceptable for one instance, but they must be included in backups.

Confirm the proxy settings and the server URL against the Traefik version you run, and test a restart to check that certificates and uploads persist.

Questions teams ask before setting up Strapi behind Traefik

How much effort does a single-host Traefik setup take compared with tuning Strapi's URL and proxy settings?

On one host, the Traefik part is usually the smaller share of the work. Adding labels to a compose file, defining an entrypoint for HTTPS and a certificate resolver is a bounded task for someone comfortable with Docker. The larger effort is the Strapi side: setting the public URL, trusting forwarded headers, and checking that the admin panel, cookies and API responses all report the correct scheme and host. Cost follows the number of hostnames, whether the admin panel sits on a separate domain, and how many environments need the same pattern. Ask any partner to separate the Traefik configuration from the Strapi configuration in its quote, so you can see where the effort sits.

What does the team need to provide before the Traefik work starts?

The work needs a few concrete inputs from your side:

  • A DNS record that points the public hostname at the Docker host.
  • Port 80 reachable from the internet for the HTTP challenge, or DNS API access if you use a DNS challenge instead.
  • Someone who can read Docker logs and Traefik's dashboard or access log output during testing.
  • Access to the compose file, environment variables and the secret store where the Strapi keys live.

If your network blocks port 80 or your DNS provider is not supported by the certificate resolver you want, confirm that before scheduling the build.

Can our own team set this up alone, and where does it usually stall?

A capable Docker team can usually get Traefik issuing a certificate and routing traffic to Strapi on port 1337. Progress tends to stall in three places. Certificate challenges fail when DNS has not propagated or port 80 is blocked. Redirect loops appear when Traefik terminates TLS and Strapi also forces HTTPS without knowing the original scheme. Mixed content shows up when the admin panel or media URLs are generated with http, even though the browser reached the site over https. Each of these is diagnosable from logs, but they are easy to misread if the team has not seen them before. Decide before you start who owns the first troubleshooting pass.

How do Traefik or Strapi version changes affect the labels and settings?

Traefik label syntax and the way certificate resolvers are declared have changed between major releases, so a Traefik upgrade can break routing that worked before. Strapi changes matter too. Strapi 5 runs only on supported Node.js versions and has its own proxy and URL behavior, so a Strapi upgrade may require checking the server settings again. Pin both image versions in your compose file, read the release notes before each upgrade, and retest hostnames, HTTPS redirects and the admin login after every change. Confirm the current Strapi release and supported Node.js versions in the Strapi installation documentation before you pin anything.

Does the Traefik setup change how Strapi handles admin sign-in and cookies?

It can. Strapi's admin panel sets cookies and builds redirects based on its configured URL, so a mismatch between the public hostname and the URL Strapi believes it serves can break login or session handling. If you later add single sign-on for administrators, the redirect URIs in your identity provider must match the public hostname exactly. If the admin panel runs on a different domain from the API, cookie and CORS settings need a separate review. Document the hostnames before you configure the identity provider, not after.

What should we send a partner so they can scope a Traefik and Strapi engagement?

A partner needs enough detail to size the work accurately. Send the public hostnames for the API and the admin panel, the target environment (a single VM, a Docker host in your data center, or a cloud account), and the Strapi version and database you run. Include the Node.js version, whether you use a separate database container, and where uploads are stored. Also share your current certificate approach, your DNS provider, and whether port 80 is open. Those details determine the scope, and a written scope is what makes the quote comparable across vendors.

Does Strapi's license or edition affect a Traefik-based deployment?

The reverse proxy choice does not change Strapi's licensing, but the edition you run does matter for features. The Community Edition is under the MIT Expat license, while code under ee directories is the Enterprise Edition under a separate Strapi license. Proxy and TLS configuration is the same for both editions, but features such as SSO for administrators depend on your plan. Check the plan terms on Strapi's self-hosted pricing page before you design the admin login path.

Limits to confirm in your environment before you rely on this setup

The Traefik and Strapi settings in this setup depend on versions, network position and organizational policy that change over time and differ between hosts. Treat each item below as a check to complete against current vendor documentation and your own environment, not as a fact to assume.

Traefik version and label syntax

Confirm that the Traefik version you run uses the label names, entrypoint names and certificate resolver options shown in the documentation for that exact release. Label keys and resolver settings have changed across major versions, and a mismatch often fails silently, leaving the router unmatched or the certificate never requested. Check the version tag in your compose file against the release notes before copying any label block.

Strapi version, Node.js and database support

Confirm which Strapi release you deploy and the Node.js and database versions it supports. Strapi 5 runs only on Active or Maintenance LTS Node.js versions and does not support MongoDB or other NoSQL databases. Your base image, the server.url value and the database container must all fall inside those supported ranges at the same time.

Strapi install requirements

Certificate challenge reachability

Confirm that the ACME challenge you choose can complete from the network this host sits in. An HTTP challenge needs the public internet to reach the host on port 80, while a DNS challenge needs API access from Traefik to your DNS provider. Hosts behind a corporate firewall, a private network or a NAT gateway may fail one challenge type but not the other, so test issuance in a staging environment before you rely on it.

Inbound ports 80 and 443

Confirm that the hosting environment, including any cloud security group, firewall or upstream load balancer, allows inbound traffic on ports 80 and 443 to the Traefik host. Port 80 is often required for HTTP to HTTPS redirects and some challenge types, and blocking it can break certificate renewal months after launch. Ask the network team to confirm rules in writing, because a rule that works today can be removed in a later change.

WebSocket and long upload behavior

Confirm how WebSocket connections and long-running upload requests behave through Traefik in your setup. Strapi's admin panel and some plugins use persistent connections, and large media uploads can hit timeouts or body size limits set at the proxy or the application. Run a test upload of a realistic file size and a session that stays open for several minutes, and check that the request completes without truncation.

Dashboard and Docker socket policy

Confirm that your organization's security policy allows the Traefik dashboard and a mount of the Docker socket into the Traefik container. Mounting the socket gives the proxy read access to container metadata and, in many setups, effective control of the host's container runtime. If policy forbids either, plan a file-based or API-based configuration provider and restrict dashboard access to an authenticated internal network.

How DeployOpen works on this

DeployOpen plans and builds the Traefik routing, TLS and Strapi proxy settings for your Docker host, inside infrastructure you control. The work is agreed as a fixed scope in writing before the build starts, and ongoing support is available as a retainer.

How we scope

  • Confirm the Strapi version, Node.js version and database engine that the container will run.
  • Record the public hostnames, DNS ownership and the Traefik entrypoints and certificate resolver you will use.
  • Agree in writing whether the admin panel shares the API hostname or uses a separate one.

How we build

  • Write Traefik labels that route the public host to the Strapi container on port 1337.
  • Set server.url and proxy trust settings so Strapi generates correct links behind Traefik.
  • Test forwarded headers, upload size limits, certificate issuance and renewal on a staging host.

How we hand over

  • Deliver the Compose files, label definitions, environment variable list and a runbook for changes.
  • Document how to verify the certificate, the forwarded protocol and the admin login after each deploy.
  • Walk your platform and security team through the configuration so they can review it independently.

How we support

  • Offer retainer support for Traefik and Strapi version updates, certificate checks and configuration reviews.
  • Plan updates to Traefik and the Strapi image with a tested rollback path before each change.
  • Retest routing and proxy settings after any change to the Strapi version or the host network.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.