Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 349
rhand Avatar asked Jul 29 '14 09:07

rhand


People also ask

What is GitLab unicorn?

GitLab uses Unicorn, a pre-forking Ruby web server, to handle web requests (web browsers and Git HTTP clients). Unicorn is a daemon written in Ruby and C that can load and run a Ruby on Rails application; in our case the Rails application is GitLab Community Edition or GitLab Enterprise Edition.

Does GitLab use nginx or Apache?

The gitlab server uses nginx as its default server, while our projects use apache server to serve contents. Running two internal servers simultaneously can pose a lot of issues (ports … etc).

What is GitLab default port?

With both of these, gitlab continues to run on the default 80 port number.


1 Answers

The documentation suggests setting 'nginx['listen_port'] = 8080' but when I did this unicorn failed to bind port 8080. I set the nginx port to 8888 instead and it worked. This suggests that in order to set the nginx port to 8080, it is necessary to change unicorn from default port of 8080 to something else, but I didn't explore that possibility. It would be nice if the example for setting the nginx port was a setting that would work in the default configuration, which mine is, as well as I know - I only installed it this morning.

like image 190
Ian Avatar answered Oct 18 '22 20:10

Ian