Files
one-click-shell/Nginx/ssl-install/README.md
2022-03-13 14:56:33 +08:00

58 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Nginx 安装 ssl 证书
1、以腾讯云为例去 SSL 证书管理控制台https://console.cloud.tencent.com/ssl 下载并解压缩证书文件包到本地目录。
2.、解压缩后,可获得相关类型的证书文件。其中包含 Nginx 文件夹和 CSR 文件。
```
文件夹名称Nginx
文件夹内容:
1_www.domain.com_bundle.crt 证书文件
2_www.domain.com.key 私钥文件
CSR 文件内容: www.domain.com.csr 文件
```
说明CSR 文件是申请证书时由您上传或系统在线生成的,提供给 CA 机构。安装时可忽略该文件。
3、将已获取到的 1_www.domain.com_bundle.crt 证书文件和 2_www.domain.com.key 私钥文件从本地拷贝到服务器的某个目录下。
4、Nginx 配置:
```
server {
listen 443;
server_name phpedu.club www.phpedu.club;
root /usr/share/nginx/html;
index index.html index.htm index.php;
# 启用 SSL 功能
ssl on;
# 证书文件名称
ssl_certificate /etc/nginx/conf.d/ssl/1_phpedu.club_bundle.crt;
# 私钥文件名称
ssl_certificate_key /etc/nginx/conf.d/ssl/2_phpedu.club.key;
ssl_session_timeout 5m;
# 请按照这个协议配置
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# 请按照这个套件配置,配置加密套件,写法遵循 openssl 标准。
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location ~* /\. {
deny all;
}
}
server {
listen 80;
server_name phpedu.club www.phpedu.club;
# 把 http 的域名请求转成 https
rewrite ^(.*)$ https://$host$1 permanent;
}
```
5、重启Nginx。
### 参考
- [https://cloud.tencent.com/document/product/400/35244](https://cloud.tencent.com/document/product/400/35244)