Confluence Wiki SSL证书更换教程

记录一次 Wiki SSL 证书过期后的更换流程,包括定位证书文件、备份、上传新证书、验证配置和重载 Nginx 的完整步骤。

...

背景

浏览网站时看到浏览器提示证书即将过期,检查后发现这是 SSL 证书,域名是 *.crashmemo.info,到期时间是 2026 年 2 月 9 日,赶紧更换一下。改吧

证书过期提示截图

定位证书文件

搜索一下证书文件 pem 和 key 放在哪里,搜索得出都放在 /etc/nginx/conf.d/ssl/

1
2
3
4
5
[root@testwiki ~]# find / -name *.crashmemo.info.info.pem
/etc/nginx/conf.d/ssl/*.crashmemo.info.info.pem
[root@testwiki ~]# find / -name *.crashmemo.info.info.key
find: '/proc/19731': No such file or directory
/etc/nginx/conf.d/ssl/*.crashmemo.info.info.key

备份旧证书

进入 cd /etc/nginx/conf.d/ssl/,把原来的 pem 和 key 文件都备份一下

1
2
3
4
5
6
[root@testwiki ssl]# ll
total 24
-rw-r--r-- 1 root root 1675 Feb  9 11:27 *.crashmemo.info.info.key
-rw-r--r-- 1 root root 1679 Feb  9 11:20 *.crashmemo.info.info.key.back
-rw-r--r-- 1 root root 5519 Feb  9 11:26 *.crashmemo.info.info.pem
-rw-r--r-- 1 root root 5510 Feb  9 11:20 *.crashmemo.info.info.pem.back

上传新证书

用 rz 命令上传证书文件到 /etc/nginx/conf.d/ssl/,这里我直接用 MobaXterm 的窗口上传。

MobaXterm 上传证书界面截图

验证配置

nginx -t 执行语法检查,显示 syntax is ok 和 test is successful,说明配置没问题。

1
2
3
[root@testwiki ssl]# nginx -t
nginx: the configuration file /etc/nginx/conf.d/ssl/test is successful
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

重载 Nginx

执行 nginx -s reload,进行平滑重载

Restart vs Reload:

  • Restart(重启):先把 Nginx 关掉,再打开。如果新配置错了,Nginx 就再也起不来了,网站瞬间瘫痪。
  • Reload(重载)
    1. 它会先在后台偷偷检查一遍配置。
    2. 如果配置是对的,它会启动新的进程处理请求,然后慢慢关掉旧进程。
    3. 如果配置是错的:它会直接报错并放弃更新,继续用旧的配置运行。
1
[root@testwiki ssl]# nginx -s reload

可以在网页上看到证书已经更新成功了

证书更新成功截图

Created by aka.g