Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forwarding to GitLab Subdomain with Existing Nginx Installation

I've been following the instructions from the GitLab wiki, however, it seems as if some key pieces of information are missing. In the section "Using a Non-Bundled Web Server" it never explains how I need to reconfigure my Nginx installation to reverse proxy over to GitLab.

Basically, I'd like to have GitLab installed under git.example.com, but I can't seem to find the configuration settings for my existing Nginx installation that'll do that. The wiki page goes on to talk about configuring an existing Passenger/Nginx installation, but I don't have Passenger, so I don't think that applies to my situation.

I suppose the easiest solution would be if there were a way to tell Gitlab to use it's built-in Nginx and just listen on an internal port, and then have my other Nginx forward to that port, but I can't seem to figure out how to configure Gitlab to handle that.

Any help would be greatly appreciated.

like image 950
Ecksters Avatar asked Apr 02 '15 00:04

Ecksters


2 Answers

I got it working! So insanely excited!

So as I said, I was attempting to follow these instructions, but I wasn't getting anywhere, since it seemed to be lacking instructions on how to make your existing Nginx install link into Gitlab.

Well, further down on the page they have a more complete explanation for Using an Existing Passenger / Nginx Installation, and while at first that didn't seem like what I wanted, researching Passenger a bit made it clear that it wasn't a Ruby-only thing(their easily-found install instructions require you to install it as a ruby gem) and their instructions for Ubuntu installation allowed me to integrate it into my existing Nginx reasonably easily.

From there, it was just follow the steps in the wiki, although with a couple changes.

  1. The Existing Passenger/Nginx Installation section fails to mention what the previous section on non-bundled Nginx install says, that you need to add www-data to the web_server['external_users'] line in the gitlab.rb file.
  2. Since I reconfigured my Gitlab installation to remove the bundled Nginx before I ran it the first time, the nginx log file at /var/log/gitlab/nginx/gitlab_access.log was non-existent, and this caused an error when Nginx tried to start up, simply creating that blank file and giving it proper read/write access made it work like a charm.

I'm super psyched now, hope anyone who has as specific of a problem in the future comes across this, that Wiki should really be updated to simply remove/merge those two sections and explain/link to how to install Passenger into an existing Nginx installation. Would have saved me a lot of confusion and wasted time.

like image 82
Ecksters Avatar answered Sep 19 '22 18:09

Ecksters


Run with existing Nginx server on Ubuntu

  1. Install gitlab
  2. Edit configuration file /etc/gitlab/gitlab.rb and uncomment or append following:
    • nginx['enable'] = false
    • unicorn['enable'] = false
    • gitlab_rails['internal_api_url'] = 'http://git.yourdomain.com'
    • web_server['external_users'] = ['www-data']
  3. Start bundled postgres database server
    • sudo gitlab-ctl start postgresql
  4. Reconfigure
    • sudo gitlab-ctl reconfigure
  5. Add nginx configuration file for git lab to /etc/nginx/sites-available/gitlab-example.conf and enable it via sites-enabled
    • https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md#using-a-non-bundled-web-server
  6. Enable passenger for nginx
    • https://www.phusionpassenger.com/library/install/nginx/install/oss/trusty
  7. Restart nginx
    • sudo service nginx restart
  8. Start redis
    • sudo gitlab-ctl start redis
like image 44
fillky Avatar answered Sep 21 '22 18:09

fillky