Try   HackMD

GilLab 14 設定HTTPS

  • 官方文件,請見Manually configuring HTTPS

https://docs.gitlab.com/omnibus/settings/nginx.html#manually-configuring-https

使用自簽憑證啟用GitLab的HTTPS_以hostname是192.168.88.216為例

  1. 到/etc/gitlab/gitlab.rb
vim /etc/gitlab/gitlab.rb

新增或改寫以下內容

  • 設定external_url為https開頭
# note the 'https' below
external_url "https://192.168.88.216:443"
  • 關閉Let’s Encrypt
letsencrypt['enable'] = false
  1. 新增資料夾/etc/gitlab/ssl,設定權限755
sudo mkdir -p /etc/gitlab/ssl
sudo chmod 755 /etc/gitlab/ssl
  1. 把自簽得到的.key、.crt檔放進來
sudo cp 192.168.88.216.key 192.168.88.216.crt /etc/gitlab/ssl/
  • 這裡要注意的是,.key、.crt的檔名都要改成與hostname一致。因為Omnibus GitLab會基於目前設定的hostname是192.168.88.216,就只去/etc/gitlab/ssl/裡面找192.168.88.216.key與192.168.88.216.crt。

  • 另一個要注意的點是,.key檔不能有密碼。如果.key檔有密碼,會造成最後reconfigure GitLab時出錯,因為NGINX不會提示輸入密碼,所以要提供沒有密碼的.key檔。
    請用以下指令另外輸出沒有密碼的.key檔後,再放入/etc/gitlab/ssl/

openssl rsa -in 192.168.88.216.key -out 192.168.88.216_new.key
  1. 請GitLab重讀設定檔
sudo gitlab-ctl reconfigure
  1. 如果Linux OS有啟動防火牆,請參考以下指令開放port 443
# UFW example (Debian, Ubuntu)
sudo ufw allow https

# lokkit example (RedHat, CentOS 6)
sudo lokkit -s https

# firewall-cmd (RedHat, Centos 7)
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld

官方文件Search步驟

  1. 在GitLab首頁網址後面加上help,就有GitLab文件
  2. 在文件search輸入https,找到Configuring HTTPS with the domain name
  3. 文件請我們去看Omnibus documentation,有超連結
  4. 有兩種方式