我已经在我具有root访问权限的虚拟服务器上为来自GitLab.org的Debian 7的.deb软件包安装了GitLab 7.2.1
。
在这个虚拟服务器上,我已经安装了Apache,版本2.2.22
,我不想将Ngnix用于GitLab。
现在我不知道GitLab的公共文件夹在哪里,我必须做什么,或者我必须注意什么。
所以我的问题是:我如何配置我的vhost for apache或我还需要做什么,我可以在我的apache web服务器上使用像“gitlab.example.com”这样的子域?
答案 0 :(得分:20)
记住两件事:
sudo netstat -pant | grep unicorn
)/opt/gitlab/embedded/service/gitlab-rails/public
您可以使用以下配置在apache中为gitlab创建新的vhost:
<VirtualHost *:80>
ServerName gitlab.example.com
ServerSignature Off
ProxyPreserveHost On
<Location />
Order deny,allow
Allow from all
ProxyPassReverse http://127.0.0.1:8080
ProxyPassReverse http://gitlab.example.com/
</Location>
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA]
# needed for downloading attachments
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
</VirtualHost>
答案 1 :(得分:11)
我遵循了这篇文章http://eserdeniz.fr/articles/view/4/installer-gitlab-sous-debian-7-avec-nginx-et-mysql并且它有效,但我需要apache而不是nginx。
在使用gitlab-ce 7.9.0.rc3配置apache2时遇到了很多麻烦,我查看了关于ProxyPass和ProxyPassReverse指令的apache文档。
我用这个vhost解决了我的问题:
<VirtualHost *:80>
ServerName gitlab.me
# those options below are recommanded by apache, dealing with the simple Proxy we need for gitlab
ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
# here we don't want to proxify the requests for the existing assets in gitlab's public directory
ProxyPassMatch ^(/[^/]+\.(html|png|ico|css|txt))$ !
ProxyPass /assets !
# here we "redirect" the requests for http://gitlab.me/ to http://127.0.0.1:8080/
ProxyPass / http://127.0.0.1:8080/
# here we "rewrite" the redirections form unicorn for http://127.0.0.1:8080/ into http://gitlab.me/
ProxyPassReverse / http://127.0.0.1:8080/
# And of course the DocumentRoot to handle the assets requests
DocumentRoot /home/git/gitlab/public/
# In the last versions of apache, there is a deny,allow default order so we put those two sections to prevent 'client denied by server configuration' 403 error
<Directory /home/git/gitlab/public/>
# apache 2.2
Order allow,deny
Allow from all
# apache 2.4
Require all granted
</Directory>
<Location />
# apache 2.2
Order allow,deny
Allow from all
# apache 2.4
Require all granted
</Location>
</VirtualHost>
现在它的速度非常快!!
希望这会有所帮助!
答案 2 :(得分:3)
使用Omnibus 8.5.0(apt-get)版本在 Debian GNU / Linux 8.4(jessie)上:
GitLab配置
# cat /etc/gitlab/gitlab.rb | grep -v '^$\|^\s*\#'
external_url 'http://gitlab.example.fr'
gitlab_workhorse['enable'] = true
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
web_server['external_users'] = ['www-data']
nginx['enable'] = false
Apache2配置
# cat /etc/apache2/sites-enabled/gitlab.conf | grep -v '^$\|^\s*\#'
<VirtualHost *:80>
ServerName gitlab.example.fr
ServerSignature Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Location />
Require all granted
ProxyPassReverse http://127.0.0.1:8181
ProxyPassReverse http://gitlab.example.fr/
</Location>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/api/v3/.*
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^/uploads/.*
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA]
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
ErrorDocument 404 /404.html
ErrorDocument 422 /422.html
ErrorDocument 500 /500.html
ErrorDocument 503 /deploy.html
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
ErrorLog /var/log/apache2/gitlab_error.log
CustomLog /var/log/apache2/gitlab_forwarded.log common_forwarded
CustomLog /var/log/apache2/gitlab_access.log combined env=!dontlog
CustomLog /var/log/apache2/gitlab.log combined
</VirtualHost>
Netstat输出
# netstat -pant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 11849/postgres
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 23736/config.ru
tcp 0 0 127.0.0.1:8181 0.0.0.0:* LISTEN 26061/gitlab-workho
来源
http://doc.gitlab.com/omnibus/settings/nginx.html#using-a-non-bundled-web-server
答案 3 :(得分:2)
如果您有HTTP git访问问题,请查看以下配置:
# cat /etc/gitlab/gitlab.rb | grep -v '^$\|^\s*\#'
external_url 'http://gitlab.example.fr'
web_server['external_users'] = ['www-data']
nginx['enable'] = false
ci_nginx['enable'] = false
gitlab_git_http_server['listen_network'] = "tcp"
gitlab_git_http_server['listen_addr'] = "localhost:8282"
和apache2配置:
# cat /etc/apache2/sites-enabled/gitlab
<VirtualHost *:80>
ServerName gitlab.example.fr
ProxyRequests Off
ServerSignature Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
ProxyPassMatch ^(/[^/]+\.(html|png|ico|css|txt))$ !
ProxyPass /assets !
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule /[-\/\w\.]+\.git\/ http://127.0.0.1:8282%{REQUEST_URI} [P,QSA,L]
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
<Directory /opt/gitlab/embedded/service/gitlab-rails/public/>
Order allow,deny
Allow from all
</Directory>
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
应用更改:
# gitlab-ctl reconfigure
# service apache2 reload
来自https://gitlab.com/gitlab-org/gitlab-ce/issues/2669#note_2176671
答案 4 :(得分:2)
对于 GitLab 10.X.X 的近期旅行者,请查看this repo。您可以找到Apache2配置文件以及其中的说明,以便GitLab仅在禁用Apache2和NGINX的情况下运行。
答案 5 :(得分:1)
从源代码安装。 gitlab 7.4.5
Unicorn正在侦听9095.Apache是2.2.9,我没有使用https。
System information
System: CentOS 6.7
Current User: git
Using RVM: no
Ruby Version: 2.1.2p95
Gem Version: 2.2.2
Bundler Version:1.11.2
Rake Version: 10.3.2
Sidekiq Version:2.17.0
GitLab information
Version: 7.4.5
Revision: 19d572e
Directory: /home/git/gitlab
DB Adapter: mysql2
URL: http://gitlab.example.com
HTTP Clone URL: http://gitlab.example.com/some-project.git
SSH Clone URL: git@gitlab.example.com:some-project.git
Using LDAP: no
Using Omniauth: no
GitLab Shell
Version: 2.0.1
Repositories: /home/git/repositories/
Hooks: /home/git/gitlab-shell/hooks/
Git: /usr/bin/git
修改configuration file apache 2.2对我有用。
gitlab 6.0的另一个旧配置文件是here,它也适用于我。
#This configuration has been tested on GitLab 8.0.0
#Note this config assumes unicorn is listening on default port 8080 and gitlab-git-http-server is listening on port 8181.
#To allow gitlab-git-http-server to listen on port 8181, edit or create /etc/default/gitlab and change or add the following:
#gitlab_git_http_server_options="-listenUmask 0 -listenNetwork tcp -listenAddr localhost:8181 -authBackend http://127.0.0.1:8080"
#Module dependencies
# mod_rewrite
# mod_proxy
# mod_proxy_http
# HTTP Configuration
<VirtualHost *:80>
ServerName gitlab.example.com
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
# 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 />
#Require all granted
Order deny,allow
Allow from all
#Allow forwarding to gitlab-git-http-server
#ProxyPassReverse http://127.0.0.1:8181
#Allow forwarding to GitLab Rails app (Unicorn)
ProxyPassReverse http://127.0.0.1:9095
ProxyPassReverse http://gitlab.example.com/
</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 these requests to gitlab-git-http-server
#Forward these requests to gitlab-git-http-server
#RewriteCond %{REQUEST_URI} ^/[\w\.-]+/[\w\.-]+/repository/archive.* [OR]
#RewriteCond %{REQUEST_URI} ^/api/v3/projects/.*/repository/archive.* [OR]
#RewriteCond %{REQUEST_URI} ^/[\w\.-]+/[\w\.-]+/(info/refs|git-upload-pack|git-receive-pack)$
#RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA]
#Forward any other requests to GitLab Rails app (Unicorn)
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^/uploads
RewriteRule .* http://127.0.0.1:9095%{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 503 /deploy.html
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
ErrorLog logs/gitlab.example.com_error.log
CustomLog logs/gitlab.example.com_forwarded.log common_forwarded
CustomLog logs/gitlab.example.com_access.log combined env=!dontlog
CustomLog logs/gitlab.example.com.log combined
</VirtualHost>
希望对于使用旧版gitlab从源代码安装的人有用。
答案 6 :(得分:0)
使用@ pincoded的答案,我能够启动并运行GitLab,但在推送更改时,我总是收到500错误。
然后我在@themadmax的回答中使用了GitLab提供的apache的官方配置。这里的问题是服务器永远无法访问,并在一段时间后产生502错误。
我的解决方案: 使用GitLab的the official solution(注意,如果你只运行GitLab SSL,请记住在此链接中选择SSL配置)但是this forum entry之后我必须再次打开nginx。
所以最后我的配置看起来像这样:
虚拟主机:
<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 /opt/gitlab/embedded/service/gitlab-rails/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
</VirtualHost>
gitlab.ru:
# nginx['enable'] = false # this defaults to true
gitlab_workhorse['enable'] = true
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
答案 7 :(得分:0)
我只是花了半天的时间弄清楚gitlab为什么会给我错误422并抱怨gitlab-rails production.log日志中的CSRF令牌。
原来,我不得不将此添加到apache配置中:
RequestHeader set X-Forwarded-Ssl on
在我的情况下,gitlab是从deb软件包安装的,而Apache在HTTPS上运行。