学习笔记 · 2021年11月3日

解决 GitLab 更新出现“unable to request certificate”的问题

今天在更新 GitLab 的时候(从12更新到14),出现了“unable to request certificate”的问题,主要报错如下:

gitlab-ce    | There was an error running gitlab-ctl reconfigure:
gitlab-ce    | letsencrypt_certificate[xxx.xxxx.com] (letsencrypt::http_authorization line 5) had an error: RuntimeError: acme_certificate[staging] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/letsencrypt/resources/certificate.rb line 25) had an error: RuntimeError: ruby_block[create certificate for xxx.xxxx.com] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/acme/resources/certificate.rb line 108) had an error: RuntimeError: [xxx.xxxx.com] Validation failed, unable to request certificate

通过查看官方论坛,发现这是因为没有设置 http 重定向到 https 导致,首先可直接重启,其次可以修改 gitlab.rb 的如下配置来解决:

nginx['redirect_http_to_https_port'] = 80
nginx['redirect_http_to_https'] = true