适用于Gitlab 9.0+
禁用内置的nginx服务器
vim /etc/gitlab/gitlab.rb
unicorn['port'] = 8081
nginx['enable'] = false
gitlab-ctl stop
sudo gitlab-ctl reconfigure
gitlab-ctl start
配置apache虚拟主机
<VirtualHost *:80>
ServerName gitlab.local.lnvit.com
ServerSignature Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Location />
Order deny,allow
Allow from all
Require all granted
ProxyPassReverse http://127.0.0.1:8080
ProxyPassReverse http://gitlab.local.lnvit.com/
</Location>
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA,NE]
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
</VirtualHost>
重新启动apache
setsebool -P httpd_can_network_connect 1
可解决如下错误:
[error] (13)Permission denied: proxy: HTTP: attempt to connect to 127.0.0.1:8080 (127.0.0.1) failed