我意识到这个问题已经存在几年了,但我最近一直在使用类似的设置(但没有安装 ISPConfig)。为可能遇到此问题的其他人投入我的 2 美分(这是我第一次回答,所以请放轻松)。
注意 该操作未指定所使用的 GitLab 版本。较新版本的 GitLab 可能正在使用较新版本的 gitlab.rb,所以我不确定这是否会有所作为。
注意 2 我在此站点上直接从 GitLab 中找到了重要信息:https://docs.gitlab.com/omnibus/settings/nginx.html#using-a-non-bundled-web-server。这基本上是一个复制和粘贴,但我会添加自己的笔记来帮助我作为一个完整的 n00b 遇到问题。
- 禁用捆绑的 Nginx
在/etc/gitlab/gitlab.rb 集合中:
nginx['enable'] = false
- 设置非捆绑网络服务器用户的用户名
默认情况下,omnibus-gitlab 对外部没有默认设置
webserver 用户,您必须在配置中指定它。为了
Debian/Ubuntu Apache/Nginx 的默认用户是 www-data
而对于 RHEL/CentOS,Nginx 用户是 nginx。
注意:确保您首先安装了 Apache/Nginx,以便网络服务器
用户已创建,否则在重新配置时综合将失败。
例如,假设网络服务器用户是 www-data。在
/etc/gitlab/gitlab.rb 设置:
web_server['external_users'] = ['www-data']
注意:此设置是一个数组,因此您可以指定多个用户
被添加到 gitlab-www 组。 个人备注:请付款
密切注意这里的单引号和数组。尽管
开发中,我已经多次重建我的 gitlab 服务器并进入
只是一个字符串或只是一个数组,两者都会失败。厨师脚本
将使用此值为其内部设置文件权限
目录,因此 Apache 将无法写入文件,如果这是
不正确。
运行 sudo gitlab-ctl reconfigure 以使更改生效。
注意:如果您使用 SELinux 并且您的 Web 服务器在
受限的 SELinux 配置文件,您可能不得不放宽对
您的网络服务器。
*注意:确保 webserver 用户对外部 web-server 使用的所有目录具有正确的权限,否则您将
读取上游错误时接收失败(XX:权限被拒绝)。
- 将未捆绑的网络服务器添加到受信任的代理列表中(可选:仅当您的网络服务器位于
与您的 gitlab 实例不同的机器)
通常,omnibus-gitlab 默认信任代理列表为
在捆绑的 NGINX 的 real_ip 模块中配置了什么。
对于非捆绑的网络服务器,需要直接配置列表,
并且应该包括您的网络服务器的 IP 地址,如果它不在
与 GitLab 相同的机器。否则用户将显示为已签名
从您的网络服务器的 IP 地址输入。
gitlab_rails['trusted_proxies'] = [ '192.168.1.0/24', '192.168.2.1', '2001:0db8::/32' ]
- (可选)如果使用 Apache,请设置正确的 gitlab-workhorse 设置个人注意:我相信这是操作员问题中缺少的配置。
注意:以下值是在 GitLab 8.2 中添加的,请确保您有
安装的最新版本。
Apache 无法连接到 UNIX 套接字,而是需要连接到
一个 TCP 端口。允许 gitlab-workhorse 监听 TCP(默认情况下
端口8181) 编辑/etc/gitlab/gitlab.rb:
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
运行 sudo gitlab-ctl reconfigure 以使更改生效。
- 下载正确的网络服务器配置
转到GitLab recipes repository 并查找综合配置
在您选择的网络服务器目录中。确保您选择
正确的配置文件取决于您是否选择服务 GitLab
是否使用 SSL。您唯一需要更改的是 YOUR_SERVER_FQDN
使用您自己的 FQDN,如果您使用 SSL,您的 SSL 所在的位置
密钥当前驻留。您可能还需要更改
你的日志文件。
为了完整起见,这里是一个没有 SSL 配置的 Apache v2.4 配置示例:阅读评论: 如果您按照我上面的说明进行操作,在第 4 步中, gitlab_workhorse 已经配置为侦听 tcp 而不是 unix 套接字,因此可以忽略该行。 不要忽略模块依赖!这些是 Apache 能够将请求代理到您的 gitlab 实例所必需的。在 Ubuntu 上(我使用的是 Ubuntu Server 16.04.4,但我相信大多数其他 Ubuntu 版本的反应相同),可以使用 sudo a2enmod rewrite proxy proxy_http 激活这些模块。
# This configuration has been tested on GitLab 8.2
# Note this config assumes unicorn is listening on default port 8080 and
# gitlab-workhorse is listening on port 8181. To allow gitlab-workhorse to
# listen on port 8181, edit or create /etc/default/gitlab and change or add the following:
#
# gitlab_workhorse_options="-listenUmask 0 -listenNetwork tcp -listenAddr 127.0.0.1:8181 -authBackend http://127.0.0.1:8080"
#
#Module dependencies
# mod_rewrite
# mod_proxy
# mod_proxy_http
<VirtualHost *:80>
ServerName YOUR_SERVER_FQDN
ServerSignature Off
ProxyPreserveHost On
# Ensure that encoded slashes are not decoded but left in their encoded state.
# http://doc.gitlab.com/ce/api/projects.html#get-single-project
AllowEncodedSlashes NoDecode
<Location />
# New authorization commands for apache 2.4 and up
# http://httpd.apache.org/docs/2.4/upgrading.html#access
Require all granted
#Allow forwarding to gitlab-workhorse
ProxyPassReverse http://127.0.0.1:8181
ProxyPassReverse http://YOUR_SERVER_FQDN/
</Location>
# Apache equivalent of nginx try files
# http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files
# http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
RewriteEngine on
#Forward all requests to gitlab-workhorse except existing files like error documents
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^/uploads/.*
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
# needed for downloading attachments
DocumentRoot /home/git/gitlab/public
#Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.
ErrorDocument 404 /404.html
ErrorDocument 422 /422.html
ErrorDocument 500 /500.html
ErrorDocument 502 /502.html
ErrorDocument 503 /503.html
# It is assumed that the log directory is in /var/log/httpd.
# For Debian distributions you might want to change this to
# /var/log/apache2.
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
ErrorLog /var/log/httpd/logs/YOUR_SERVER_FQDN_error.log
CustomLog /var/log/httpd/logs/YOUR_SERVER_FQDN_forwarded.log common_forwarded
CustomLog /var/log/httpd/logs/YOUR_SERVER_FQDN_access.log combined env=!dontlog
CustomLog /var/log/httpd/logs/YOUR_SERVER_FQDN.log combined
</VirtualHost>
这个配置文件不能通过简单的复制和粘贴来工作!
查找“YOUR_SERVER_FQDN”并将其替换为您的 gitlab 实例的完全限定域名。根据操作员的问题,这将是 http://gitlab.example.ee,但应该与您的 gitlab.rb 文件中的 external_url 的值基本匹配。
查找“httpd”并将其替换为“apache”。该配置在设计时并未考虑到 Ubuntu 服务器,相应的目录称为“apache”。我假设你也可以使用 ${APACHE_LOG_DIR},但我自己没有测试过。
对于基本设置,这应该可以正常工作。我强烈建议研究使用 SSL 设置(可以在提供的链接中找到文档)。即使您不需要安全设置(也许这是一个内部服务器),综合中的其他功能,如 Mattermost,在没有启用 SSL(而不是使用自签名证书)的情况下也容易引发错误。