首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NGINX HTTPS - SSL证书

NGINX HTTPS - SSL证书
EN

Stack Overflow用户
提问于 2021-07-15 10:39:47
回答 1查看 292关注 0票数 0

我有三个关于证书的文件:

代码语言:javascript
复制
- example.com.ca-bundle # contains root and intermediate certificates
- example.com.crt # Certificate
- example.com.p7b # only contains certificates and chain certificates

我需要配置NGINX来接受HTTPS,但我感到有点困惑,因为我对SSL没有最丰富的经验,而且大多数示例似乎都使用了证书/密钥对。这种NGINX配置是否是正确的方法?

代码语言:javascript
复制
server {
    listen              443 ssl;
    server_name         www.example.com;
    ssl_certificate     /path/to/example.com.crt;
    ssl_certificate_key /path/to/example.com.crt;
    ...
}
EN

回答 1

Stack Overflow用户

发布于 2022-01-13 21:43:52

正如其他人在注释中指出的那样,您需要为ssl_certificate_key使用私钥。如果有进一步的帮助,下面是使用SSL证书加密Nginx配置的摘录。在某些情况下,cert.pem是不够的,而且为了跨更多的浏览器和服务器类型进行兼容性,还需要chain.pem。

代码语言:javascript
复制
    # Full chain fullchain.pem is just a concatenation of public key cert.pem and chain.pem. If you are using certbot this will be automatically created.
    ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
 
    # Like others pointed out in the comments there should be a private key and not the cert file
    ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;

您可以使用certbot (让我们加密的一个工具)来自动生成证书。下面是与自动为Nginx托管网站安装HTTPS / SSL证书的一步一步的说明的链接

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68392301

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档