默認(rèn)情況下,gitlab使用自帶的Nginx偏友,占用80端口蔬胯,這樣就與系統(tǒng)原本安裝的Nginx沖突。有完美的解決方案嗎位他?當(dāng)然氛濒!
方案一:通過修改GitLab端口解決沖突
- vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
upstream gitlab-workhorse {
server unix:/var/opt/gitlab/gitlab-workhorse/socket;
}
server {
listen *:80; --修改端口
server_name localhost;
server_tokens off; ## Don't show the nginx version number, a security best practice
......
......
只列舉了其中一部分
}
將其中的80改為其它端口即可,如我的是886鹅髓,執(zhí)行gitlab-ctl restart
重啟gitlab等待網(wǎng)關(guān)恢復(fù)舞竿,重新訪問:http://ip:886 即可
方案二:禁用gitlab自帶Nginx 并把 UNIX套接字 更改為 TCP端口
禁用捆綁的Nginx
vim /etc/gitlab/gitlab.rb
將
nginx['enable'] = true
修改為
nginx['enable'] = false
并去掉注釋 (前邊的#)
允許gitlab-workhorse監(jiān)聽TCP(默認(rèn)端口8181),編輯/etc/gitlab/gitlab.rb:
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
運行 sudo gitlab-ctl reconfigure
使更改生效窿冯。
- 通過系統(tǒng)原本安裝的Nginx反代以便提供訪問
$ vim /etc/nginx/conf.d/gitlab.conf
server {
listen 80;
server_name gitlab.edevops.top;
location / {
root html;
index index.html index.htm;
proxy_pass http://127.0.0.1:8181;
}
}
systemctl restart nginx
訪問:http://gitlab.edevops.top 即可