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.
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=1Start and enable the Postfix mail service:
[root@test ~]# systemctl start postfix && systemctl enable postfixInstall 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" 2048Generate 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.pemApply 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.confExample 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
