posts: 更换SSL证书的方法
All checks were successful
Gitea Actions Demo / build-and-deploy-to-local-server (push) Successful in 3m47s
Gitea Actions Demo / deploy-to-remote-server (push) Successful in 3s

This commit is contained in:
2025-06-12 21:37:12 +08:00
parent 5c3c437cff
commit a7012934e0
8 changed files with 79 additions and 23 deletions

View File

@ -1,5 +0,0 @@
---
date: '2025-05-27T21:09:30+08:00'
draft: true
title: 'Fifth'
---

View File

@ -1,5 +0,0 @@
---
date: '2025-05-27T21:09:24+08:00'
draft: true
title: 'Forth'
---

View File

@ -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

View File

@ -0,0 +1,76 @@
---
date: '2025-06-12T20:32:04+08:00'
draft: false
title: '更换SSL证书的方法'
---
## 背景说明
- 网站通过NGINX代理
- NGINX通过Docker部署
- 域名通过阿里云购入
- SSL证书通过阿里云申请
## 更换方法
基于上面的背景更换SSL证书共分为四步
1. 申请新的SSL证书
![alt text](image.png)
点击```创建证书```,在弹出的页面中,输入```域名名称```,然后点击```提交审核```。等待大概10分钟就会通过审核并完成证书签发这个过程无需做任何操作因为域名和SSL证书都是通过阿里云所以会自动添加记录值和验证。
2. 下载证书
![alt text](image-1.png)
服务器类型为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;
}
}
```

View File

@ -1,5 +0,0 @@
---
date: '2025-05-27T21:09:19+08:00'
draft: true
title: 'Third'
---

View File

@ -1,6 +1,6 @@
baseURL: http://1970666.xyz/ baseURL: https://1970666.xyz/
languageCode: zh-cn languageCode: zh-cn
title: 魔芋土豆 title: 技术文章
theme: ["PaperMod"] theme: ["PaperMod"]
menu: menu:
@ -25,7 +25,7 @@ params:
profileMode: profileMode:
enabled: true enabled: true
title: " " title: " "
subtitle: A在川渝的街头巷尾,有一种朴素又迷人的食物,它没有山珍海味的贵气,也没有异国料理的新奇,却总能在寒冷的冬日里,或是疲惫的午后,悄悄地温暖一个人的胃,也安抚一颗心。 subtitle: 在川渝的街头巷尾,有一种朴素又迷人的食物,它没有山珍海味的贵气,也没有异国料理的新奇,却总能在寒冷的冬日里,或是疲惫的午后,悄悄地温暖一个人的胃,也安抚一颗心。
imageUrl: "/images/website_icon.png" imageUrl: "/images/website_icon.png"
imageTitle: icon imageTitle: icon
imageWidth: 300 imageWidth: 300