rhand rhand - 6 months ago 177
Ruby Question

Gitlab Configuration Issues:: NGINX Unicorn Port Conflict

I have managed to partly setup Gitlab on a Linux CentOS server with Apache, Git, PHP, PostGreSQL and MySQL. I am running the Chef Cookbook version. I got the rpm from here. I wanted to use it to manage my Git repo better and more visually and this seemed to be a good choice. But now I run into issues getting it to work.

Just to make it really work and update all files I decided to rerun the configuration using

gitlab-ctl reconfigure
. Second run did work:

Chef Client finished, 4 resources updated
gitlab Reconfigured!


See full log here: http://pastebin.com/cE7DYv6w

The hoster had already put NGINX on 8080 not get into an argument with Apache running on port 80 where we have a LAMP project running. But now Ruby's Unicorn Web Server seems to be conflicting with NGINX. I have worked with NGINX a little bit, not much and this is my first stab at Gitlab. Anyways this is what I figured out with the help of my hoster.

When I log into testserver.domain.net and pass the following command:

netstat -ln |grep 8080
I see

tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN


So something is running on 8080
According to my hoster it should run on 0.0.0.0:8080. And when we check what is running on that port we see

netstat -tupln |grep 8080
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 21627/unicorn maste


When we check the process id 21627, we see

cat /proc/21627/cmdline
unicorn master -E production -c /var/opt/gitlab/gitlab-rails/etc/unicorn.rb /opt/gitlab/embedded/service/gitlab-rails/config.ru


That is a Ruby process, and not a NGINX process.

So NGINX seems to be conflicting with Unicorn.

And when we check the logs of nginx we see that nginx cannot get going because of this:

tail -f /var/log/gitlab/nginx/error.log
2014/07/28 09:43:10 [emerg] 23122#0: bind() to 0.0.0.0:8080 failed (98: Address already in use)
2014/07/28 09:43:10 [emerg] 23122#0: still could not bind()
2014/07/28 09:43:12 [emerg] 23123#0: bind() to 0.0.0.0:8080 failed (98: Address already in use)
2014/07/28 09:43:12 [emerg] 23123#0: bind() to 0.0.0.0:8080 failed (98: Address already in use)
2014/07/28 09:43:12 [emerg] 23123#0: bind() to 0.0.0.0:8080 failed (98: Address already in use)
2014/07/28 09:43:12 [emerg] 23123#0: bind() to 0.0.0.0:8080 failed (98: Address already in use)
2014/07/28 09:43:12 [emerg] 23123#0: bind() to 0.0.0.0:8080 failed (98: Address already in use)
2014/07/28 09:43:12 [emerg] 23123#0: still could not bind()


I googled Unicorn.rb and found this link. I also read that:


Unicorn is an HTTP server for Rack applications designed to only serve
fast clients on low-latency, high-bandwidth connections and take
advantage of features in Unix/Unix-like kernels. Slow clients should
only be served by placing a reverse proxy capable of fully buffering
both the the request and response in between Unicorn and slow clients.


When I check the file
/var/opt/gitlab/gitlab-rails/etc/unicorn.rb
I do see it uses 8080. Issue is that it seems Unicorn should work together with NGINX so perhaps I should not change the port.

What step should I take to make Gitlab work? Can Gitlab work without Unicorn? I would think not. Should I then pick another port for it or perhaps for NGINX?

Answer

You should override the ports in /etc/gitlab/gitlab.rb. Don't mess with /var/opt/gitlab/... because any manual configuration will be lost after a reconfigure. In particular read this. In the downloads page there is a sentence: For troubleshooting and configuration options please see the Omnibus GitLab readme. I wonder if this is not seen by people :/ If not we should make it more clear.