Apache 代理背后的 Gitlab

Jan*_*ack 5 apache reverse-proxy gitlab

经过几个小时的搜索,找到了在 Apache 反向代理后面运行的 Gitlab 的解决方案。需要明确的是,我可以连接到 Gitlab 实例,并且还可以执行每个基本功能,例如推送、克隆代码等。

我的问题是,我在问题中发布的每张图片始终以http://127.0.0.1:8090/.../作为 URL。我尝试更改 external_url,这总是导致 Gitlab 响应 502。我更改和尝试的任何其他设置要么没有效果,要么导致 500 或 503。我决定向你们中的任何一个人寻求提示。

我当前的配置是:/etc/gitlab/gitlab.rb

 external_url 'http://127.0.0.1:8090'
 gitlab_rails['time_zone'] = 'Europe/Berlin'

 gitlab_rails['smtp_enable'] = true
 gitlab_rails['smtp_address'] = "mail.server.de"
 gitlab_rails['smtp_port'] = 465
 gitlab_rails['smtp_user_name'] = "noreply@server.de"
 gitlab_rails['smtp_password'] = "password"
 gitlab_rails['smtp_domain'] = "mail.server.de"
 gitlab_rails['smtp_authentication'] = "login"
 gitlab_rails['smtp_enable_starttls_auto'] = false
 gitlab_rails['smtp_tls'] = true
 gitlab_rails['smtp_pool'] = false

 gitlab_rails['smtp_openssl_verify_mode'] = 'none'

 gitlab_rails['gitlab_email_enabled'] = true

 gitlab_rails['gitlab_email_from'] = 'noreply@server.de'
 gitlab_rails['gitlab_email_display_name'] = 'NoReply Server'
 gitlab_rails['gitlab_email_reply_to'] = 'kontakt@server.de'

 gitlab_rails['gitlab_default_theme'] = 2

 letsencrypt['enable'] = false
Run Code Online (Sandbox Code Playgroud)

/etc/apache2/sites-available/gitlab.conf

<VirtualHost *:443>
    ServerName gitlab.server.de
    
    ProxyPreserveHost On
    ProxyRequests Off
    ProxyPass /.well-known/acme-challenge !
    ProxyPass / http://127.0.0.1:8090/ retry=0
    ProxyPassReverse / http://127.0.0.1:8090/
    
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/gitlab.server.de/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/gitlab.server.de/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

你们能帮我吗?提前致谢。

syt*_*ech 8

将您的external_urlURL 设置为用户用来访问您的 GitLab 服务器的 URL。例如gitlab.server.de根据您的 Apache 配置。

此外,如果您不使用相互 TLS,您需要修复代理标头以处理协议更改。

最重要的是,您需要显式配置 GitLab 的内部 nginx 以侦听您在 proxy/proxypass 配置中指定的端口,而不是使用 https。

所以,像这样:

external_url "https://gitlab.server.de"

# set listen port explicitly, required when using non-default port
# and port is not specified in external_url
nginx['listen_port'] = 8090

# disable https listener, since Apache is setup for SSL/TLS termination
nginx['listen_https'] = false


# technically optional, set proxy headers
nginx['proxy_set_headers'] = {
    "X-Forwarded-Proto" => "http",
    "X-Forwarded-Port" => "80"
}
Run Code Online (Sandbox Code Playgroud)

同样重要的是要注意,GitLab 本身应该能够使用其external_url. 换句话说,您的 Apache 服务器应该 (1) 可通过主机上的 DNS 进行解析,并且 (2) 允许从 GitLab 访问。