使用 apache2(或 nginx + apache2)配置 gitlab [英] Configure gitlab with apache2 (or nginx + apache2)

查看:40
本文介绍了使用 apache2(或 nginx + apache2)配置 gitlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在带有 LAMP 的 Ubuntu14.04 服务器中安装了 GitLab.我知道 GitLab 旨在与基于 nginx 的服务器一起使用,但该服务器具有已通过 apache2 安装的网络应用程序,我需要它们.

I have installed GitLab in a Ubuntu14.04 server with LAMP. I am aware that GitLab has been designed to work with nginx based servers, but this server has web apps that have been installed over apache2 and I need them.

我尝试按照 本教程安装 GitLab.我使用了 gitlab_7.7.1-omnibus.5.4.1.ci-1_amd64.deb 包.

I tried installing GitLab following this tutorial. I used the gitlab_7.7.1-omnibus.5.4.1.ci-1_amd64.deb package.

我最终遇到了与一些评论者相同的问题(错误 502).我尝试遵循 this通过评论链接,看看我是否能找到任何相关信息,但它似乎与我的情况无关.

I ended up having the same problem than some of the people who commented (error 502). I tried following this link through the comments to see if I could find any relevant information, but it doesn't seem to be relevant for my case.

我一直在寻找通过 apache2 配置 nginx 的替代方法,但我什么也没找到.

I keep searching for alternative ways to configure nginx through apache2, but I'm not finding anything.

这是我在 /var/log/gitlab/nginx/gitlab_error.log 中找到的一个日志条目:

Here's a log entry that I found in /var/log/gitlab/nginx/gitlab_error.log:

2015/01/30 19:32:27 [error] 995#0: *3 connect() to unix:/var/opt/gitlab
/gitlab-rails/sockets/gitlab.socket failed (111: Connection refused)
while connecting to upstream, client: 127.0.0.1, server: mygitlab.com,
request: "GET / HTTP/1.1", upstream: "http://unix:/var/opt/gitlab/gitlab-
rails/sockets/gitlab.socket:/", host: "localhost:8080"

看来是上游socket的配置有问题.

It seems that it is a problem with upstream socket's configuration.

gitlab-ctl status 输出:

run: logrotate: (pid 4465) 1488s; run: log: (pid 826) 5087s
run: nginx: (pid 837) 5087s; run: log: (pid 825) 5087s
run: postgresql: (pid 827) 5087s; run: log: (pid 817) 5087s
run: redis: (pid 828) 5087s; run: log: (pid 818) 5087s
run: sidekiq: (pid 839) 5087s; run: log: (pid 824) 5087s
run: unicorn: (pid 5861) 0s; run: log: (pid 823) 5087s

无论如何,似乎 Omnibus 根本没有安装 nginx(或者我猜是这样,/etc/init.d/ 中没有名为nginx"的服务.我不会丢弃日志生成器将 apache2 与 nginx 混淆的可能性.

Anyways, it seems that Omnibus doesn't install nginx at all (or I guess so, there's no service named 'nginx' in /etc/init.d/. I do not discard the possibility that the log generator confused apache2 with nginx).

问题:

  • 是否必须安装nginx才能运行gitlab?如果可以,能不能和apache正常共存?

  • Is it mandatory to install nginx to run gitlab? If so, can it co-exist with apache properly?

通过 apache 代理 GitLab 是否是我正在寻找的一种好方法?

Is proxying GitLab through apache a good approach to what I'm looking for?

我对独角兽了解不多.我在 SO 中找到了这个问题.这是否意味着 Unicorn 在 GitLab 中处理上游套接字?

I don't know much about Unicorn. I found this question in SO. Does this mean that Unicorn handles upstream sockets in GitLab?

检查 本文档 我决定检查 Omnibus 是否使用 ruby -v 安装了 Ruby,我注意到根本没有安装 Ruby.所以我决定按照文档的说明编译安装它:

Checking this document I decided to check if Omnibus installed Ruby with ruby -v and I noticed that Ruby wasn't installed at all. So I decided to compile and install it, following the document's instructions:

mkdir /tmp/ruby && cd /tmp/ruby
curl -L --progress http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.5.tar.gz | tar xz
cd ruby-2.1.5
./configure --disable-install-rdoc
make
sudo make install

无论如何,似乎某些依赖项失败了,并且 ruby​​ 无法正常运行.当我尝试 sudo gem install bundler --no-ri --no-rdoc 时,出现以下错误:

Anyways, it seems some dependencies failed and ruby is not plently operative. When I try sudo gem install bundler --no-ri --no-rdoc, the following errors ocurr:

ERROR:  Loading command: install (LoadError)
    cannot load such file -- zlib
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass

make操作过程中,发生了以下错误:

During the make operation, these errors happened:

Failed to configure -test-/win32/dln. It will not be installed.
Failed to configure -test-/win32/dln/empty. It will not be installed.
Failed to configure -test-/win32/fd_setsize. It will not be installed.
Failed to configure dbm. It will not be installed.
Failed to configure fiddle. It will not be installed.
Failed to configure gdbm. It will not be installed.
Failed to configure openssl. It will not be installed.
Failed to configure readline. It will not be installed.
Failed to configure tk. It will not be installed.
Failed to configure tk/tkutil. It will not be installed.
Failed to configure win32. It will not be installed.
Failed to configure win32ole. It will not be installed.
Failed to configure zlib. It will not be installed.

似乎完全没有必要编译和安装 Ruby.环顾配置文件,我看到 Omnibus 在 /opt/gitlab/embedded/ 目录中安装了很多依赖项(其中包括 Ruby).:-S

It seems that compiling and installing Ruby was completely inneccessary. Looking around for config files, I saw that Omnibus installed lots of dependencies (Ruby among them) in /opt/gitlab/embedded/ directory. :-S

推荐答案

运行 gitlab 必须安装 nginx 吗?如果可以,可以共存吗正确使用apache?

Is it mandatory to install nginx to run gitlab? If so, can it co-exist with apache properly?

Gitlab 与 nginx 捆绑在一起,但您可以将它与 Apache HTTP 服务器一起使用.

Gitlab is bundled with nginx but you can use it with Apache HTTP server.

通过 apache 代理 GitLab 是一种很好的方法来满足我的需求为了?

Is proxying GitLab through apache a good approach to what I'm looking for?

您可以在 Gitlab 配置中禁用 nginx 并配置 Apache 以转发到 Gitlab.

You can disable nginx in Gitlab config and configure Apache to forward to Gitlab.

我对独角兽了解不多.我在 SO 中发现了这个问题.做这意味着 Unicorn 在 GitLab 中处理上游套接字?

I don't know much about Unicorn. I found this question in SO. Does this mean that Unicorn handles upstream sockets in GitLab?

Unicorn 是 Ruby 的 HTTP 服务器.您可以将请求转发到 Gitlab Unicorn 服务器或 gitlab-workhorse.

Unicorn is HTTP server for Ruby. You can forward requests to Gitlab Unicorn server or gitlab-workhorse.

以下是Apache使用的基本/etc/gitlab/gitlab.rb配置,其他行注释:

Below is the basic /etc/gitlab/gitlab.rb configuration used with Apache, other lines are commented:

external_url 'https://my.example.com/gitlab'

external_url 'https://my.example.com/gitlab'

gitlab_workhorse['enable'] = true
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:9191"

gitlab_workhorse['enable'] = true
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:9191"

独角兽['听'] = '127.0.0.1'
独角兽['端口'] = 9099

unicorn['listen'] = '127.0.0.1'
unicorn['port'] = 9099

web_server['external_users'] = ['www-data']
web_server['用户名'] = 'apache' #'gitlab-www'
web_server['group'] = 'apache' #'gitlab-www'

web_server['external_users'] = ['www-data']
web_server['username'] = 'apache' #'gitlab-www'
web_server['group'] = 'apache' #'gitlab-www'

nginx['启用'] = 假

nginx['enable'] = false

并将 /etc/apache2/apache2.conf 中的 proxyPass 设置为运行在 9191 上的 gitlab-workhorse:

And make proxyPass in /etc/apache2/apache2.conf to the gitlab-workhorse running on 9191:

ProxyPass/gitlab http://127.0.0.1:9191/gitlab
RequestHeader 添加 X-Forwarded-Proto "https"
RequestHeader 设置 X-Forwarded-Ssl on

ProxyPass /gitlab http://127.0.0.1:9191/gitlab
RequestHeader add X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Ssl on

这篇关于使用 apache2(或 nginx + apache2)配置 gitlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆