Nginx 配置 https 出现no "ssl_certificate" is defined问题原因及解决方法

配置Nginx https时遇到错误提示缺少ssl_certificate定义。原因是ssl_certificate需要在http段预先配置,而不仅限于server段。检查并确保在nginx.conf的http段添加ssl_certificate配置后,问题得以解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、问题

今天在配置nginx的https发现报错:

2019/01/21 11:21:15 [error] 11593#0: *204154 no "ssl_certificate" is defined in server listening on SSL port while SSL handshaking, client: 175.9.181.35, server: 0.0.0.0:443
2019/01/21 11:21:15 [error] 11593#0: *204155 no "ssl_certificate" is defined in server listening on SSL port while SSL handshaking, client: 175.9.181.35, server: 0.0.0.0:443
2019/01/21 11:21:15 [error] 11593#0: *204156 no "ssl_certificate" is defined in server listening on SSL port while SSL handshaking, client: 175.9.181.35, server: 0.0.0.0:443

意思是ssl_certificate没有配置,可是ssl_certificate和ssl_certificate_key都已经配置,网上搜索ssl_certificate必须在http段中先定义, 在server段才配置ssl_certificate已经来不及了, 检查我的nginx配置,ssl_certificate确实只在server段定义,而在http段未定义,加到http段即可。

二、解决方案

nginx的配置文件中nginx.conf中加入

http {
  ssl_certificate  xxx.pem;
  ssl_certificate_key xx.key;
}

欢迎扫描下方二维码,持续关注:

互联网工程师(id:phpstcn),我们一起学习,一起进步

转载于:https://my.oschina.net/xushuhui/blog/3004019

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值