OCSP Stapling in NGINX: Configuration, Testing and Troubleshooting
OCSP stapling is a modern TLS optimization technique that boosts SSL certificate validation performance and security. When configured properly in NGINX, it allows your server to provide clients with proof of certificate validity directly, reducing browser delays and protecting user privacy. This blog explains how to secure your NGINX server by implementing OCSP stapling, with steps for configuration, best practices, and common troubleshooting tips.
Quick answer: OCSP stapling lets NGINX fetch a signed certificate status from the CA and send it during the TLS handshake, so browsers need not query the CA. Enable it with ssl_stapling on, ssl_stapling_verify on, a resolver and an ssl_trusted_certificate chain, then test with openssl s_client -status. Check that your CA still runs OCSP, because some have stopped.
Key takeaways
- Stapling needs four things in NGINX: ssl_stapling, ssl_stapling_verify, a resolver and a trusted certificate chain file.
- The most common failure is a missing resolver, which leaves stapling silently off, with a warning in the error log.
- NGINX fetches the OCSP response lazily, so the first test connection may show no response. Test a few times.
- Verify with openssl s_client -connect host:443 -status, not just by reading the config.
- Let's Encrypt ended its OCSP service in 2025, so certificates from it cannot be stapled any more. Check your CA before you spend time on this.
What is OCSP stapling?
OCSP (Online Certificate Status Protocol) lets a browser ask a certificate authority (CA) whether a certificate has been revoked. Without stapling, every visitor's browser makes that request, which adds delay and tells the CA which sites the visitor is opening. With stapling, your web server asks the CA's OCSP responder itself, caches the signed answer for a limited time and attaches it to the TLS handshake. The browser can check the CA's signature on the answer without contacting the CA. The protocol is defined in RFC 6960 and the stapling extension in RFC 6066.
Should you still use it? Check your CA first
Before changing any config, confirm that your certificate has an OCSP responder URL. Run openssl x509 -in cert.pem -noout -ocsp_uri. If nothing is printed, there is nothing to staple. Let's Encrypt announced the end of its OCSP support and moved to certificate revocation lists, and stopped issuing certificates with OCSP URLs during 2025. If you use Let's Encrypt, NGINX stapling will not work for new certificates. Read the Let's Encrypt documentation for the current position. Commercial CAs generally still provide OCSP, but browser and CA industry rules are moving towards optional OCSP, so treat this as a configuration to verify, not a permanent feature.
What is the minimum working NGINX configuration?
Put the following in the HTTPS server block (or the http block for all sites). Paths are examples.
ssl_certificate /etc/nginx/ssl/fullchain.pem; # server cert + intermediates
ssl_certificate_key /etc/nginx/ssl/example.com.key;
ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/nginx/ssl/chain.pem; # intermediates + root, to verify the response
resolver 1.1.1.1 9.9.9.9 valid=300s;
resolver_timeout 5s;
- fullchain.pem must contain your certificate first, then the intermediate certificates. Build it with
cat example.com.crt intermediate.crt > fullchain.pem. - ssl_trusted_certificate is used to verify the OCSP response when
ssl_stapling_verifyis on. It should contain the issuing chain up to a trusted root. - resolver is required because NGINX has to resolve the hostname of the OCSP responder at runtime. Use a resolver your server can reach, preferably your own internal one, rather than a random public address.
Test and reload without dropping connections:
sudo nginx -t
sudo systemctl reload nginx
The directives are documented in the NGINX SSL module reference.
How do you verify that stapling works?
echo | openssl s_client -connect example.com:443 -servername example.com -status 2>/dev/null | grep -A 8 "OCSP response"
Look for OCSP Response Status: successful and Cert Status: good, with This Update and Next Update times. If you see OCSP response: no response sent, wait a few seconds and run it again. NGINX fetches the response when the first client asks, so the first handshake after a reload often has none. Also check the error log with sudo tail -f /var/log/nginx/error.log while you test.
Which errors appear, and what do they mean?
| Symptom or log message | Likely cause | Fix |
|---|---|---|
no resolver defined to resolve ocsp... | No resolver directive, so NGINX cannot look up the responder | Add resolver and make sure the server can reach DNS |
"ssl_stapling" ignored, no OCSP responder URL in the certificate | Certificate has no OCSP URL, for example from a CA that stopped OCSP | Check with openssl x509 -noout -ocsp_uri. Use a certificate that includes one, or turn stapling off |
"ssl_stapling" ignored, issuer certificate not found | Chain file is incomplete | Provide the issuer in ssl_certificate or ssl_trusted_certificate |
OCSP_basic_verify() failed | Trusted chain does not verify the response | Replace ssl_trusted_certificate with the correct intermediates and root |
no response sent on first test | Response not fetched yet | Repeat the test after one request |
| Firewall blocks the responder | Outbound HTTP to the CA is closed | Allow outbound access to the OCSP URL from the web server |
The exact wording of NGINX log lines can vary by version, so search your own error log for the word "ssl_stapling" or "OCSP".
What other things should you watch?
- Renewal hooks. After certificates are renewed, reload NGINX so it loads the new files. With Certbot, a deploy hook that runs
systemctl reload nginxdoes this. - Multiple virtual hosts. Each host needs its own matching chain, and the settings apply per server block or per listening socket in older versions. Test each name.
- Must-Staple. If a certificate carries the OCSP Must-Staple flag, a failed staple can make the site unreachable in some browsers. Only use it when monitoring is in place.
- Monitoring. Alert if the stapled response is missing or close to expiry. A simple scheduled
openssl s_client -statuscheck is enough to begin.
Security note: stapling improves privacy and reliability of revocation checking. It does not replace sound TLS settings, patching or key protection. See how an SSL/TLS certificate works and how SSL/TLS works for the wider picture. Only test servers you own or are authorised to administer.
Next steps
To learn server hardening and web security hands-on, see WebAsha's Linux training and the cyber security course.
Related reading
Frequently Asked Questions
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0