Automate certificate renewal on nginx

nginx can obtain and renew certificates itself through the ngx_http_acme_module, or through an external client such as Certbot. Public certificate lifetimes are heading from 200 to 100 to 47 days, so renewal must run unattended with monitoring.

On this page

How nginx certificate renewal can be automated, and what 47 days changes

Web operations teams running publicly trusted certificates on nginx can automate renewal in two ways: the ngx_http_acme_module, which speaks ACMEv2 (RFC 8555) directly from nginx, or an external client such as Certbot with a reload hook. Both remove the manual steps of generating a key, submitting a request, installing the file and reloading the server. The shorter lifetimes now coming into effect make manual renewal unworkable, because a certificate that must be replaced every 47 days is replaced many more times a year than one that lasts 398 days. Under the CA/Browser Forum Baseline Requirements, the maximum subscriber certificate validity drops to 200 days from 15 March 2026, to 100 days from 15 March 2027, and to 47 days from 15 March 2029. Let's Encrypt's own schedule moves its default classic profile to 64-day certificates from 10 February 2027 and to 45-day certificates from 16 February 2028. Anyone who owns a publicly trusted certificate on an nginx server needs to act, and the operations team that owns reloads and monitoring carries most of the work.

The module is configured with acme_issuer in the http context, where the mandatory uri directive sets the ACME directory URL, and acme_certificate in each server block. The acme_certificate directive takes its identifiers from server_name by default and exposes $acme_certificate and $acme_certificate_key for ssl_certificate and ssl_certificate_key. Wildcards and regular expressions in server_name are not supported for this purpose, so operators with those patterns need to list explicit names. The default challenge is http-01, which requires a port 80 listener. The state directory set by state_path holds the account key, issued certificates and private keys, so it must be protected, and without state_path the account key is lost on restart. Teams should confirm the module version they run, since the profile directive requires module 0.3.0 or later, and the nginx-acme README lists ACME Renewal Information (RFC 9773) as implemented, with a build requirement of NGINX sources 1.22.0 or later. The ssl_certificate_cache directive, introduced in nginx 1.27.4 and off by default, matters when certificates come from variables, because nginx otherwise loads the certificate on every TLS handshake.

Reloads are where renewals usually break. Per nginx's control documentation, a HUP signal, which nginx -s reload sends, checks the syntax, tries to apply the new configuration, rolls back if that fails, and lets old workers finish serving their clients. Operations teams should test a reload in staging with a renewed certificate and confirm the new serial appears on the live endpoint. For external clients, Certbot's --nginx plugin is paired with a backup of the configuration before first use and certbot --nginx rollback for reverting changes, and its --deploy-hook runs only after a successful renewal. Certbot 4.0.0 renews a certificate when less than one third of its lifetime remains, so a 45-day certificate renews around day 30, and certificates with a lifetime of 10 days or less renew at half their lifetime. Let's Encrypt recommends ACME Renewal Information where the client supports it, says that a fixed 60-day schedule will no longer be sufficient, and advises monitoring that alerts when a certificate is not renewed on time. The sources do not give a monitoring tool or threshold, so teams should set alert points against the certificate's own expiry date and check the vendor documentation for their chosen client.

The lifetime schedule and what each step means for nginx

This table lists the CA/Browser Forum maximum lifetimes and Let's Encrypt's published timeline, with the validation reuse limit for each step. Read each row for how often an nginx host renews and which renewals fail if done by hand. The new validity applies only to certificates issued after each date, so the next renewal after a step shows the change.

DateMaximum lifetimeWhat it means for an nginx host
From 15 March 2026 (CA/B Forum)200 days, with domain validation reuse of 200 daysRenewals drop to roughly 1 to 2 per year per certificate. A manual renewal still works, but the calendar gets longer between them.
From 13 May 2026 (Let's Encrypt opt-in)45 days on the opt-in tlsserver ACME profileRenewals rise to about 8 per year per certificate for hosts that opt in. Manual renewal is no longer practical at this frequency.
From 15 March 2027 (CA/B Forum)100 days, with domain validation reuse of 100 daysRenewals rise to about 3 to 4 per year per certificate. Hand-run renewals start to miss windows, so scheduled renewal is needed.
From 10 February 2027 (Let's Encrypt default)64 days, with a 10-day authorization reuse periodDefault certificates renew about 5 to 6 times a year per name. A fixed 60-day cron job no longer leaves enough margin, so use ARI or a schedule based on the remaining lifetime.
From 16 February 2028 (Let's Encrypt default)45 days, with a 7-hour authorization reuse periodRenewals reach about 8 per year per certificate. Hand renewal stops working reliably, and each reload must be verified.
From 15 March 2029 (CA/B Forum)47 days, with domain validation reuse of 10 daysRenewals reach about 8 per year per certificate, and each validation must complete within a 10-day reuse window. Automated HTTP-01 or TLS-ALPN-01 challenges on every host are required.

How issuance and renewal work inside nginx

Issuance on nginx is driven by two directives. The acme_issuer directive sits in the http context and names the ACME directory through its mandatory uri parameter, and it sets the challenge type, which defaults to http-01. Because HTTP-01 challenges are answered on port 80, a port 80 listener must exist for the validation to succeed. The acme_certificate directive is valid only inside a server block, takes its identifiers from server_name by default, and generates an ecdsa:256 key unless told otherwise. Regular expressions and wildcards in server_name are not valid identifiers for it, so teams with those patterns should list explicit names. Once acme_certificate runs, it exposes the variables $acme_certificate and $acme_certificate_key, which you pass to ssl_certificate and ssl_certificate_key. Confirm the exact directive syntax for your module version in the nginx ngx_http_acme_module documentation.

The state_path directory is what makes renewals survive a restart. The module keeps the generated account key, issued certificates and private keys there. Account keys are preserved across reloads, but without state_path they are lost on restart, which means the next start must register a new account and reissue. The same directory holds private keys, so it needs restrictive filesystem permissions, limited access for administrators and inclusion in your backup and restore plan. Treat a loss of this directory as a key compromise scenario and plan for re-issuance. The acme_shared_zone directive defaults to ngx_acme_shared:256k, which the module documentation says holds about 50 ECDSA P-256 keys or 35 RSA-2048 keys, so a larger deployment must size the zone up. Check these figures against your own certificate count before go-live.

A reload is how the renewed certificate reaches clients. nginx checks the configuration syntax, applies the new configuration and rolls back to the old one if that fails. On success, old workers finish serving their existing connections before shutting down. Be aware that ssl_certificate_cache, added in nginx 1.27.4 and off by default, caches certificates and keys named with variables. The nginx ssl module documentation notes that using variables without this cache means the certificate is loaded on every SSL handshake, which affects handshake cost and how quickly a renewed certificate is seen, so verify which behavior your version exhibits. Test a renewal in staging by confirming the served certificate's serial number changes after the reload.

Which way to automate nginx certificates

The ngx_http_acme_module implements automatic certificate management with ACMEv2 as defined in RFC 8555, so nginx itself requests, stores and renews certificates without a separate agent. It ships as the open-source nginx-module-acme package, and since 1.29.0 it is also offered as nginx-plus-module-acme with a commercial subscription. You configure an acme_issuer block in the http context, and the uri directive that sets the ACME directory URL is mandatory for every issuer. In each server block, acme_certificate requests the certificate and exposes the variables $acme_certificate and $acme_certificate_key, which you pass to ssl_certificate and ssl_certificate_key.

  • Challenge listener: The default challenge is http-01, and the example configuration notes that a port 80 listener is required to process those challenges. tls-alpn-01 is the alternative if port 80 cannot be open to the internet.
  • server_name rules: Identifiers come from server_name by default. Regular expressions and wildcards are not valid identifiers for acme_certificate and are not supported, so those names must be written out explicitly.
  • Key type: acme_certificate defaults to an ecdsa:256 key, so confirm that clients and any downstream systems accept ECDSA before relying on the default.
  • Shared zone sizing: acme_shared_zone defaults to ngx_acme_shared:256k, which holds about 50 ECDSA P-256 keys or 35 RSA-2048 keys. Larger deployments need a bigger zone, so size it against your certificate count.
  • State and restarts: Account keys survive a reload but are lost on restart unless state_path is set. The state directory holds the account key, issued certificates and private keys, so restrict its permissions.

Before you rely on this path, check your nginx version and package source, and confirm the directives and defaults against the module documentation for your build. Verify that every server name is written explicitly and that your challenge listener is reachable.

Set up ACME issuance and renewal on nginx, step by step

This sequence turns nginx into an ACME client that requests, stores and renews its own TLS certificates through the ngx_http_acme_module, so the server no longer depends on someone copying certificate files in by hand. Each step adds one directive or check, ending with a reload and a confirmation that nginx is serving the issued certificate.

  1. Confirm the nginx build and module

    Check that the nginx binary is version 1.22.0 or later, which is the minimum the nginx-acme project lists for its build requirement. Confirm that the ngx_http_acme_module is available, either from the open-source nginx-module-acme package or, from 1.29.0 onward, the commercial nginx-plus-module-acme package. Run nginx -V to see the version and the modules compiled in. Done when the build reports a version that meets the minimum and the module is present, or when you know you need to install or upgrade the package first.

  2. Back up the existing configuration

    Copy the current nginx configuration directory and any certificate files before changing anything, so you have a known-good state to return to. Certbot's guidance for its nginx plugin makes the same recommendation before any automated change, and it is good practice here too. Store the copy outside the live configuration path. Done when the backup exists and you can list the files it contains.

  3. Define the ACME issuer in the http context

    Add an acme_issuer block in the http context and set its uri directive to the ACME directory URL of the certificate authority you have chosen. The uri directive is mandatory for every issuer, so the block fails without it. Give the issuer a name that you will reference later from the server block. Done when the configuration parses cleanly, which you can check with nginx -t before reloading.

  4. Set the challenge type for the issuer

    Within the acme_issuer block, set the challenge directive. It defaults to http-01 and also accepts tls-alpn-01. If you use http-01, the nginx-acme example configuration notes that a port 80 listener is required to answer the challenge requests, so the next step depends on this choice. Confirm which challenge your network path and firewall rules allow. Done when the challenge value is set and you have noted whether port 80 must be reachable from the certificate authority.

  5. Add a port 80 listener for challenges

    Add a server block that listens on port 80 and is reachable from the internet or from the certificate authority's validation servers, so HTTP-01 challenge requests can reach nginx. This listener is needed for HTTP-01 validation according to the module's example configuration, and it is the one place where the challenge is answered. Confirm that the port is open at your firewall and load balancer. Done when a test request to port 80 on the server's public name reaches nginx.

  6. Request the certificate in the server block

    In the server block for the site, add acme_certificate and point it at the issuer you defined. The identifiers come from server_name by default, so the names in server_name are the names the certificate will cover. Regular expressions and wildcards in server_name are not valid identifiers here, so use explicit hostnames. The directive defaults to an ecdsa:256 key. Done when nginx -t passes and the server block references the issuer by name.

  7. Set state storage and the shared zone

    Set state_path so the account key, issued certificates and private keys are kept on disk, because generated account keys are otherwise lost on restart. Protect this directory, since it holds private keys and must be restricted to the nginx user and administrators. Size the acme_shared_zone directive for your number of certificates: its default of ngx_acme_shared:256k holds about 50 ECDSA P-256 keys or 35 RSA-2048 keys, so larger deployments need a bigger zone. Done when state_path points to a protected directory and the zone size matches your certificate count.

  8. Reload nginx and confirm the certificate

    Optionally, request a certificate profile with the profile directive, which the module added in version 0.3.0. Adding the require parameter makes renewals fail if the server does not support the profile, so use it only if you need that guarantee. Then run nginx -s reload. nginx checks the syntax, applies the new configuration and rolls back to the old one if applying fails. Finally, connect to the site over TLS and confirm that the served certificate has the expected names and issuer. Done when the handshake shows the new certificate and the old workers have drained.

What must be in place before nginx can renew its own certificates

nginx can obtain and renew certificates itself only when the module, the NGINX version, the network path and the storage are all ready. Check each requirement below before you write the acme_issuer and acme_certificate directives, because a gap in any one of them stops renewal silently.

Module package and edition

Automatic certificate management comes from the ngx_http_acme_module. It ships as the open-source nginx-module-acme package. From NGINX 1.29.0 it is also offered as nginx-plus-module-acme, which requires a commercial subscription. Confirm which package your build pulls in and that the module loads before you rely on it. Check your installed version against the release notes for the package you use.

Module docs

NGINX version floor

The nginx-acme project states a build requirement of NGINX sources 1.22.0 or later. Confirm your nginx version meets that floor before you build or install the module. Treat this as the minimum the project documents, and verify compatibility for the exact version and build you run.

nginx-acme README

Port 80 reachability for validation

The default http-01 challenge requires a port 80 listener, and the module's example configuration says so explicitly. The certificate authority must reach that listener from the public internet. Confirm that firewalls, security groups and load balancers forward port 80 to this host. If you use the alternative tls-alpn-01 challenge, confirm that port 443 is reachable instead and that the challenge is configured in acme_issuer.

Module docs

DNS pointing at the host

Each name in server_name must resolve to this host before validation can succeed. Check the A or AAAA records for every identifier, including any alternate names, and confirm they point at the address the certificate authority will reach. Stale records or a name pointing at an old load balancer will fail validation even when the module is configured correctly.

State directory write access

The module keeps the account key, issued certificates and private keys in the directory set by state_path. Without state_path, generated account keys are lost on restart. Give the nginx worker account write access to this directory, and restrict everyone else, because the directory holds private keys. Confirm the permissions after the first issuance, not only before it.

Module docs

server_name naming rules

acme_certificate takes its identifiers from server_name by default. Regular expressions and wildcards in server_name are not valid identifiers and are not supported. List each hostname explicitly in server_name, and confirm that no block relies on a wildcard or regex for a name that needs a certificate. Mismatched names cause issuance to fail for that server block.

Module docs

The issuance and renewal flow between nginx and the certificate authority

The flow starts in the nginx master process, where ngx_http_acme_module reads the acme_issuer directory URL set with uri and requests an order from the certificate authority. The CA validates the domain through HTTP-01 on port 80, which is why a port 80 listener must stay open, then issues the certificate. The module stores the account key, certificate and private key in the state_path, and the acme_certificate variables feed ssl_certificate and ssl_certificate_key. A reload then applies the new certificate, and old workers shut down gracefully after serving their clients. Check that the state directory is protected and that the reload succeeds.

The nginx to certificate authority issuance and renewal path.

What goes wrong with nginx renewals and how to notice it

Most nginx renewal failures show up at the validation step, the storage step or the reload step, and each leaves a different trace. Knowing where each failure surfaces lets operations teams set up monitoring before a shorter certificate lifetime makes a missed renewal visible to users.

HTTP-01 validation blocked on port 80

The default challenge is http-01, and the nginx example configuration notes that a port 80 listener is required to process those challenges. If port 80 is closed by a firewall, missing from the server block, or redirected away before the ACME challenge path is handled, the order fails at validation. Check the module's error output for the failed challenge, then confirm from outside the network that port 80 answers on the names in server_name. If you cannot open port 80, confirm in the module documentation whether tls-alpn-01 suits your environment.

nginx ACME module docs

Shared zone exhausted on large deployments

The acme_shared_zone directive defaults to ngx_acme_shared:256k, which holds about 50 ECDSA P-256 keys or 35 RSA-2048 keys. A deployment with more certificates than that can run out of room, so new issuances or renewals stop working for the sites that did not fit. Count your server blocks that use acme_certificate, then size the zone above that count. Watch the module's error log for storage messages after adding sites, since the failure appears only when the zone is full.

Account keys lost after restart

Generated account keys survive a reload but are lost on restart unless state_path is set. When the account key disappears, the server registers a new ACME account on the next run, which is harder to track and can mean certificates tied to the old account are no longer managed. The state directory also holds issued certificates and private keys, so protect it with restrictive file permissions. Confirm that state_path is set in your configuration and that the directory persists across restarts and host rebuilds.

Required profile the server does not offer

The profile directive requests a named ACME certificate profile, and adding require makes renewals fail when the server does not support that profile. This is useful for pinning a lifetime, but it turns a server-side change into a hard renewal failure. Compare the profile name in your configuration against what your certificate authority publishes, and check the module's error output after a renewal attempt to see whether the profile was refused. Remove require only after confirming a fallback is acceptable to your policy.

Reload fails syntax check and rolls back

A reload sends HUP to the master process, which checks syntax and tries to apply the new configuration. If applying fails, nginx rolls back to the old configuration, so the server keeps running on the previous certificate while the new one sits unused. Run nginx -t before reloading, and check the error log after each renewal to confirm the new certificate actually took effect. A rolled-back reload looks like success from the renewal side, so verify the served certificate's expiry date from outside the server.

nginx control docs

Renewals blocked by DNS or firewall changes

A DNS change that moves a name off the server, or a firewall rule update that closes the challenge path, can stop renewals without any change to nginx itself. The failure appears only at the next renewal, which may be weeks after the change, so it is easy to miss. Keep a record of DNS and firewall changes that affect the names in acme_certificate, and test renewal in a staging environment after each one. Alerting on certificate expiry, as Let's Encrypt recommends, catches these failures before users do.

Future classic lifetime
45 days
Let's Encrypt 45-day post

How to confirm nginx renewals keep happening

Once nginx renews its certificates automatically, the question for operations teams becomes whether renewals keep happening after the first success. Let's Encrypt recommends setting up monitoring that alerts you when certificates are not renewed when expected, and it does not recommend manual renewal, because shorter lifetimes would require manual work more often. The starting point is to decide who receives that alert, what threshold triggers it, and which system owns the check. Under the 47-day schedule set by the CA/Browser Forum from 15 March 2029, a missed renewal leaves much less time to notice, so the alert has to fire well before expiry. Let's Encrypt's current guidance is that renewing about two thirds of the way through the lifetime is acceptable, and clients without ARI support should use a schedule that works with 45-day certificates rather than a hardcoded 60-day interval. Confirm which of these your client uses before you set the alert threshold.

Monitoring should check the certificate nginx actually serves, not only the files on disk. From a machine outside the nginx host, connect to the public endpoint, read the served certificate, and compare its expiry date against your alert threshold. Running this check from outside the host catches cases where the file was renewed but the workers never picked up the new certificate, which is the failure a host-local check would miss. Next, review nginx error logs after each reload. Per nginx's control documentation, a HUP signal makes the master process check syntax, apply the new configuration, and roll back if applying fails, so a failed reload may leave the old configuration running without an obvious outage. Search the error log after each scheduled renewal for reload or certificate errors, and confirm the served certificate changed. Also confirm which ssl_certificate_cache setting applies to your configuration, since the sources note that certificates specified with variables are loaded on every SSL handshake when caching is off.

Keep a dated record of every issuance and renewal for an auditor or customer review. The record should list each domain, the issuance and expiry dates, the ACME client and version used, and the reload result. If you use Certbot, its post-renewal hooks receive RENEWED_DOMAINS and FAILED_DOMAINS as space-separated lists from Certbot 2.7.0, so a hook can write those values to your log and raise an alert when FAILED_DOMAINS is non-empty. Certbot runs --deploy-hook only after a successful renewal, so pair it with a separate check that detects renewals that never happen. Store the record outside the nginx host, and protect the state directory set by state_path, since it holds account keys, certificates and private keys.

Common questions about automating nginx certificates

Does nginx support ACME natively?

Yes, through the ngx_http_acme_module, which implements automatic certificate management with ACMEv2 as defined in RFC 8555. It is available as the open-source nginx-module-acme package. Since 1.29.0 it is also offered as nginx-plus-module-acme with a commercial subscription. Let's Encrypt noted on 11 September 2025 that NGINX announced ACME support on 12 August through this module, which is implemented in Rust. Confirm the module version and package that match your nginx build before you plan the rollout.

Which ACME client should I use with nginx?

The choice depends on whether you want nginx to manage certificates itself or prefer a separate client. The native module is configured with an acme_issuer block in the http context and an acme_certificate directive in each server block. Certbot's nginx plugin is enabled with --nginx and edits your existing configuration, and the Certbot guide advises backing up the configuration first and using certbot --nginx rollback if needed. Compare how each option handles reloads, state storage and renewal hooks against your existing process. The sources listed on this page do not rank the two options.

How often will nginx certificates renew under the 47-day limit?

The 47-day maximum applies from 15 March 2029 under the CA/Browser Forum Baseline Requirements, after the 200-day limit from 15 March 2026 and the 100-day limit from 15 March 2027. Let's Encrypt plans 45-day certificates on its classic profile from 16 February 2028, with an opt-in 45-day profile from 13 May 2026. Let's Encrypt says renewing about two thirds of the way through the lifetime is acceptable, and recommends ACME Renewal Information (RFC 9773) over a fixed interval. A fixed 60-day schedule will no longer be sufficient for 45-day certificates, so check your client's renewal logic before the lifetime shortens.

What happens when an nginx certificate renewal fails?

The sources do not describe the module's full failure behavior, so confirm it in the module documentation for your version. Two points are supported. Per nginx's control documentation, a reload checks syntax and rolls back to the old configuration if the new one cannot be applied. The module also keeps account keys across reloads but loses them on restart unless state_path is set. Let's Encrypt recommends monitoring that alerts you when certificates are not renewed as expected, and does not recommend manual renewal because shorter lifetimes would require it more often. Set up that alert before relying on automation.

Do wildcard or regex server names work with acme_certificate?

No. The acme_certificate directive takes its identifiers from server_name by default, and regular expressions and wildcards in server_name are not valid identifiers for it and are not supported. Each certificate must name concrete hostnames. Review your server blocks for regex or wildcard names before migrating them to automatic issuance, and confirm how any wildcard certificate you need is issued and renewed through your certificate authority.

Where should the nginx ACME state directory be stored?

The state directory holds the account key, issued certificates and private keys, so it must be protected like any other secret store. Set state_path so the account key survives a restart, because without it the module loses generated account keys on restart. Restrict file permissions on the directory to the account that runs nginx. If you run several nginx instances, plan how the shared zone is sized: acme_shared_zone defaults to ngx_acme_shared:256k, which holds about 50 ECDSA P-256 keys or 35 RSA-2048 keys, so larger deployments need a bigger zone.

Should we get outside help to automate nginx certificates?

It depends on how many servers you run, how many teams touch them and how much of the current setup is manual. Consider outside help if the existing configuration is complex, if you have many server names to migrate, or if no one on the team has run an ACME client in production. DeployOpen plans, implements, integrates, hardens and documents self-hosted open-source platforms inside your own infrastructure, and most engagements are fixed-scope with the scope and timeline agreed in writing before work starts. Ask any provider for a written scope and a clear list of what they will and will not change on your servers.

How DeployOpen helps with nginx certificate automation

DeployOpen approaches nginx certificate renewal by first mapping every server block that terminates TLS and how each one would be issued and renewed. We then build and test the ACME configuration, the reload path and the monitoring together, so renewals keep working as lifetimes move toward 47 days. Work is documented so your web operations team can run it after handover.

How we scope

  • We inventory each nginx server block, its server_name values and whether names use wildcards or regular expressions.
  • We confirm which nginx version and ngx_http_acme_module package you run, or whether a commercial build is needed.
  • The written scope lists the server blocks, ACME issuer, state path and renewal monitoring included in the engagement.

How we build

  • We configure acme_issuer and acme_certificate per server block and set the http-01 port 80 listener the challenge requires.
  • We protect the state_path directory, which holds account keys and private keys, and size acme_shared_zone for your certificate count.
  • We test reload behavior with nginx -s reload, including the rollback path if a new configuration fails to apply.

How we hand over

  • You receive the configuration, state directory layout and access controls documented for your web operations team.
  • We document how renewal is triggered, how ARI or a fixed schedule is set, and what each alert means in practice.
  • A runbook covers manual checks, certificate inspection and the steps to take when an issuance or renewal fails.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after the fixed-scope work ends.
  • We can retest renewal and reload behavior after nginx upgrades or changes to the certificate lifetime schedule.
  • Confirm current lifetimes and profile options with your certificate authority and the nginx module documentation before go-live.

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.