Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx环境,在网站数量很多的情况下,ssl申请失败 #133

Open
yar999 opened this issue Apr 10, 2024 · 0 comments
Open

nginx环境,在网站数量很多的情况下,ssl申请失败 #133

yar999 opened this issue Apr 10, 2024 · 0 comments

Comments

@yar999
Copy link

yar999 commented Apr 10, 2024

  1. 问题介绍:

不知道从哪个版本开始,宝塔的nginx环境下,申请ssl的验证文件的内容返回变成nginx那边直接返回内容了, 比如某个nginx虚拟主机添加了下面的内容:

    #CERT-APPLY-CHECK--START
    # 用于SSL证书申请时的文件验证相关配置 -- 请勿删除
    include /www/server/panel/vhost/nginx/well-known/abc.conf;
    #CERT-APPLY-CHECK--END

/www/server/panel/vhost/nginx/well-known/abc.conf具体的内容类似下面的:

if ($request_uri ~ "^/\.well-known/acme-challenge/GRp2K2NhFc1ngLB78xmg1BW3lr46g_il6t-ZYYJ8Fvc.*"){
    return 200 "GRp2K2NhFc1ngLB78xmg1BW3lr46g_il6t-ZYYJ8Fvc.sA3oj-aC__XMRTAC3Y9JxhB4evgIg1mJsTmPISELmLE";
}
  1. 导致的问题

/www/server/panel/vhost/nginx/well-known/abc.conf 会在每次申请ssl的时候临时修改, 且修改之后还需要重载nginx配置, 问题就出现在这里.

如果访问验证文件是在nginx重载生效之前,100% 会验证失败,导致ssl申请失败.
如果访问验证文件是在nginx重载生效之后,则会通过验证,成功申请ssl.

实际生产环境下服务器负载高或者nginx当前比较繁忙无法立刻重载,都会导致访问验证文件在nginx重载生效之前发生.进而导致ssl申请失败.

  1. 建议

(1) 建议修改程序等待nginx重载生效之后再访问验证文件
(2) 不让nginx返回验证文件的内容, 直接访问网站根目录下对应的验证文件
(3) 指定一个固定的目录生成验证文件,做个 .well-known/acme-challenge 的别买到那个固定目录 (directadmin面板好像就是这样操作的)

建议(2),(3)不需要重载nginx配置文件,直接访问验证文件的内容就没有这个问题.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant