Cyber Deals - Get up to 65% off on CKA, CKAD, CKS, KCNA, KCSA exams and courses!

Configure Custom SSL to Secure GitLab Server

Configure Custom SSL to Secure GitLab Server

I have explained How to Install GitLab in a Disconnected Environment in a past article. In this article you will learn how to use self-signed or custom SSL certificates to secure your GitLab servers.

You can use any of the below listed certificates depends on your environments for this method.

  • Self-signed SSL certificates and key
  • Custom CA signed SSL certificate and key
  • Let’s Encrypt SSL certificates and key

Follow below steps to configure GitLab with custom SSL certificate.

Copy SSL Certificate and Key

Create the ssl directory if does not exist.

$ mkdir /etc/gitlab/ssl/

Copy custom SSL certificate and key to the /etc/gitlab/ssl/ directory.

sudo ls -l /etc/gitlab/ssl
total 8
-rw-r--r--. 1 root root 2222 Dec 22 13:06 gitlab-ce.lab.local.crt
-rw-------. 1 root root 1679 Dec 22 13:06 gitlab-ce.lab.local.key

Configure /etc/gitlab/gitlab.rb

Edit /etc/gitlab/gitlab.rb file and configure below items.

  1. Disable Let’s Encrypt and renewal in /etc/gitlab/gitlab.rb file
letsencrypt['auto_renew'] = false
  1. You can use any custom names or keep the file format as per GitLab configuration. In my case, I follow the GitLab file format and did not change filename or path inside configuration for SSL.
# nginx['ssl_certificate'] = "/etc/gitlab/ssl/#{node['fqdn']}.crt"
# nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/#{node['fqdn']}.key"
  1. Change the external_url parameter in /etc/gitlab/gitlab.rb file (from http to https )
external_url 'https://gitlab-ce.lab.local'

Reconfigure the GitLab

Reconfigure the GitLab and wait for re-configuration to complete.

$ sudo gitlab-ctl reconfigure

Restart GitLab to use the latest configuration

$sudo gitlab-ctl restart

Now verify access to `` from a web browser and verify the SSL certificate.

Gineesh Madapparambath

Gineesh Madapparambath

Gineesh Madapparambath is the founder of techbeatly. He is the co-author of The Kubernetes Bible, Second Edition and the author of Ansible for Real Life Automation. He has worked as a Systems Engineer, Automation Specialist, and content author. His primary focus is on Ansible Automation, Containerisation (OpenShift & Kubernetes), and Infrastructure as Code (Terraform). (Read more: iamgini.com)


Disclaimer: Views expressed in articles are those of the respective authors and do not necessarily reflect the views of their employers or this site. While we aim for accuracy, please verify information before relying on it, and let us know if you spot an error.
Share:

Related Posts

How to Install GitLab in a Disconnected Environment

How to Install GitLab in a Disconnected Environment

Installing GitLab is a simple job as you just need to install the dependancies and then GitLab package.

Ansible

Ansible for Infrastructure Provisioning in AWS | Ansible Real Life Series

Learn how to use Ansible for Infrastructure Provisioning in AWS Creating ec2 instances Creating security groups Creating Elastic Load Balancers …

Ansible

Demystifying YAML for Ansible [LIVE]

Learn YAML Basics, YAML in Ansible, Variable, List, Dictionary, YAML in Playbook

Ansible

How to Start with Ansible [LIVE]

Are you an absolute beginner and struggling to start your Ansible journey ? Join us this Sunday 31st Oct, 7.30 PM IST/10PM SGT

Ansible

Ansible Collections [LIVE]

Ansible Collection is a great way of getting content contributions from various Ansible Developers. We will learn what is Ansible Collection and how …

Creating the Elastic Stack on AWS using Terraform

Creating the Elastic Stack on AWS using Terraform

Elastic stack brings all the logs & traces into a single place & Terraform is an Infrastructure as code provisioner. While exploring both of them,...