Gitlab的Caddy配置

这是使用Caddy运行Gitlab的配置示例。

更新Gitlab配置

使用你喜欢的文本编辑器打开/etc/gitlab/gitlab.rb,更新下面的值。

  • 替换external_urlhttps协议
  • gitlab_workhorse['listen_network']从”unix”改成”tcp”
  • gitlab_workhorse['listen_addr']从”000”改成”127.0.0.1:8181”
  • 除了root,把web_server['external_users']改成运行caddy的用户
  • nginx['enable'] = "true"改成nginx['enable'] = "false"
  • 保存并退出配置文件,然后运行gitlab-ctl reconfigure使配置生效

更新Caddyfile

gitlab.example.com指向你的FQDN。

Caddyfile

代理到http

  1. https://gitlab.example.com {
  2. log git.access.log
  3. errors git.errors.log {
  4. 404 /opt/gitlab/embedded/service/gitlab-rails/public/404.html
  5. 422 /opt/gitlab/embedded/service/gitlab-rails/public/422.html
  6. 500 /opt/gitlab/embedded/service/gitlab-rails/public/500.html
  7. 502 /opt/gitlab/embedded/service/gitlab-rails/public/502.html
  8. }
  9. proxy / http://127.0.0.1:8181 {
  10. fail_timeout 300s
  11. transparent
  12. header_upstream X-Forwarded-Ssl on
  13. }
  14. }

代理到socket文件

  1. https://gitlab.domain.tld {
  2. errors {
  3. 404 /opt/gitlab/embedded/service/gitlab-rails/public/404.html
  4. 422 /opt/gitlab/embedded/service/gitlab-rails/public/422.html
  5. 500 /opt/gitlab/embedded/service/gitlab-rails/public/500.html
  6. 502 /opt/gitlab/embedded/service/gitlab-rails/public/502.html
  7. }
  8. proxy / unix:/home/git/gitlab/tmp/sockets/gitlab.socket {
  9. fail_timeout 300s
  10. transparent
  11. }
  12. }