Gitlab 克隆按钮和自定义集成 URL

Gitlab clone button and Integrations with custom URL

我在反向代理后面的亲戚 url domain.com/gitlab 上使用 gitlab,但是我在一些功能上遇到了一些麻烦。

我必须设置 external_url=http://<ip-address>:<port> 才能使用我的反向代理访问 gitlab。当我创建项目时,gitlab 在创建过程 https://my.domain.com/gitlab/<username|groupname>/<newprojectname> 以及现有项目的设置中显示正确的项目 url。但是,克隆按钮仍然显示 http://<ip-address>:<port>/gitlab/<username|groupname>/<newprojectname>,这当然不起作用。我已经添加了 slack webhook 集成来接收合并请求、推送等的更新,这也是同样的问题。松弛消息的链接看起来像这样 http://<ip-address>:<port>/gitlab/<username|groupname>/<someidentifier>.

这可能是gitlab版本的问题还是我缺少一些设置?

Gitlab gitlab/gitlab-ce:14.9.4-ce.0

gitlab_rails['gitlab_shell_ssh_port'] = 2224
external_url 'http://<server-ip-address>:<docker-port>/gitlab/'
gitlab_rails['trusted_proxies'] = ['<server-ip-address>']
nginx['proxy_set_headers'] = {
  "X-Forwarded-Proto" => "https",
  "X-Forwarded-Ssl" => "on",
  "Host" => "my.domain.com",
  "X-Real-IP" => "$$remote_addr",
  "X-Forwarded-For" => "$$proxy_add_x_forwarded_for",
}

Nginx:nginx:1.21.6-alpine

##############
##  GITLAB  ##
##############
  location /gitlab/ {
    root /home/git/gitlab/public;

    client_max_body_size 0;

    proxy_http_version 1.1;
    proxy_pass http://<server-ip-address>:<docker-port>/gitlab/;

    gzip                    off;

    proxy_read_timeout      300;
    proxy_connect_timeout   300;
    proxy_redirect          off;


    proxy_set_header    Host                $host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Proto   https;
    proxy_set_header    X-Forwarded-Ssl     on;
  }

请参阅 Installing GitLab under a Relative URL 的文档。它涉及更改几个不同文件中的配置。

对于尝试此操作的其他人,以下方法对我有用:

gitlab_rails['gitlab_shell_ssh_port'] = 2224
external_url 'https://my.domain.com/gitlab/'
nginx['listen_port'] = 8929
nginx['listen_https'] = false
nginx['proxy_set_headers'] = {
  "X-Forwarded-Proto" => "https",
  "X-Forwarded-Ssl" => "on",
  "Host" => "$$host",
  "X-Real-IP" => "$$remote_addr",
  "X-Forwarded-For" => "$$proxy_add_x_forwarded_for",
}
 location /gitlab/ {
    root /home/git/gitlab/public;

    client_max_body_size 0;

    proxy_http_version 1.1;
    proxy_pass http://<server-ip-address>:8929/gitlab/;

    gzip                    off;

    proxy_read_timeout      300;
    proxy_connect_timeout   300;
    proxy_redirect          off;


    proxy_set_header    Host                $host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Proto   https;
    proxy_set_header    X-Forwarded-Ssl     on;
  }