GitLab 7.2.1 с Apache Server вместо Nginx
Я установил GitLab 7.2.1
с пакетом .deb из GitLab.org для Debian 7 на виртуальном сервере, где у меня есть root-доступ.
На этом виртуальном сервере я уже установил Apache, версия 2.2.22
, и я не хочу использовать Ngnix для GitLab.
Теперь я понятия не имею, где находятся общие папки GitLab или что мне нужно делать или на что я должен обратить внимание.
Итак, мой вопрос: как мне настроить мой vhost для apache или что мне нужно сделать, чтобы я мог использовать подобный поддомен, например gitlab.example.com, на моем веб-сервере apache?
Ответы
Ответ 1
С учетом двух вещей:
- Единорог слушает 8080 (вы можете проверить это с помощью
sudo netstat -pant | grep unicorn
)
- Корень вашего документа
/opt/gitlab/embedded/service/gitlab-rails/public
Вы можете создать новый vhost для gitlab в apache со следующей конфигурацией:
<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>
Ответ 2
Я следил за этой статьей http://eserdeniz.fr/articles/view/4/installer-gitlab-sous-debian-7-avec-nginx-et-mysql, и она работала, но мне нужен apache вместо nginx.
После множества проблем, связанных с настройкой apache2 с gitlab-ce 7.9.0.rc3, я просмотрел документацию apache относительно директивы ProxyPass и ProxyPassReverse.
Я решил свои проблемы с этим 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 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>
Теперь он быстро вспыхивает!
Надеюсь, это поможет!
Ответ 3
В Debian GNU/Linux 8.4 (jessie) с версией Omnibus 8.5.0 (apt-get):
Конфигурация 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
Источник
https://gitlab.com/gitlab-org/gitlab-recipes/blob/master/web-server/apache/gitlab-omnibus-apache24.conf
http://doc.gitlab.com/omnibus/settings/nginx.html#using-a-non-bundled-web-server
Ответ 4
Если у вас есть проблема с доступом к 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
Ответ 5
Установка из источника. gitlab 7.4.5
Единорог слушает 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: [email protected]: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
Изменить файл конфигурации apache 2.2 работает для меня.
Другой старый файл конфигурации для gitlab 6.0 - здесь, который также работает для меня.
#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
Используя @pincoded ответ, я смог запустить GitLab, но при нажатии изменений я всегда получал ошибку 500.
Затем я использовал официальную конфигурацию для apache, предоставленную GitLab в ответе @themadmax. Проблема здесь в том, что сервер никогда не был доступен, и через некоторое время он произвел ошибку 502.
Мое решение:
Используя официальное решение от GitLab (будьте осторожны, не забудьте выбрать конфигурацию SSL в этой ссылке, если вы используете только GitLab SSL) a href= "https://forum.gitlab.com/t/error-500-when-pull-or-clone/6058" rel= "nofollow noreferrer" > эта запись в форуме Мне пришлось снова включить 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
Для недавних путешественников с GitLab 10.X.X посмотрите это репо. Вы можете найти файлы конфигурации Apache2, а также инструкции там, чтобы GitLab работал только с отключенными Apache2 и NGINX.