Certbot 安裝 ssl 證書

下載 certbot-auto 自動安裝腳本

curl -o /usr/sbin/certbot-auto https://dl.eff.org/certbot-auto
chmod 0755 /usr/sbin/certbot-auto

CentOS7 + Nginx 環境

配置 nginx

  • 備份現有配置文件
  • 刪除 /etc/nginx/nginx.conf 中 http 塊裏的所有 server 塊
  • 清空 /etc/nginx/conf.d 目錄
  • 新建 /etc/nginx/conf.d/80.conf,內容以下
    server {
        listen 80;
        server_name aa.example.com bb.example.com;
    }
  • 重載 nginx 配置
    nginx -s reload
  • certbot 生成 nginx ssl 證書,並修改 nginx 配置
    certbot-auto --nginx -d aa.example.com -d bb.expmple.com
  • 按照業務需求,自行修改 nginx 配置

續簽證書

# 證書有效期 90 天
systemctl stop nginx
certbot-auto renew --force-renew
systemctl start nginx
相關文章
相關標籤/搜索