[英]NGINX HTTPS - SSL Certificates
我有三个关于证书的文件:
- 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 配置是正确的方法吗?
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate /path/to/example.com.crt;
ssl_certificate_key /path/to/example.com.crt;
...
}
就像其他人在评论中指出的那样,您需要使用 ssl_certificate_key 的私钥。 如果它有进一步的帮助,下面是使用 Let's Encrypt SSL 证书的 Nginx 配置的摘录。 在某些情况下 cert.pem 是不够的,还需要 chain.pem 以实现跨更多浏览器和服务器类型的兼容性。
# 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(Let's Encrypt 的工具)自动生成证书。 这是为您的 Nginx 托管网站自动设置 HTTPS / SSL 证书的分步说明的链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.