Operations 5 min read

Installing and Configuring GitLab CE with SSL on CentOS

This guide walks through setting up the GitLab CE repository, installing GitLab, generating SSL certificates, configuring GitLab and Nginx for HTTPS, and verifying access on a CentOS server using command‑line operations.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Installing and Configuring GitLab CE with SSL on CentOS

First, add the GitLab CE repository by creating [root@test yum.repos.d]# more gitlab_gitlab-ce.repo with the following content:

[gitlab_gitlab-ce]
name=gitlab_gitlab-ce
baseurl=https://packages.gitlab.com/gitlab/gitlab-ce/el/7/$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1

Start and enable the Postfix mail service:

[root@test ~]# systemctl start postfix && systemctl enable postfix

Install the GitLab CE community edition: [root@test ~]# yum -y install gitlab-ce Next, create a directory for SSL certificates and generate a private key:

[root@test ~]# mkdir -p /etc/gitlab/ssl
[root@test ~]# openssl genrsa -out "/etc/gitlab/ssl/gitlab.hahashen.com.key" 2048

Generate a certificate signing request (CSR):

[root@test ~]# openssl req -new -key "/etc/gitlab/ssl/gitlab.hahashen.com.key" -out "/etc/gitlab/ssl/gitlab.hahashen.com.csr"

Sign the CSR to create a self‑signed certificate:

[root@test ssl]# openssl x509 -req -days 365 -in "/etc/gitlab/ssl/gitlab.hahashen.com.csr" -signkey "/etc/gitlab/ssl/gitlab.hahashen.com.key" -out "/etc/gitlab/ssl/gitlab.hahashen.com.crt"

Generate Diffie‑Hellman parameters and set proper permissions:

[root@test ssl]# openssl dhparam -out /etc/gitlab/ssl/dhparams.pem 2048
[root@test ssl]# chmod 600 *

Modify the GitLab configuration file: [root@test ~]# vim /etc/gitlab/gitlab.rb Set the external URL and enable HTTPS redirection:

external_url 'https://gitlab.hahashen.com'
nginx['redirect_http_to_https'] = true
# nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.hahashen.com.crt"
# nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.hahashen.com.key"
# nginx['ssl_dhparam'] = /etc/gitlab/ssl/dhparams.pem # Path to dhparams.pem

Apply the configuration changes: [root@test ~]# gitlab-ctl reconfigure Adjust the embedded Nginx configuration to force HTTPS:

[root@test ssl]# vim /var/opt/gitlab/nginx/conf/gitlab-http.conf

Example server block:

server { ## HTTPS redirect server
listen *:80;
server_name gitlab.hahashen.com;
rewrite ^(.*)$ https://$host$1 permanent;
server_tokens off;
}

Restart GitLab services to apply the Nginx changes: [root@test ssl]# gitlab-ctl restart Finally, open a web browser and navigate to https://gitlab.hahashen.com to verify the installation.

The article concludes with a request for readers to like, share, and follow the author for more technical content.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

GitLabNGINXInstallationSSLCentOS
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.