certbot Ubuntu 自动更新 nginx证书

  1. 安装

    sudo snap install --classic certbot
    sudo ln -s /snap/bin/certbot /usr/bin/certbot
  2. 获取证书

    sudo certbot certonly --webroot -w /data/wwwroot/iguojin.com/ -d iguojin.com
  3. 挂载docker

    /etc/letsencrypt:/etc/nginx/ssl/letsencrypt
  4. 配置nginx

    ssl_certificate     /etc/nginx/ssl/letsencrypt/live/iguojin.com/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/letsencrypt/live/iguojin.com/privkey.pem;
  5. 自动更新

    sudo certbot renew --dry-run

    执行这个命令后,他会自动配置定时任务,在如下位置之一

    /etc/crontab/
    /etc/cron.*/*
    systemctl list-timers
  6. 通过阿里云DNS
    https://github.com/tengattack/certbot-dns-aliyun

    sudo snap install certbot-dns-aliyun
    sudo snap set certbot trust-plugin-with-root=ok
    sudo snap connect certbot:plugin certbot-dns-aliyun
    /snap/bin/certbot plugins
    
    certbot certonly --authenticator=dns-aliyun --dns-aliyun-credentials='/ssl_conf/credentials.ini' -d "*.iguojin.com"

此处评论已关闭