当前位置: 首页 > wzjs >正文

怎么用群晖nas做网站院校建设网站群的原因

怎么用群晖nas做网站,院校建设网站群的原因,html5制作网站谁的好,网站设计方案报价在 CentOS 8 上配置 SSL 证书并自动续期,使用 Let’s Encrypt 的免费证书和 Certbot 工具。 Certbot 是 Let’s Encrypt 官方推荐的客户端工具,其默认行为是向 Let’s Encrypt 的 ACME 服务器申请证书,无需手动指定 CA。Let’s Encrypt 证书有…

在 CentOS 8 上配置 SSL 证书并自动续期,使用 Let’s Encrypt 的免费证书和 Certbot 工具。
Certbot 是 Let’s Encrypt 官方推荐的客户端工具,其默认行为是向 Let’s Encrypt 的 ACME 服务器申请证书,无需手动指定 CA。Let’s Encrypt 证书有效期为 90 天。

一、准备工作

1. 安装必要工具

sudo dnf install epel-release -y
sudo dnf install certbot python3-certbot-nginx -y  # 如果使用 Nginx

2. 确保防火墙开放 HTTP/HTTPS

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

二、生成 SSL 证书

方式 1:自动配置(推荐)
sudo certbot --nginx   # 使用 Nginx
  • 按提示输入域名和邮箱,Certbot 会自动完成证书申请和 Web 服务器配置
  • 注意:若 Nginx 是离线编译安装的(路径为 /usr/local/nginx),需通过以下方式指定路径:
方法 1:通过 Certbot 配置文件指定路径(推荐)
sudo vim /etc/letsencrypt/cli.ini

添加内容:

# 指定 Nginx 二进制路径和配置目录
nginx-ctl = /usr/local/nginx/sbin/nginx
nginx-server-root = /usr/local/nginx/conf

重新运行 Certbot:

sudo certbot --nginx
方法 2:使用符号链接统一路径
sudo ln -s /usr/local/nginx/conf /etc/nginx
sudo ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
sudo certbot --nginx --dry-run  # 验证
方法 3:使用命令参数指定
sudo certbot --nginx \--nginx-ctl /usr/local/nginx/sbin/nginx \--nginx-server-root /usr/local/nginx/conf

方式 2:手动配置(适合自定义需求)

sudo certbot certonly --standalone -d example.com -d www.example.com

证书保存路径:/etc/letsencrypt/live/example.com/


三、配置 Web 服务器

自动配置(推荐)

sudo certbot --nginx

手动配置示例

server {listen 443 ssl;server_name example.com www.example.com;ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;ssl_protocols TLSv1.2 TLSv1.3;ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;ssl_prefer_server_ciphers on;
}server {listen 80;server_name example.com www.example.com;return 301 https://$host$request_uri;  # 强制 HTTPS 重定向
}

重启 Nginx:

sudo nginx -t        # 测试配置
sudo nginx -s reload

四、配置自动续期

1. 手动测试续期

sudo certbot renew --dry-run

成功输出:Congratulations, all renewals succeeded

2. 添加定时任务

echo "0 0,12 * * * root /usr/bin/certbot renew --quiet" | sudo tee -a /etc/cron.d/certbot

3. 续期后自动重启 Web 服务器

创建续期钩子脚本:

sudo mkdir -p /etc/letsencrypt/renewal-hooks/deploy
sudo vi /etc/letsencrypt/renewal-hooks/deploy/restart-nginx.sh

脚本内容:

#!/bin/bash
/usr/local/nginx/sbin/nginx -t && /usr/local/nginx/sbin/nginx -s reload

赋予权限:

sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/restart-nginx.sh

五、验证与维护

1. 检查证书状态

sudo certbot certificates

2. 查看自动续期日志

journalctl -u certbot.service

3. 定期检查

  • 确保域名解析正确
  • 避免修改 /etc/letsencrypt/ 目录权限
  • 更新 Certbot 和 Web 服务器软件

附录

certbot renew --dry-run 命令详解

命令作用
sudo certbot renew --dry-run
  • 核心功能:模拟 SSL 证书自动续期流程(不实际颁发新证书)
  • 核心价值:提前发现配置错误、网络问题或权限故障,规避证书过期风险
  • 注意事项
    • 不会延长证书有效期
    • 实际续期需等待证书到期前 30 天自动触发
    • 同一域名每小时最多执行 5 次(避免触发 Let’s Encrypt 速率限制)

输出结果解析
成功场景
----------------------------------------
Congratulations, all simulated renewals succeeded: /etc/letsencrypt/live/example.com/fullchain.pem (success)
----------------------------------------
  • 解读:所有证书模拟续期测试通过,实际续期成功率 >95%
失败场景
----------------------------------------
The following errors were reported by the server:Domain: example.comType:   connectionDetail: Fetching http://example.com/.well-known/acme-challenge/xxx:Timeout during connect (likely firewall problem)
----------------------------------------

echo "0 0,12 * * * root /usr/bin/certbot renew --quiet" | sudo tee -a /etc/cron.d/certbot 命令详解

1. 时间规则拆解
0 0,12 * * *
字段含义
分钟0整点执行
小时0,12UTC 时间 0 点和 12 点
日/月/周*每天/每月/每周生效
2. 命令执行逻辑
组件技术说明
root以 root 权限运行(访问证书文件需特权)
/usr/bin/certbot renew续期所有到期前 30 天内的证书
--quiet静默模式(抑制非关键日志输出)
3. 配置文件写入
| sudo tee -a /etc/cron.d/certbot
  • 管道符 |:传递 echo 命令的输出流
  • tee -a:追加写入系统级 Cron 配置
  • 文件权限/etc/cron.d/ 目录需 root 权限

renewal和renewal-hooks目录作用

目录功能对比
目录核心作用典型文件
/etc/letsencrypt/renewal存储证书续订元数据(域名/有效期/验证方式)example.com.conf
/etc/letsencrypt/renewal-hooks管理续订生命周期钩子脚本post/restart-nginx.sh
1. renewal 目录实例
# example.com.conf
renew_before_expiry = 30 days    # 到期前30天触发续订
preferred_chain = ISRG Root X1   # 优先使用ISRG根证书链
authenticator = nginx            # 使用Nginx插件验证
account = xxxxxxxxxxxxxxx        # Let's Encrypt账户ID
2. renewal-hooks 工作流程
/etc/letsencrypt/renewal-hooks/
├── pre/    # 续订前操作(示例:暂停负载均衡)
├── post/   # 续订后操作(示例:重启服务)
└── deploy/ # 证书部署操作(示例:同步到CDN)
钩子脚本示例

post/restart-nginx.sh

#!/bin/sh
# 安全重启Nginx服务
/usr/local/nginx/sbin/nginx -t && \
/usr/local/nginx/sbin/nginx -s reload

权限配置:

sudo chmod +x /etc/letsencrypt/renewal-hooks/post/restart-nginx.sh

文章转载自:

http://jinF042A.rLpmy.cn
http://kvn1viC4.rLpmy.cn
http://k7U0hCxT.rLpmy.cn
http://8Plw9DPh.rLpmy.cn
http://ggHMTGGa.rLpmy.cn
http://gVRA8x89.rLpmy.cn
http://YV8w3SP1.rLpmy.cn
http://ljgPyHPP.rLpmy.cn
http://1biW4hES.rLpmy.cn
http://eOZCrEB6.rLpmy.cn
http://Vk5ITsXS.rLpmy.cn
http://oqYXL1Vw.rLpmy.cn
http://SBzUgQZv.rLpmy.cn
http://t5nNjOre.rLpmy.cn
http://sjB6CDiX.rLpmy.cn
http://mhClJLOE.rLpmy.cn
http://VZ1HqBaq.rLpmy.cn
http://C8FKhKwg.rLpmy.cn
http://jPtH38Ck.rLpmy.cn
http://YmVkk2sK.rLpmy.cn
http://aWWc2zkD.rLpmy.cn
http://l4SVyN9q.rLpmy.cn
http://oBd363zj.rLpmy.cn
http://FvIfbWXM.rLpmy.cn
http://Upg4YWFr.rLpmy.cn
http://UucZLp6R.rLpmy.cn
http://aCvJATVs.rLpmy.cn
http://y58kkcbo.rLpmy.cn
http://eUFfHr9B.rLpmy.cn
http://mDcDioY7.rLpmy.cn
http://www.dtcms.com/wzjs/679284.html

相关文章:

  • 一般网站开发语言wordpress搜索引擎主题
  • 重庆推广网站排名价格2023新闻大事件摘抄
  • 门业网站模板下载昆山网站建设苦瓜网络
  • 滨州哪里有做网站的有什么平台可以推广
  • 鞍山人才网官网湘潭seo公司
  • 网站建设费是业务宣传费吗聊城手机网站建设软件
  • 网站开发合同范本大全东莞网站建设-信科网络
  • 中国最大网站建设商推荐知乎家电网站设计方案
  • 湖南省长沙建设厅网站wordpress ssh
  • 重庆英文网站建设专门做网站推广的平台
  • 唐山免费自助建站模板静态展示网站模板下载
  • 网站报价方案怎么做推广app的妙招
  • 做产品展示网站100平米全包装修价格
  • 网站建设三方协议临沂网站关键词
  • 响应式网站建设的好处centos 6.8 wordpress
  • 广州企业网站制作学而思的网站哪里做的
  • 网站公司谁家好天元建设集团有限公司路桥工程公司
  • 百度糯米做网站多少钱php网站模板使用
  • 金华网站如何制作网站收录提交入口怎么做
  • 网站常用后台路径互联网技术与应用
  • 什么是网络营销取得成功的基础珠海做网站优化的公司
  • 建站优化是什么iis搭建多个网站
  • 阿里巴巴网站导航栏怎么做信阳一地最新通告
  • 转运公司网站制作大连网站建设学校
  • 网站建设语最好用的虚拟主机WordPress
  • 怎么做原创短视频网站桂林市自来水公司网站
  • 网站建设一条龙包括哪些服务怎样学设计快速入门
  • 外国语学校网站建设方案pathon做网站
  • 怎么认证网站网站你懂我意思正能量晚上在线下载免费软件魅族
  • seo网站建设为爱直播视频