Brief guide for installing Gitlab-ee and replacing nginx with an apache reverse-proxy. Plus a few tips on overcoming several issues ran into setting up Gitlab.
Following how-to is based off Ubuntu 16.04 server and an apache reverse-proxy setup like outlined here.
Installation
Installing is pretty straight forward. Follow this guide for your system.
I chose not to install postfix as I'll setup my own SMTP mail server after.
Services
Gitlab has several services that you'll likely call frequently during setup.
sudo gitlab-ctl stop sudo gitlab-ctl start sudo gitlab-ctl status sudo gitlab-ctl restart sudo gitlab-ctl reconfigure
Configuration file
Gitlab uses a configuration file for most the setup that you'll do during a server install. This file, for example is used to change ports that it will listen on, disable nginx (to use apache instead), and setup authentication with Atlassian Crowd:
/etc/gitlab/gitlab.rb
For example, since I run several applications on my server, the default Gitlab listening port of 8080 wouldn't work (since Jira was already listening on that port). I used the above file to change the listening port to something else.
Auto-boot
Gitlab is, by default, set to start on boot. You can toggle this by:
sudo systemctl disable gitlab-runsvdir.service sudo systemctl enable gitlab-runsvdir.service
Using apache instead of nginx, and all over https
Changes to gitlab.rb to disable nginx
Open gitlab.rb
sudo nano /etc/gitlab/gitlab.rb
and make the following changes
... external_url 'https://gitlab.example.com' ... ################################################################################ ## GitLab Workhorse ##! Docs: https://gitlab.com/gitlab-org/gitlab-workhorse/blob/master/README.md ################################################################################ # gitlab_workhorse['enable'] = true # gitlab_workhorse['ha'] = false gitlab_workhorse['listen_network'] = "tcp" # gitlab_workhorse['listen_umask'] = 000 gitlab_workhorse['listen_addr'] = "127.0.0.1:9000" gitlab_workhorse['auth_backend'] = "http://127.0.0.1:9080" ... gitlab_workhorse['auth_socket'] = "/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket" ... unicorn['port'] = 9080 unicorn['socket'] = '/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket' ... web_server['external_users'] = ['www-data'] ... nginx['enable'] = false
Note: the above examples assumes workhorse port (which you will apache reverse-proxy to) is 9000 and unicorn is 9080 (this is the port you set the workhorse['auth_backend'] to).
Now, we need to add apache (www-data) to the gitlab user group:
sudo usermod -G gitlab-www www-data
Now, save gitlab.rb and run reconfigure
sudo gitlab-ctl reconfigure
Apache setup
The biggest issue I had was getting this dang thing working with my apache reverse-proxy, and using https (with a 301 redirect if accessed via http).
First, add entries in a proxy.conf file for your gitlab subdomain. Gitlab is a bit different than my other applications and requires a bit of special attention in the virtual-host block of the proxy.conf file. See below for a working example:
Note1: where <path/to/fullchain.pem> and <path/to/privkey.pem> are the paths to your SSL certificate files.
Note2: You'll note that I <Location /> directive overrides any default apache configuration for <Proxy *> directives. If you've defined an ipblacklist (like here) you'll need to redefine it within this <Location /> directive.
Integrating with Altassian Crowd
I had a few issues implementing Gitlab with Crowd for authentication. Below are settings that finally worked:
Add omniauth_provider to /etc/gitlab/gitlab.rb
Add/modify the following to /etc/gitlab/gitlab.rb
Now save, exit and reconfigure
sudo gitlab-ctl reconfigure
References
- https://about.gitlab.com/installation/
- https://kevingoedecke.me/2015/09/17/setup-gitlab-on-debian-7-with-existing-apache-webserver/
- https://blog.romaingre.net/2015/01/gitlab-install-and-configure-on-apache2-with-https/
- https://serverfault.com/questions/585528/set-gitlab-external-web-port-number
- https://gitlab.com/gitlab-org/omnibus-gitlab/issues/3615
Related articles