Enable HTTPS on Gitlab

The Gitlab self-hosted application uses HTTP by default. You can enable HTTPS by performing a couple of steps. You need to acquire an SSL certificate and corresponding key for a domain that is under your control, and tell Gitlab that it needs to use these resources.

Create a directory which will hold the certificate and key:

mkdir -p /etc/gitlab/ssl
chmod 0700 /etc/gitlab/ssl

Copy your certificate file (either .crt or .pem) and key file into this directory:

cp example.net.pem example.net.key /etc/gitlab/ssl
chmod 0600 /etc/gitlab/ssl/example.net.*

Edit the file /etc/gitlab/gitlab.rb:

external_url 'https://gitlab.example.net:8443’
nginx['ssl_certificate'] = "/etc/gitlab/ssl/example.net.pem"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/example.net.key"

Reconfigure Gitlab to apply the changes:

gitlab-ctl reconfigure