Gitlab 8.0.3与Apache2 / Nginx

背景

Ubuntu 15.10

Apache / 2.4.10(Ubuntu)

模块相关性全部启用:

  • mod_rewrite的
  • mod_proxy的
  • mod_proxy_http

GitLab社区版8.0.3

GitLab docroot:/ opt / gitlab / embedded / service / gitlab-rails / public

我以这种方式安装GitLab: https ://about.gitlab.com/downloads/#ubuntu1404

问题

在我的服务器上,我有一个运行Apache2(exemple-site.com)的网站。

我有GitLab与捆绑的nginx(exemple-gitlab.com)

我有1个服务器,1个IP和多个FQDN。

像这样,我所有的域名都指向GitLab。

所以exemple-gitlab.com指向GitLab,但exemple-site.com也指向GitLab,也指向其他所有FQDN。

解决方法

我想我必须(而且我试过):

  • 禁用捆绑的nginx并configurationapache2的gitlab(很难做到这一点)
  • 将绑定的nginxconfiguration为apache2的反向代理(很难做到)

MAJ:事实上问题是Apache和捆绑的nginx运行在同一个IP上,并且有相同的端口(80)。 而且我不想在81端口上运行一个网站,只有80端口。

我更喜欢为我的所有PHP网站使用apache2,我不介意gitlab是否使用apache2或捆绑的nginx,我只需要使用我的每个网站的所有FQDN,而不是所有的FQDN redirectinf到gitlab。

理解

我不明白如何omnibus或铁路或反向代理工作。

我试过在/etc/gitlab/gitlab.rb禁用捆绑的nginx

 nginx['enable'] = false # For GitLab CI, use the following: ci_nginx['enable'] = false 

添加www-datagitlab-www组并修改:

 web_server['external_users'] = ['www-data'] 

并添加修改后的vhost.conf到apache2我从https://gitlab.com/gitlab-org/gitlab-recipes/blob/master/web-server/apache/gitlab-apache24.conf

  <VirtualHost *:80> ServerName exemple-gitlab.com ServerSignature Off ProxyPreserveHost On AllowEncodedSlashes NoDecode <Location /> Require all granted #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:8080 ProxyPassReverse http://exemple-gitlab.com/ </Location> #apache equivalent of nginx try files RewriteEngine on #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:8080%{REQUEST_URI} [P,QSA,NE] # needed for downloading attachments /opt/gitlab/embedded/service/gitlab-rails/public #Set up apache error documents, if back end goes down (ie 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 # /var/log/apache2. LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded ErrorLog /var/log/apache2/logs/gitlab.example.com_error.log CustomLog /var/log/apache2/logs/gitlab.example.com_forwarded.log common_forwarded CustomLog /var/log/apache2/logs/gitlab.example.com_access.log combined env=!dontlog CustomLog /var/log/apache2/logs/gitlab.example.com.log combined </VirtualHost> 

但是这个conf错误我的apache2:

 ~# systemctl status apache2.service ● apache2.service - LSB: Apache2 web server Loaded: loaded (/etc/init.d/apache2) Active: failed (Result: exit-code) since mar. 2015-11-10 15:41:08 CET; 1min 9s ago Docs: man:systemd-sysv-generator(8) Process: 18315 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS) Process: 18342 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE) nov. 10 15:41:08 vpsxxx.ovh.net apache2[18342]: * The apache2 configtest failed. nov. 10 15:41:08 vpsxxx.ovh.net apache2[18342]: Output of config test was: nov. 10 15:41:08 vpsxxx.ovh.net apache2[18342]: (2)No such file or directory: AH02291: Cannot access di...f:10 nov. 10 15:41:08 vpsxxx.ovh.net apache2[18342]: AH00014: Configuration check failed nov. 10 15:41:08 vpsxxx.ovh.net apache2[18342]: Action 'configtest' failed. nov. 10 15:41:08 vpsxxx.ovh.net apache2[18342]: The Apache error log may have more information. nov. 10 15:41:08 vpsxxx.ovh.net systemd[1]: apache2.service: Control process exited, code=exited status=1 nov. 10 15:41:08 vpsxxx.ovh.net systemd[1]: Failed to start LSB: Apache2 web server. nov. 10 15:41:08 vpsxxx.ovh.net systemd[1]: apache2.service: Unit entered failed state. nov. 10 15:41:08 vpsxxx.ovh.net systemd[1]: apache2.service: Failed with result 'exit-code'. Hint: Some lines were ellipsized, use -l to show in full. 

我发现为什么apache2通过评论每一行(damm日志是无用的)坠毁。

我只需要创build/var/log/apache2/logs

  ErrorLog /var/log/apache2/logs/gitlab.example.com_error.log CustomLog /var/log/apache2/logs/gitlab.example.com_forwarded.log common_forwarded CustomLog /var/log/apache2/logs/gitlab.example.com_access.log combined env=!dontlog CustomLog /var/log/apache2/logs/gitlab.example.com.log combined 

apache2崩溃,因为文件夹/目录丢失…

所以现在gitlab工作是域和我的drupal也是这样的:

  • gitlab.com:80
  • drupal.com:80

像我想的那样非常好:)