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

https://gitlab.example.com {
    log git.access.log 
    errors git.errors.log {
        404 /opt/gitlab/embedded/service/gitlab-rails/public/404.html
        422 /opt/gitlab/embedded/service/gitlab-rails/public/422.html
        500 /opt/gitlab/embedded/service/gitlab-rails/public/500.html
        502 /opt/gitlab/embedded/service/gitlab-rails/public/502.html
    }

    proxy / http://127.0.0.1:8181 {
        fail_timeout 300s
        transparent
        header_upstream X-Forwarded-Ssl on
    }
}

代理到socket文件

https://gitlab.domain.tld {

    errors {
        404 /opt/gitlab/embedded/service/gitlab-rails/public/404.html
        422 /opt/gitlab/embedded/service/gitlab-rails/public/422.html
        500 /opt/gitlab/embedded/service/gitlab-rails/public/500.html
        502 /opt/gitlab/embedded/service/gitlab-rails/public/502.html
    }

    proxy / unix:/home/git/gitlab/tmp/sockets/gitlab.socket {
        fail_timeout 300s

        transparent
    }
}