美文网首页
certbot 申请免费ssl证书配置

certbot 申请免费ssl证书配置

作者: 虚心的锄头 | 来源:发表于2020-12-10 17:41 被阅读0次

    安装

    配置环境

    centos7 # 从 20年12月9日 certbot 删除了对 centos6 的支持

    # 安装 snapd
    yum -y install epel-release
    yum install snapd nginx
    systemctl enable --now snapd.socket
    ln -s /var/lib/snapd/snap /snap
    
    # 安装 certbot 
    snap install core
    snap refresh core
    snap install --classic certbot
    ln -s /snap/bin/certbot /usr/bin/certbot
    

    配置nginx

    mkdir -p /var/www/certbot
    # 添加配置
    vim /etc/nginx/nginx
    ...
    server {
            listen 80 default_server;
            location ^~ /.well-known/acme-challenge/ {
                root /var/www/certbot/;
                default_type "text/plain";
                try_files $uri =404;
            }
            location / {
                return 404;
            }
        }
    ...
    
    # 启动服务
    systemctl enable nginx
    systemctl start nginx
    

    配置防火墙

    -A INPUT -p tcp -m multiport --dports 80,443 -j ACCEPT
    

    申请方式

    手动

    --manual
    条件: 修改dns, 添加txt值

    certbot certonly --agree-tos -d a.mailtest.wang \
    --manual-auth-hook /opt/certbot-auto/auth_certbot \
    --no-bootstrap --manual --preferred-challenges dns \
    -n -q --dry-run
    

    自动1

    --webroot
    默认证书 letsencrypt (90天有效期)
    条件: 80 或 443 端口对外开放

    certbot certonly --agree-tos -d c.mailtest.wang \
    --webroot -w /var/www/certbot/ \
    --dry-run
    

    自动2 ---其他证书

    --webroot
    更换申请地址 buypass (180天有效期)
    条件: 80 或 443端口对外开放

    certbot certonly --agree-tos -d a.mailtest.wang \
    --webroot -w /var/www/certbot/ \
    --email email.list@cndns.com \
    --server 'https://api.buypass.com/acme/directory' \
    --dry-run
    

    参数详解

    https://www.dazhuanlan.com/2019/12/13/5df2eeb662b16/

    certonly 创建证书
    -d 指定域名
    --manual-auth-hook 验证插件中间件
    --no-bootstrap 阻止certbot-auto脚本从安装操作系统级别的依赖项
    --manual 指定插件
    --preferred-challenges 指定验证类型列表顺序 "dns" or "http,dns"
    -n 非交互式运行
    -q 程序运行只输出错误信息
    --dry-run (正式申请时不用添加)测试, 不限制频率
    --force-renewal 强制更新
    --agree-tos 同意ACME服务器的订阅协议
    -m EMAIL 接收重要帐户通知的电子邮件地址

    certbot 会将相关的环境变量传递

    CERTBOT_DOMAIN: 正在验证的域
    CERTBOT_VALIDATION: 验证字符串
    CERTBOT_TOKEN: HTTP-01挑战的资源名称部分(仅适用于HTTP-01)
    CERTBOT_REMAINING_CHALLENGES: 当前挑战之后剩余的挑战数量
    CERTBOT_ALL_DOMAINS: 以逗号分隔的列表,列出了针对当前证书提出挑战的所有域

    相关文章

      网友评论

          本文标题:certbot 申请免费ssl证书配置

          本文链接:https://www.haomeiwen.com/subject/frergktx.html