Why teams put Strapi behind Caddy with automatic TLS
Teams put Strapi behind Caddy when they run Strapi on a VM or container host and want HTTPS without someone renewing certificates by hand. Caddy takes the public-facing role: it listens on ports 80 and 443, obtains a certificate for the site's domain, renews it before expiry, redirects plain HTTP requests to HTTPS, and proxies the remaining traffic to Strapi on its internal port. Strapi keeps running as a private process that is never exposed directly to the internet. The decision for the team is less about whether Caddy works and more about who owns the certificate lifecycle, the DNS records it depends on, and the firewall rules that let the certificate authority reach the host.
Caddy handles the transport, but Strapi still has to know its public address. Caddy passes the original host and scheme in forwarded headers, and Strapi builds absolute URLs, admin links and cookie scope from its own server.url setting in config/server.js. If that value still points at ` generated links, admin redirects and SSO callbacks will break in ways that look like application bugs. Teams should confirm, in the Caddy version they choose and in the Strapi version they run, how the proxy forwards headers and which Strapi proxy settings the current documentation describes. This page does not treat any Strapi version-specific setting as confirmed, so check the Strapi documentation for your release before copying a configuration.
Which proxy layer fits your team and where TLS ends
Caddy is a web server and reverse proxy that obtains and renews public certificates automatically for the site names you configure, so TLS setup is largely part of the server configuration. For a single Strapi host or a small set of hosts, this removes a recurring operational task that teams otherwise handle with scripts or cron jobs. Its configuration is short and readable, which suits teams that want few moving parts.
- Certificate automation: Caddy requests and renews certificates for configured domains without a separate client, provided the host can complete the validation method you choose.
- Configuration style: A Caddyfile maps a site address to a reverse proxy target, so the Strapi upstream and forwarded headers fit in a few lines.
- Team ownership: Teams with little proxy experience can maintain it, but someone still owns the host firewall, DNS records and renewal monitoring.
- Limits to confirm: Check that your required load balancing, rate limiting and plugin needs are covered by the Caddy build and modules you plan to run.
- Fit: Strong for single-node or small deployments where a standalone edge host is the goal.
Before committing, confirm the certificate validation method and the Caddy version your security team has approved.
Nginx is widely deployed and many platform teams already run it with established TLS processes, logging and change control. Certificates are usually obtained with a separate client or the organization's own certificate tooling, so renewal is a process you design and monitor. Traefik is built for dynamic environments: it reads routing rules from container labels or Kubernetes resources and can request certificates itself, which fits Docker or Kubernetes platforms where services appear and disappear often.
- Nginx certificate handling: Renewal typically runs through a separate ACME client or an internal CA workflow, so confirm who owns that job.
- Nginx configuration style: Explicit server blocks give fine control over headers and buffering, and the team must maintain them by hand.
- Traefik configuration style: Routes and certificate resolvers are declared as labels or resources next to the Strapi service definition.
- Traefik team ownership: Platform engineers who already manage label-based routing usually maintain it best.
- Existing platform: If your organization already standardizes on one of these, the cost of a second proxy usually outweighs the benefit of a different tool.
Check which proxy your operations team can patch, monitor and audit without a new skill set.
HAProxy is a load balancer that terminates TLS and distributes traffic across several backends with active health checks. It is a common choice when several Strapi instances sit behind one entry point, or when the team already runs HAProxy for other services. Certificates are typically installed from files or an external issuance process, so automated renewal is not the strength of HAProxy alone, and the team should plan that job explicitly.
- Certificate automation: Renewal usually depends on an external ACME client or your certificate authority workflow.
- Configuration style: Frontends, backends and health check rules are explicit, which suits teams that want precise control over balancing.
- Health checks: HAProxy can probe the Strapi health endpoint on each instance and remove unhealthy backends from rotation.
- Team ownership: Operations teams that already tune load balancers tend to maintain it most comfortably.
- Session and state: Several instances need shared storage and sessions handled consistently, which is a design question independent of the proxy.
Confirm the health check path and interval against the Strapi version you deploy before relying on them.
The point where TLS ends determines what Strapi sees. If the proxy terminates TLS, Strapi receives plain HTTP from the proxy, so it must trust forwarded headers such as the original scheme and host to build correct absolute URLs, cookies and redirects. If TLS passes through to Strapi, the application handles certificates itself, which moves renewal into Strapi's host and removes the proxy's header role. Re-encrypting between the proxy and Strapi adds a second certificate to manage but keeps traffic encrypted inside the network.
- Headers Strapi must trust: When the proxy terminates TLS, the proxy must set the forwarded scheme and host, and Strapi must be configured to use them.
- Settings that depend on it: The
server.urlvalue and proxy trust settings in Strapi's configuration must match the public address users see. - Health check location: Probes may run at the proxy against Strapi's health path, or at a load balancer over internal HTTP, and the path must be reachable from there.
- Internal traffic: Decide whether traffic between the proxy and Strapi crosses an untrusted network, which determines whether re-encryption is required.
- Logging: Client IP addresses reach Strapi only through forwarded headers, so audit logs depend on the same configuration.
Confirm the termination point with your security team before writing the Strapi proxy settings.
No proxy is the correct answer for every team. The better question is which proxy your organization already runs, who will patch and monitor it, and whether the deployment is one node, several instances, or a container platform. A team with an established Nginx or HAProxy estate gains more from consistency than from a new tool, while a small team deploying one Strapi host may prefer the reduced workload that Caddy offers. Docker and Kubernetes environments often make Traefik or an ingress controller the natural fit.
- Single host: Caddy keeps certificate work and configuration small.
- Existing standard: Reuse Nginx, HAProxy or Traefik where your team already has change control and monitoring.
- Several instances: Balancing and health checks push the decision toward HAProxy or a container platform's ingress.
- Ownership: Name the team responsible for certificate renewal alerts, proxy upgrades and header settings.
- Compliance evidence: Ask whether your assessor expects documented TLS versions, certificate sources and logs for the chosen tool.
Before you decide, document the existing platform, the owner for each proxy task, and the termination point, then confirm them against your Strapi version.
Strapi settings that matter behind a proxy
This table lists the Strapi settings that must agree with the Caddy site block, and what breaks when each one is wrong. Read it as a checklist: confirm each key name and default against the Strapi docs for your exact version before go-live, then test generated URLs, admin login and client IP logging through the public hostname.
| Setting | When it fits | What goes wrong if misset |
|---|---|---|
| server.url (public URL) | Set to the public HTTPS hostname that Caddy serves, so Strapi builds absolute links for media, callbacks and admin pages. | Links point to an internal address or to http, and SSO or admin redirects fail because the callback does not match the public host. |
| Proxy trust (server.proxy) | Enable trust for forwarded headers only when Caddy is the sole entry point, so Strapi reads the original scheme and client address. | Strapi sees http instead of https, secure cookies may not be issued as expected, and logs or rate limits record the Caddy address for every request. |
| Caddy forwarded headers | Caddy's reverse_proxy sets forwarding headers such as X-Forwarded-For and X-Forwarded-Proto. Confirm the defaults and any header overrides in your Caddy version. | A client that can reach the Strapi port directly can send spoofed forwarding headers, and any trusted-proxy list that is too broad lets those headers through. |
| Host and port binding (HOST, PORT) | Bind Strapi to a loopback or private interface, with the Caddy upstream pointing at the same port that PORT sets. | Binding to a public interface exposes Strapi without TLS, and a mismatch between PORT and the upstream causes 502 errors from Caddy. |
| Admin URL and panel serving (config/admin.ts url, serveAdminPanel) | Use a path such as /admin on the same host, or a subdomain served by the same Caddy site, and keep Caddy routes aligned with that choice. | Admin assets return 404, or the login page loops, when the admin path in Strapi and the Caddy matcher disagree. |
| APP_KEYS and secret variables | Set stable values from your secret store, so every instance and every restart uses the same keys. | Sessions and tokens break on each deploy, or keys end up in the repository or image, which weakens every signed value Strapi issues. |
Setting up Caddy in front of Strapi step by step
This sequence takes a Strapi instance from a bare process on a private port to a site served over HTTPS with a certificate Caddy issued and renews, with Strapi generating correct absolute URLs from forwarded headers.
Confirm DNS points at the host
Before anything else, the operator confirms that the public hostname for the Strapi API and admin panel resolves to the server's public address, and that ports 80 and 443 are reachable from the internet. Caddy uses these to complete certificate challenges, so a mismatch here is the most common reason issuance fails. Check with a DNS lookup from outside your network, such as dig +short against the hostname, and confirm a connection to port 443 succeeds from an external host. The step is done when both checks return your server's address and the port is open.
Bind Strapi to a local port
Strapi should listen only on the loopback interface, so that all public traffic enters through Caddy. Set HOST to 127.0.0.1 and PORT to a fixed value such as 1337 in the environment file, then start the application under your process manager of choice. The engineer running the service checks the listener with a command such as ss -ltnp and then runs curl from the server itself. The step is done when the health endpoint returns a success response locally and the port is not visible on the public interface.
Write the Caddyfile site block
Create a Caddyfile with one site block for the public hostname, containing a reverse_proxy directive that points to 127.0.0.1:1337. Caddy enables automatic HTTPS for named hostnames by default, so no certificate file or manual TLS directive is needed for a standard public setup. Validate the file with caddy validate --config Caddyfile before reloading. The step is done when validation reports a valid configuration and the file lists only the hostname, the proxy target and any directives you have deliberately added.
Set the public URL and proxy trust in Strapi
Configure Strapi so it knows it sits behind a proxy and what its public address is. In config/server.js, set url to the public HTTPS address and enable proxy handling so that Koa reads X-Forwarded-Proto and X-Forwarded-Host from Caddy. Confirm the exact option names against the Strapi server configuration reference for your version, since these settings are version-sensitive. Restart Strapi and check that the admin panel loads without mixed-content warnings. The step is done when the configuration is saved, the process restarts cleanly, and no startup errors mention the URL or proxy settings.
Start Caddy and let it issue the certificate
Start or reload Caddy as a service so it reads the Caddyfile. On first request for the hostname, Caddy contacts its certificate authority, completes the challenge over port 80 or 443, stores the certificate and schedules renewal before expiry without operator action. The engineer watches the Caddy log for successful certificate issuance and any ACME errors. The step is done when the log shows the certificate was obtained for the hostname and a request from outside your network succeeds without a certificate warning.
Verify redirects and HTTPS responses
Test the public entry point from a machine outside your network. Run curl -I to confirm the plain HTTP request is redirected to HTTPS, then curl -I to confirm a valid TLS handshake and a success status. Log in to the admin panel over HTTPS with a test administrator account to confirm session cookies are set as secure. The step is done when the redirect returns a permanent redirect to the HTTPS address, the health check succeeds and admin login completes without errors.
Verify forwarded headers and absolute URLs
Confirm that Strapi builds URLs from the public address rather than the local listener. Request an API endpoint that returns media or links, such as an upload entry, and check that absolute URLs begin with https and the public hostname. You can also inspect what Caddy forwards by temporarily logging request headers. If URLs still show http or 127.0.0.1, return to the proxy and URL settings in Strapi. The step is done when every generated absolute URL uses the public HTTPS address and the forwarded headers arrive as expected.
How forwarded headers reach Strapi and why trust matters
A browser never talks to Strapi directly in this setup. The request goes from the client to Caddy, which terminates TLS on port 443 and forwards plain HTTP to the Strapi process on the private network. By the time Strapi sees the request, the socket peer is Caddy, not the visitor. Caddy adds headers that carry the original facts: X-Forwarded-For holds the client address chain, X-Forwarded-Proto records whether the visitor used HTTPS, and Host keeps the public hostname. Strapi reads these values to build absolute URLs, decide whether cookies should be marked secure, and attribute requests to a client IP. Caddy's reverse_proxy directive sets these headers by default, so the work is mostly confirming that nothing in front of Caddy overwrites them.
The risk is the trust boundary. Forwarded headers are plain request headers, and any client can send them. If Strapi accepts X-Forwarded-For from any source, a visitor can send a spoofed address and the value will appear in access logs, in rate-limit keys and in any audit trail that records IPs. A forged X-Forwarded-Proto: https can make Strapi issue cookies or redirects that assume a secure connection when the request arrived over plain HTTP. The control is to make Strapi trust forwarded headers only from the proxy hop, which means setting the proxy address or range that Strapi should accept and keeping the Strapi port off any public interface. Your team should confirm the exact proxy trust and server.url settings against the version it deploys, and test with a request that carries a forged header from outside the network to confirm the value is ignored.
Request flow from browser to Strapi through Caddy
The flow starts when a browser resolves the public hostname through DNS and opens a TLS connection to Caddy, which holds the certificate it obtained and renews automatically. Caddy terminates TLS and forwards the request over the private network to Strapi on its internal port, adding forwarded headers that tell Strapi the original scheme and host. Strapi then queries its database over a separate connection. Check that server.url matches the public address and that Strapi trusts only the proxy network, because a mismatch breaks generated links and admin login.
Browser traffic reaches Strapi only through Caddy, which handles TLS and forwards headers.
Security checks before exposing the Strapi admin over HTTPS
Once Caddy serves the Strapi admin over HTTPS, the public surface is the certificate, the proxy path and the admin login. Each of the checks below closes a different gap, and they only work together when the Strapi port is unreachable from the internet and Strapi trusts only the proxy it actually sits behind. The full Strapi review covers the rest of the configuration.
Certificate issuance and ACME limits
Caddy requests certificates over ACME, so the domain must resolve to the Caddy host and the challenge path must be reachable from the certificate authority. Check which CA Caddy uses, whether staging certificates are enabled for testing, and how many attempts a domain can make in a given window. Repeated failed issuance from a misconfigured host can lock you out for a period, so test against staging first. Confirm the rate-limit policy with the CA you choose rather than assuming defaults.
Certificate data storage
Caddy stores issued certificates, private keys and account data in its data directory. Treat that directory as a secret: restrict its permissions, keep it out of container images and include it in your backup plan. If Caddy runs in several containers or hosts, decide where the data lives so that one node does not issue duplicate certificates or lose the renewal state.
Keeping the Strapi port private
Strapi listens on its application port, which should not accept connections from the internet. Bind it to a loopback or private interface, or restrict it at the firewall or security group so that only the Caddy host or network can reach it. Verify from outside the network that the port does not respond, because a direct connection bypasses every header and TLS control in front of it.
Trusted proxy addresses
Strapi uses forwarded headers to build URLs and determine the client protocol, so it must trust only the address of the Caddy instance. Set the proxy trust list to Caddy's address or range, not a broad private subnet, and confirm that clients cannot inject their own X-Forwarded-For or X-Forwarded-Proto values that reach Strapi unchanged. Test the behavior with a request that sets a spoofed header.
Secure cookies over HTTPS
Once the admin is served over HTTPS, session cookies should carry the secure attribute so browsers never send them over plain HTTP. Confirm that the Strapi admin URL and server.url use the https scheme, because a mismatch can cause login loops or cookies that are rejected. Check the cookie domain and SameSite settings if the admin and API sit on different hosts.
Admin access controls
Limit who can reach the admin login at all, for example with an allow list at Caddy, a VPN or an identity-aware proxy in front of the admin path. Decide whether admin SSO is required and whether local login stays enabled as a fallback. Keep the admin on a dedicated hostname if possible, and record who holds super admin rights.
Strapi SSO docsQuestions teams ask before setting up Caddy for Strapi
Can our own team set up Caddy in front of Strapi without outside help?
Yes, if someone on the team can run Strapi and Caddy and owns the proxy configuration. The work is small in code but precise: Caddy must obtain certificates for the public name, forward traffic to the Strapi process, and Strapi must know its public URL so that generated links, redirects and cookies are correct. The main risk is not the Caddyfile itself but the Strapi side, where server.url and proxy settings must match what Caddy sends. A team that already runs Strapi in production and has someone who reads Caddy configuration will usually manage it internally. A team without either skill set should ask a partner for a written scope that includes the handover.
What drives the effort up for a Caddy and Strapi setup?
The effort depends mostly on how many places the proxy must serve and how many standards already exist. The main drivers are:
- Multiple environments, such as staging and production, each with its own domain and certificate path
- The admin panel on a separate host, which adds CORS, cookie and admin URL settings
- Internal-only domains that need certificates from a private authority instead of a public one
- An existing Nginx or Traefik standard that the platform team wants to keep, so the setup must match their logging, headers and deployment pattern
Each added item increases the number of configurations to test, so ask for the environment list in the scope before pricing.
Does Caddy renew TLS certificates automatically for Strapi?
Caddy obtains and renews certificates automatically for domains it can validate, so the operator does not normally schedule renewals for the public name. What the team still has to confirm is that DNS points to the host, that the required ports are reachable from the internet for the validation method in use, and that the storage directory for certificates survives host rebuilds. For internal-only domains, certificates usually come from a private authority, and the team must decide how clients will trust it. Confirm the validation method and the certificate storage plan with your own network owners before go-live.
What do we need to provide for the Caddy and Strapi work?
Plan to provide four things before work starts:
- DNS access, or a named person who can create the records for each public and internal name
- Host ports 80 and 443 open on the machine running Caddy, or the port plan your network team requires
- Access to the Strapi host or container configuration, including environment variables
- A Strapi owner who knows the proxy settings, the public URL and how the admin panel is reached
The Strapi owner matters most. Without that person, the first change to a domain or certificate will break login or media links, and nobody will know which setting to change.
How do we verify that the proxy and TLS setup works?
Verification checks the public path end to end, not only whether Caddy starts. A useful check covers the certificate chain and expiry for each name, the redirect from HTTP to HTTPS, the forwarded protocol and host values reaching Strapi, and generated absolute URLs in API responses and the admin panel. Test login through the admin panel, a content read and write through the API, and an upload, since upload limits and media URLs often reveal proxy mistakes. Ask for these checks to be written into the handover so the team can repeat them after each change.
What goes wrong most often when Strapi sits behind a reverse proxy?
The most common failure is a mismatch between the public address and what Strapi believes its address is. When Strapi builds links, redirects or cookie domains from the wrong scheme or host, login loops, broken media URLs and mixed-content warnings follow. Another frequent problem is a proxy that does not pass forwarded headers, so Strapi sees plain HTTP behind a site that is served over HTTPS. Teams also hit this when they move from one domain to another and forget to change the server URL in the environment. Check these values first when a symptom appears.
Should we ask for a written scope before hiring help with Caddy?
Yes. Most engagements at DeployOpen are fixed-scope, so the scope, deliverables and timelines are agreed in writing before work starts. For this topic, the scope should list each domain and environment, where the proxy runs, whether the admin panel is on the same host, how certificates are issued and stored, the Strapi settings to be changed, the verification steps, and the handover to your team. DeployOpen does not publish a price list, so a quote follows from that written scope. Request the scope in writing and compare it against what your team can maintain after the work ends.
Where to check the Strapi and proxy documentation
Before you finalize the Caddyfile or the Strapi environment file, confirm two things against the vendor documentation for the exact versions you run: the runtime requirements and the admin login behavior. The Strapi installation requirements page lists the supported databases, the supported Node.js versions and the Strapi 5 release line you are targeting, so check it against the Node.js version in your build image and the database version behind your deployment. The Strapi installation (CLI) requirements page is the natural starting point for that check.
If you plan to put the admin panel behind Caddy with SSO, read the Strapi SSO documentation before you choose the public hostname. The SSO feature applies only to administrator login, and its settings interact with the admin URL and cookie behavior your proxy configuration produces. Confirm which plan includes SSO for your organization, since the self-hosted pricing page lists it as an add-on or an Enterprise feature, and record the answer in the scope so procurement and the platform team agree.
Caddy's own documentation is the authority for directive syntax, including the reverse proxy directive, the header handling options and the automatic TLS behavior. Check the directives against the Caddy version you deploy, not against examples copied from forum posts or older guides, because directive names and defaults change between releases. Test the final configuration with caddy validate before reload, and confirm that X-Forwarded-Proto and X-Forwarded-Host reach Strapi as your server.url settings expect.
How DeployOpen scopes and delivers Strapi proxy and TLS work
DeployOpen plans and builds the Caddy front end, the Strapi proxy settings and the checks that confirm forwarded headers are trusted, inside infrastructure you control. Engagements are fixed-scope, with the routing, certificate and handover work agreed in writing before the build starts.
How we scope
- Confirm the public hostnames, the admin panel location and whether the admin panel is served from the same host as the API.
- Record the Strapi version, the Node.js version and the database engine so proxy settings match your runtime.
- Agree in writing which Caddy configuration, Strapi settings and verification steps are in the fixed scope.
How we build
- Write the Caddyfile for your domains, with automatic certificate issuance and renewal for each public hostname.
- Set server.url, proxy and forwarded header settings in Strapi and test them against the admin login and generated URLs.
- Test upload size limits, WebSocket behavior if used, and redirects through the proxy before any traffic moves.
How we hand over
- Deliver the Caddyfile, Strapi configuration and environment variable list under version control with a short runbook.
- Document how certificates are issued, where they are stored, and what to check when renewal fails.
- Walk your platform and security teams through the routing diagram and the test results so they can review them.
How we support
- Offer ongoing support, upgrades and testing as a retainer after handover, with the scope agreed in writing.
- Plan a retest of proxy and TLS settings after Strapi upgrades or changes to the network path in front of Caddy.
- Ask for a quote based on the written scope, since DeployOpen does not publish a price list.

