解决 Nginx 报错 ssl_stapling ignored no responder URL in certificate
分析 Nginx 开启 ssl_stapling 时证书缺少 OCSP 地址报 ignored no responder URL 根因,提供自签名证书与自建证书排查方案。
问题现象
在执行 nginx -t 测试配置文件或启动 Nginx 时,终端输出如下警告:
nginx: [warn] "ssl_stapling" ignored, no responder URL in the certificate "/etc/nginx/ssl/server.crt"
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
触发根因
OCSP Stapling 是将证书吊销状态预先缓存在 Web 服务器的技术:
- 当前使用的是自签名证书(Self-Signed Certificate)或内部私有 CA 签发的证书:这类证书内部没有包含公网可访问的
Authority Information Access (AIA)扩展字段,即缺少OCSP - URI字段。 - Nginx 检测到证书本身无法从权威 CA 查询 OCSP 状态,因此自动忽略
ssl_stapling指令并打印告警。
诊断排查步骤
- 使用 openssl 检查证书中是否包含 OCSP Responder URL:
openssl x509 -in /etc/nginx/ssl/server.crt -noout -ocsp_uri
如果输出为空,证明证书本身不支持 OCSP Stapling。
解决步骤与操作命令
方案 A:针对自签名或私有证书关闭 ssl_stapling(最规范)
自签名证书无需且无法使用公网 OCSP,直接在配置中关闭该指令:
server {
listen 443 ssl;
server_name example.local;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
# 关闭私有证书的 OCSP 检查
ssl_stapling off;
ssl_stapling_verify off;
}
方案 B:针对公网正式证书补齐中间证书与 DNS 解析器
如果是商业证书(如 Let's Encrypt / DigiCert),确保配置了完整的全链证书并指定本地 DNS 解析器:
ssl_certificate /etc/nginx/ssl/fullchain.pem; # 必须使用包含中间CA的全链
ssl_stapling on;
ssl_stapling_verify on;
resolver 223.5.5.5 114.114.114.114 valid=300s;
resolver_timeout 5s;
步骤三:验证配置
重新执行 nginx -t:
sudo nginx -t
警告完全消失,语法校验干净通过。


