SebasSBM
SebasSBM

Reputation: 908

Configure gitlab with apache2 (or 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.

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

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.

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

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"

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

gitlab-ctl status outputs:

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

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).

Questions:

EDIT: 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

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

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.

EDIT2: 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

Upvotes: 1

Views: 1829

Answers (1)

Justinas Jakavonis
Justinas Jakavonis

Reputation: 8798

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

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

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

You can disable nginx in Gitlab config and configure Apache to forward to 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 is HTTP server for Ruby. You can forward requests to Gitlab Unicorn server or gitlab-workhorse.

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

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"

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

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

nginx['enable'] = false

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 add X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Ssl on

Upvotes: 1

Related Questions