posts: 更换SSL证书的方法
This commit is contained in:
@ -1,5 +0,0 @@
|
||||
---
|
||||
date: '2025-05-27T21:09:30+08:00'
|
||||
draft: true
|
||||
title: 'Fifth'
|
||||
---
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
date: '2025-05-27T21:09:24+08:00'
|
||||
draft: true
|
||||
title: 'Forth'
|
||||
---
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
date: '2025-05-27T21:09:13+08:00'
|
||||
draft: true
|
||||
title: 'Second'
|
||||
---
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 87 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 112 KiB |
@ -0,0 +1,76 @@
|
||||
---
|
||||
date: '2025-06-12T20:32:04+08:00'
|
||||
draft: false
|
||||
title: '更换SSL证书的方法'
|
||||
---
|
||||
|
||||
## 背景说明
|
||||
|
||||
- 网站通过NGINX代理
|
||||
- NGINX通过Docker部署
|
||||
- 域名通过阿里云购入
|
||||
- SSL证书通过阿里云申请
|
||||
|
||||
## 更换方法
|
||||
|
||||
基于上面的背景,更换SSL证书共分为四步:
|
||||
|
||||
1. 申请新的SSL证书
|
||||
|
||||

|
||||
|
||||
点击```创建证书```,在弹出的页面中,输入```域名名称```,然后点击```提交审核```。等待大概10分钟,就会通过审核并完成证书签发,这个过程无需做任何操作,因为域名和SSL证书都是通过阿里云,所以会自动添加记录值和验证。
|
||||
|
||||
2. 下载证书
|
||||
|
||||

|
||||
|
||||
服务器类型为Nginx,点击下载。解压之后,可以得到```.key```和```.pem```文件。
|
||||
|
||||
3. 配置新的SSL证书
|
||||
|
||||
把```.key```和```.pem```文件放在```cert/```目录下(替换原来的证书文件)。
|
||||
|
||||
4. 重启NGINX服务
|
||||
|
||||
```bash
|
||||
docker restart nginx
|
||||
```
|
||||
|
||||
至此,SSL证书更换完成。
|
||||
|
||||
## 后记
|
||||
|
||||
如果是首次配置SSL证书,还需要在nginx的配置文件中添加如下内容:
|
||||
|
||||
```nginx
|
||||
server
|
||||
{
|
||||
listen 443 ssl;
|
||||
server_name [your domain name];
|
||||
|
||||
ssl_certificate cert/1970666.xyz.pem;
|
||||
ssl_certificate_key cert/1970666.xyz.key;
|
||||
|
||||
ssl_session_cache shared:SSL:1m;
|
||||
ssl_session_timeout 5m;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html/blog;
|
||||
index index.html;
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
access_log /logs/blog.log;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name [your domain name];
|
||||
|
||||
rewrite ^(.*)$ https://$host$1;
|
||||
location / {
|
||||
index index.html index.htm;
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
date: '2025-05-27T21:09:19+08:00'
|
||||
draft: true
|
||||
title: 'Third'
|
||||
---
|
||||
Reference in New Issue
Block a user