# 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 ```bash vim /etc/gitlab/gitlab.rb ``` 新增或改寫以下內容 * 設定external_url為https開頭 ```bash # note the 'https' below external_url "https://192.168.88.216:443" ``` * 關閉Let’s Encrypt ```bash letsencrypt['enable'] = false ``` 2. 新增資料夾/etc/gitlab/ssl,設定權限755 ```bash sudo mkdir -p /etc/gitlab/ssl sudo chmod 755 /etc/gitlab/ssl ``` 3. 把自簽得到的.key、.crt檔放進來 ```bash sudo cp 192.168.88.216.key 192.168.88.216.crt /etc/gitlab/ssl/ ``` * <font color=red>這裡要注意的是,.key、.crt的檔名都要改成與hostname一致。</font>因為Omnibus GitLab會基於目前設定的hostname是192.168.88.216,就只去/etc/gitlab/ssl/裡面找192.168.88.216.key與192.168.88.216.crt。 * <font color=red>另一個要注意的點是,.key檔不能有密碼。</font>如果.key檔有密碼,會造成最後reconfigure GitLab時出錯,因為NGINX不會提示輸入密碼,所以要提供沒有密碼的.key檔。 請用以下指令另外輸出沒有密碼的.key檔後,再放入/etc/gitlab/ssl/ ```bash openssl rsa -in 192.168.88.216.key -out 192.168.88.216_new.key ``` * 自簽憑證請參考之前寫的[OpenSSL自簽憑證](https://hackmd.io/@enoladne/rJZ2xzWxY) 4. 請GitLab重讀設定檔 ```bash sudo gitlab-ctl reconfigure ``` 5. 如果Linux OS有啟動防火牆,請參考以下指令開放port 443 ```bash # 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. 有兩種方式 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up