代码之家  ›  专栏  ›  技术社区  ›  Victor

Nginx不考虑续费让我们加密证书

  •  0
  • Victor  · 技术社区  · 6 年前

    我有一个服务器在内部端口上运行一些NodeJs应用程序(准确地说是MeteorJs)。我用Nginx proxy_pass 以应用程序的URL为目标的请求。

    app_1 正在运行 localhost:3000 app1.domain.com 本地主机:3000 然后添加防火墙规则以限制对端口3000的访问。

    然后在传入连接上添加SSL app1.domain.com网站 certbot certonly -w /var/www/app1 -d app1.domain.com 然后将nginx配置文件设置为使用它。

    一切工作都完美无瑕,直到它的时间来更新证书。

    要进行续订,我有以下cron作业:

    12 6 * * 3 /root/renew.sh
    

    /root/renew.sh :

    certbot renew 
    service nginx reload
    

    我遇到的问题是,在过期时,nginx web服务器不提供新证书!

    30 6 * * 3 service nginx restart
    

    但是它仍然不能刷新证书(这会导致导航器出错,说连接失败是因为证书到期而不安全)。所以我需要手动登录并重新加载nginx。

    我的设置有什么问题?

    谢谢

    1 回复  |  直到 6 年前
        1
  •  0
  •   Victor    6 年前

    经过更多的测试,下面是这个问题的答案:

    将cron作业设置为指向bash脚本:

    12 6 * * 3 /root/renew.sh
    

    certbot renew
    sleep 1m
    service nginx reload
    

    请注意 sleep

    推荐文章