Strapi behind Nginx

Putting Strapi behind Nginx with TLS is mostly a matter of telling Strapi its public URL, passing forwarded headers correctly and sizing uploads. This page explains the settings, trade-offs and checks needed before go-live.

On this page

Why teams put Strapi behind Nginx and what that changes

Teams put Strapi behind Nginx when a self-hosted Strapi API must be reachable over HTTPS under their own domain. In that setup, Nginx terminates TLS, routes requests to the Strapi process, limits how large a request body can be, and manages proxy buffering. Strapi itself must be told its public address through the url setting in config/server.js and must trust the proxy headers that Nginx adds, so that generated links, redirects, cookies and admin URLs use the address users actually see. Getting only one side right is a common cause of mixed-content warnings, redirect loops and broken uploads.

This matters most when Strapi serves editors and public front ends from infrastructure the organization controls. The Node.js process runs inside your network, on a virtual machine, container or Kubernetes cluster you manage, so the reverse proxy is part of your own trust boundary. It is also where certificates are renewed, where access logs are written and where request limits are enforced. Before you copy any sample configuration, confirm the exact keys for your installed Strapi version in the server configuration reference and the proxy settings in the installation documentation, since option names and defaults can change between 5.x releases.

Plan the decisions early, because each one changes the configuration. Decide whether the admin panel shares the API hostname or moves to a subdomain, since that affects cookies, CORS and the SSO restriction on unrelated domains. Decide how many hops sit between the internet and Strapi, so you know which forwarded headers Strapi should trust. Confirm the maximum upload size your editors need against the body limit in Nginx and in Strapi's upload settings, because the lower value wins. Then run a short test of login, a media upload, a redirect and a generated URL through the proxy before any content team relies on it.

Nginx and Strapi configuration options and when each fits

This table compares the main routing, certificate and upload limit choices when Strapi sits behind Nginx. Read each row against your DNS setup, your certificate process and the largest file your editors need to upload. The main takeaway is that the admin panel layout and the upload limit should be decided together, before server.url and proxy settings are written.

OptionWhen it fitsRequires from DNS and certificatesMain trade-off
Single domain, admin panel at a pathOne public hostname is preferred and the admin panel can live under a path such as /admin on the same origin as the API.One DNS record and one certificate covering the hostname. Confirm with your Strapi version that the admin path and server.url match the public URL.Simpler certificates and cookies, but path-based routing must be checked carefully against the API routes and any other services on the same host.
Separate admin subdomainEditors reach the admin panel on their own hostname, or the admin panel is hosted apart from the API.A second DNS record and certificate coverage for both names, plus CORS and cookie settings that match both origins. Confirm against the admin panel hosting documentation.Clearer separation and access rules for admin traffic, at the cost of more DNS, CORS and cookie configuration to test.
Managed certificate from a public CA or cloud providerPublic hostnames, a team that wants renewal handled automatically and no private trust distribution.Domain control validation for each hostname, a renewal path that Nginx can reload, and outbound access for the validation method you choose.Low operational effort, but renewal failures depend on DNS or HTTP validation staying reachable from the issuer.
Internal CA certificateHostnames are internal only and clients or devices already trust your private root.Your internal CA must issue the certificate, and every client, browser and automation tool must trust the root. Confirm distribution with your security team.Full control over issuance and lifetime, but clients that do not trust the root will fail, and renewal becomes your responsibility.
Wildcard certificateSeveral Strapi hostnames, such as API, admin and preview, share one parent domain.Wildcard coverage for one parent domain and a validation method that supports wildcard issuance. Confirm the method your DNS provider or CA supports.Fewer certificates to manage, but a leaked wildcard key affects every subdomain it covers.
Upload limit enforced in Nginx (client_max_body_size)Large media or file uploads must be rejected before they reach Strapi, and the proxy is the first place to protect the application.No DNS or certificate change. Set the value from your own upload requirements and test a file just above and below the limit.Rejected requests never reach Strapi, but the limit applies to every route on that server block, so set it per location where needed.
Upload limit enforced in Strapi upload settingsThe application should own the rule for file size and the upload provider, and proxy limits should stay aligned with it.No DNS or certificate change. Set the Strapi limit from your own requirements and keep it consistent with the Nginx value.Strapi is the authoritative check, but requests still pass through Nginx first, so a lower proxy limit silently overrides a higher Strapi setting.

How to set up Strapi behind Nginx with TLS

This sequence takes a Strapi instance from a working local or staging install to a public HTTPS endpoint behind Nginx, with forwarded headers, upload limits and an admin panel path or subdomain that all generate correct URLs. Each step ends with a check you can run before moving on.

  1. Confirm Node.js and database versions

    The platform or DevOps engineer checks the Node.js version and database engine against the Strapi installation requirements before touching the proxy. Strapi 5 runs only on Active or Maintenance LTS Node.js versions and supports PostgreSQL 14 or later, MySQL 8.0 or later, MariaDB 10.3 or later and SQLite 3, without NoSQL databases. Confirm the exact Node.js line against the current requirements page, because the supported set changes over time. The step is done when node --version and the database server version both match the documented minimums and the application starts cleanly on its internal port.

  2. Set the public URL and server URL

    The engineer sets the public address in the Strapi environment so that generated links, admin asset paths and redirects point at the Nginx hostname rather than the internal port. The relevant settings are the server URL and host and port values in config/server.ts or config/server.js, which should read from environment variables such as PUBLIC_URL so each environment can differ. Bind Strapi to 127.0.0.1 or a private interface so that only Nginx can reach it. Check the result by loading a Strapi endpoint directly on the internal port and confirming it responds, then confirming the configured URL value reads back as the public https address.

  3. Configure Nginx proxy headers and proxy pass

    The engineer creates a server block in Nginx that forwards requests to the Strapi port with proxy_pass and passes the Host, X-Forwarded-For and X-Forwarded-Proto headers. Setting X-Forwarded-Proto to the scheme Nginx received lets Strapi build https links even though it listens on plain HTTP internally. Also set proxy_http_version 1.1 and the Upgrade and Connection headers if the admin panel or any feature uses WebSockets. Run nginx -t to validate the configuration, reload Nginx, then send a request through the public hostname and confirm the API responds with a 200 status from the expected route.

  4. Set the request body size limit

    The engineer raises client_max_body_size in the Nginx server or location block so that media uploads are not rejected before they reach Strapi. Nginx defaults to a small limit, which causes failures that look like application errors. Choose the limit from the largest file editors will upload, and confirm the upload provider or any application-level limit in Strapi matches it. The check is to upload a file just above the old default and a file near the chosen limit through the admin panel, then confirm both are stored and that a file over the limit returns a clear 413 response from Nginx.

  5. Obtain and install the TLS certificate

    The engineer obtains a certificate for the public hostname from the organization's certificate authority or an automated issuer, then installs the certificate chain and private key in Nginx with ssl_certificate and ssl_certificate_key. Redirect plain HTTP on port 80 to HTTPS, and confirm the renewal process is in place before go-live. Confirm with the security team which certificate authority and renewal method apply in your environment. The check is that nginx -t passes, the hostname loads over HTTPS with a valid chain, and the HTTP request returns a redirect to the https address.

  6. Verify generated URLs use https

    Before configuring the admin path, the engineer confirms that Strapi generates https links. Open the admin panel login page, inspect the network requests for the admin bundle and assets, and check that they load from the public https hostname with no mixed content warnings. Request a content entry that includes an uploaded media file and confirm the media URL starts with https. If any link still uses http or the internal port, return to the server URL and forwarded proto settings, because a mismatch there is the most common cause.

  7. Configure the admin panel path or subdomain

    The engineer decides whether the admin panel lives on the same hostname under a path, or on its own subdomain, and sets the admin URL and any path prefix in the Strapi configuration to match. A subdomain usually keeps routing simpler, while a path requires the admin build and its asset base to be set consistently. If the admin panel is served from a different host than the API, review the CORS, cookie and SSO restrictions before rollout. Confirm with the identity and security teams which option your access policy supports. The check is that the admin login loads at the chosen address, signs in successfully, and that its assets return 200 responses without redirects loops.

  8. Run an end-to-end upload and login test

    The engineer closes the sequence with a combined test through the public https hostname. Sign in to the admin panel, create a content entry, upload a large media file near the configured limit, publish the entry, and fetch it through the public API. Confirm that the client IP recorded in the Strapi logs reflects the forwarded address rather than Nginx's own address, which shows that X-Forwarded-For is trusted. The sequence is complete when all of these succeed and the results are recorded so that a later change to Nginx or Strapi can be retested against the same checklist.

How forwarded headers affect Strapi URLs, cookies and redirects

When TLS ends at Nginx, Strapi receives plain HTTP from the proxy, so it cannot see the scheme and host that the browser actually used unless Nginx passes them along. Without those headers, Strapi builds URLs from what it receives on the socket, which means links and an internal host name or port in responses, redirects and asset paths. The browser then blocks scripts or styles loaded over from an page as mixed content, and redirects can send users to an address they cannot reach. Nginx should set X-Forwarded-Proto, X-Forwarded-Host and X-Forwarded-For, and the public address Strapi uses should be set through server.url` so that generated links do not depend solely on request headers.

Cookies and admin login are where a missing forwarded scheme most often shows up as a loop. Session cookies marked Secure are only sent back over HTTPS, so if Strapi believes the request is plain HTTP, the browser can store a cookie that is never returned and the admin panel keeps sending the user back to the login screen. The cookie domain and path also have to match the public host, which is why a mismatch between the host Nginx forwards and the host in the browser address bar is a frequent cause. Treat any login redirect loop as a header problem until proven otherwise.

Forwarded headers are only useful if Strapi believes them from the right sources. Trusted proxy settings in your Strapi configuration determine which upstream addresses may set these headers, and anything from an untrusted client should be ignored, so confirm that the Nginx host is the only source trusted in your deployment. Do not assume how your version of Strapi handles these headers, redirects or cookie flags. Verify them on your release: request the admin login, follow redirects, inspect Set-Cookie attributes and the URLs in API responses, then repeat the check after each Strapi upgrade. Your Strapi version's documentation for the proxy and server.url settings is the authority for which keys apply.

Security settings to review before exposing Strapi through Nginx

Nginx is the only component that should face the internet, so most of the exposure risk sits in how it forwards traffic, terminates TLS and logs requests. The cards below cover the edge settings and the operational data around them. Application-level Strapi settings are covered separately in the Strapi security configuration topic.

Restrict forwarded hosts and headers

Nginx should forward only the headers Strapi needs, such as X-Forwarded-For, X-Forwarded-Proto and Host, and set them from known values rather than passing client-supplied copies through. Strapi uses these headers to build URLs and decide whether a request is secure, so a spoofed value can change generated links or redirects. Check that the server.url value in your Strapi configuration matches the public hostname Nginx serves, and that the proxy only accepts requests for that name.

Keep the Strapi port off the public network

Strapi listens on its application port, commonly 1337, and that port should be reachable only from the Nginx host or the private network segment behind it. If the port is open on the public interface, clients can bypass Nginx entirely, along with its TLS, rate limits and access rules. Confirm with a scan from outside your network, and bind Strapi to a private address or a firewall rule that allows only the proxy.

Set TLS protocols and renewal

Limit Nginx to current TLS protocol versions and strong cipher suites, and disable older protocols that your clients do not need. Automate certificate issuance and renewal with a tool such as certbot, and alert on failed renewals, because an expired certificate stops the admin panel and API for every user at once. Test the configuration with an external TLS scanner after each change to the server block.

Strapi install requirements

Limit admin panel access by network

The Strapi admin panel is an administrator surface, so it should not be open to the whole internet when the API is. Restrict the admin path with Nginx allow and deny rules to known office or VPN address ranges, or serve it from a separate host with its own access controls. Remember that admin single sign-on applies only to administrator login, and that end-user access is governed separately by the Users and Permissions plugin.

Strapi SSO docs

Review Nginx access log retention

Nginx access logs record client IP addresses, request paths, user agents and sometimes query strings, which can contain personal data. Decide what is logged for the API and the admin panel, set a retention period that matches your policy, and restrict who can read the log files. Strip or hash sensitive query parameters where possible. Confirm the retention rules with your privacy or legal team before go-live, since the right period depends on your jurisdiction and purpose.

Protect the secrets Strapi depends on

Strapi relies on secrets such as APP_KEYS, API_TOKEN_SALT, ADMIN_JWT_SECRET and the database password. Keep them in environment variables or a secrets manager with file permissions that block other local users, and never place them in the Nginx configuration or in version control. Rotate them through a planned change, because rotating some keys invalidates existing sessions or tokens. Check the Strapi security configuration topic for the full list of settings to verify.

How a request travels from the browser to Strapi through Nginx

A request starts in the browser over HTTPS and reaches Nginx on the public side, where TLS ends and forwarded headers such as the original host and protocol are set. Nginx passes the request across the trust boundary to the Strapi process on the internal network, which reads a server.url value to build absolute URLs. Strapi then queries the database and, for media, the upload provider. Check that the admin panel path or subdomain is routed to the same Strapi process and that forwarded headers reach it intact.

Request path from the browser through Nginx to Strapi, with the trust boundary marked.

Questions teams ask before setting up Strapi behind Nginx

How much effort does putting Strapi behind Nginx take?

The Nginx configuration itself is small, but the effort depends on how many pieces must agree. Each environment (development, staging, production) needs its own server.url, TLS certificate and proxy settings, so more environments mean more checks. A separate admin subdomain adds a second host to configure, along with CORS and cookie behavior that must match. Large uploads need a deliberate client_max_body_size value and matching Strapi upload settings. SSO adds callback URLs that must match the public address exactly. Ask any partner to list each host, certificate and header path in the written scope so the work can be counted.

How long does the setup take, and what does the network team need to provide?

Duration depends on how quickly DNS records, certificates and firewall rules can be changed in your environment, which is often the slowest part. Before work starts, confirm with your network and DNS team the public hostnames, the internal address and port where Strapi listens, who issues the TLS certificate and how renewal works, and which load balancers or CDNs sit in front of Nginx. Ask for a timeline that shows these approvals as separate steps, since the Nginx work itself can usually be tested in a staging environment once they are in place.

Can an in-house engineer set this up using the Strapi docs?

Yes, an engineer comfortable with Nginx and TLS can usually follow the Strapi documentation for server.url, proxy settings and admin URL configuration. The harder part is verifying behavior: checking that forwarded headers reach Strapi, that redirects and cookies are correct, and that uploads succeed at the size you expect. Teams without recent Nginx experience often find that the review and testing take longer than the configuration. If you prefer to keep ownership in-house, ask for a written checklist of verification steps as part of any engagement.

Does Strapi Cloud remove the need to configure Nginx?

Strapi Cloud is a hosted service, so it handles hosting and routing for projects on it, and you do not run your own Nginx in front of it. The trade-off is that the hosting is outside your infrastructure. Strapi's listed Cloud plans are Starter, Pro and Business, with prices published on the Strapi Cloud pricing page at Strapi Cloud pricing. Check that page for current plan details and compare them against the cost of your own hosting, including your team's time. If you must run in your own cloud accounts or data centers, self-hosting with Nginx remains the path.

What should a fixed-scope quote for this work include?

A fixed-scope quote should list the hostnames and environments covered, the Nginx configuration to be delivered, the server.url and proxy settings for each Strapi instance, the upload size limits agreed, and how the admin panel is served (path or subdomain). It should also state which items are handled by your team, such as DNS records and certificate issuance, and which are handled by the partner. Ask for the verification steps, the testing environments used, the handover documentation and whether a retest is included. Fees and timelines should appear only in the written scope.

Which Strapi settings most often break behind a reverse proxy?

The most common failures involve the public URL and forwarded headers. If Strapi does not know its public address, generated links, admin redirects and media URLs can point to the internal host or port. Strapi must be configured to trust the proxy so that it reads the original protocol and host correctly, otherwise secure cookies and login redirects can fail. Upload limits are another frequent problem, since Nginx rejects large request bodies before Strapi sees them. Test login, file uploads and admin navigation through the public hostname before go-live.

Does serving the admin panel on a subdomain change the SSO setup?

Yes. Serving the admin panel on a separate subdomain changes CORS, cookie scope and the callback URLs registered with your identity provider. Strapi's SSO feature applies to administrator login through an identity provider, and the documentation describes restrictions on unrelated domains, so confirm the exact behavior for your Strapi version in the Strapi SSO docs before choosing a layout. Ask for the callback URLs and cookie settings to be tested with the identity provider in staging.

What to monitor after go-live

The first ongoing check is certificate renewal, because a proxy that stops renewing its certificate fails at the edge while Strapi itself looks healthy. Confirm how the certificate is issued and renewed (ACME client, cron job or a managed certificate on a load balancer), check the expiry date from outside the network, and alert before it lapses. After each renewal, reload Nginx with nginx -t followed by a reload, and confirm that the server_name block still serves the expected hostname. Also re-check the proxy_set_header X-Forwarded-Proto and X-Forwarded-For lines after any change to the Nginx configuration, since a quiet regression there breaks the server.url assumptions Strapi relies on.

Version coordination is the check that most often gets skipped. Strapi 5 minor releases have shipped roughly weekly, for example v5.56.0 on September 30 and v5.57.0 on October 7, 2026, so an unpinned install drifts quickly. Pin the Strapi version in your lockfile or image tag, and schedule a short review of each new minor release in a staging copy behind the same Nginx configuration, covering the admin login, a media upload near your client_max_body_size limit and an API call from your front end. Record which Nginx version runs in production and test any proxy change against that version. Review the Strapi GitHub releases page on a fixed cadence so that security and breaking-change notes do not go unread.

Log review and rollback close the loop. Watch Nginx access and error logs for repeated 413 responses (upload limits too low), 502 or 504 responses (Strapi down or slow), and unexpected redirect loops after admin path changes. Keep the previous Nginx configuration file and the previous Strapi image or build under version control so a rollback is one command, not a rebuild. Before any rollback that touches the database, confirm that your backup is current, because Strapi documents that downgrading is not supported. Ask your team or a partner to confirm the exact rollback steps in writing before go-live. DeployOpen can run these checks, upgrades and log reviews as a retainer if you want continuous support. Service levels for a retainer are set in the written agreement, so confirm response commitments before you sign.

How DeployOpen works on this

DeployOpen plans and builds Strapi behind Nginx inside your own infrastructure, so the TLS termination, proxy settings and upload limits are written down, tested and owned by your team. Each engagement starts from a written scope that fixes the deliverables before any configuration changes are made.

How we scope

  • Inventory the hostnames, the public API domain and whether the admin panel stays on the same host or moves to a subdomain or path.
  • Record the expected upload sizes, media flows and any proxied services that share the Nginx host.
  • Agree in writing the server.url value, forwarded header policy, certificate process and acceptance tests before work starts.

How we build

  • Configure Strapi's server settings and proxy trust for the chosen Nginx topology in your environment.
  • Write the Nginx server blocks for TLS, forwarded headers, client_max_body_size and admin panel routing, then test them against real upload and admin login flows.
  • Test the setup in a staging copy first, including redirects, cookies and the admin login path, before any production change.

How we hand over

  • Deliver versioned Nginx and Strapi configuration files, with a short note on each setting and why it was chosen.
  • Document the verification checklist and the steps to change the admin URL or certificate without breaking sign-in.
  • Walk your platform and security teams through the configuration and the acceptance test results before closing the engagement.

How we support

  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
  • Ongoing support, Nginx and Strapi upgrades and continuous testing are available as retainers.
  • Ask any quote to list the environments covered, the acceptance tests included and the upgrade stops that are planned.

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.