![為 GitLab 啟用 SSL 會導致 ERR_CONNECTION_REFUSED](https://rvso.com/image/697037/%E7%82%BA%20GitLab%20%E5%95%9F%E7%94%A8%20SSL%20%E6%9C%83%E5%B0%8E%E8%87%B4%20ERR_CONNECTION_REFUSED.png)
我已經安裝了現有的 GitLab 幾個月了,我決定是時候新增一個真正的 SSL 憑證(不是自簽署的)了。
根據文檔,我更改了以下行:
external_url 'http://<domain>.com'
到:
external_url 'https://<domain>.com'
並取消註解以下行:
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.crt"
nginx['ssl_certificate_key'] "/etc/gitlab/ssl/gitlab.key"
為了確定起見,我仔細檢查了密鑰檔:
root@host:/etc/gitlab# cat /etc/gitlab/ssl/gitlab.crt
-----BEGIN CERTIFICATE-----
...
root@host:/etc/gitlab# cat /etc/gitlab/ssl/gitlab.key
-----BEGIN PRIVATE KEY-----
...
然後我跑了gitlab-ctl reconfigure
,最後我收到了成功的訊息。但是,當導航到 GitLab URL 時,我得到了一個ERR_CONNECTION_REFUSED
.當我註解掉上面的所有行並運行時gitlab-ctl reconfigure
,HTTP 連接埠 80 上的一切都恢復正常。
當我向設定檔提供兩個憑證並調整 URL 時,什麼可能會導致 nginx 拒絕連線?謝謝!
答案1
聽起來 GitLab 沒有監聽 443。80 上的重定向會將您傳送到 443,您會在其中收到「連線被拒絕」的訊息。配置應該有listen 443
一行(參見http://nginx.org/en/docs/http/configuring_https_servers.html),允許它接收 SSL 請求。
頁面中的範例:
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate www.example.com.crt;
ssl_certificate_key www.example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
...
}