在 CentOS 上部署 GitLab 后,通过域名访问通常包含以下几个步骤:
gitlab.example.com)sudo vi /etc/gitlab/gitlab.rb
找到并修改以下内容(没有就添加):
external_url 'http://gitlab.example.com'
如果使用 HTTPS(推荐):
external_url 'https://gitlab.example.com'
sudo gitlab-ctl reconfigure
在你的域名解析控制台添加记录:
Agitlab例如:
gitlab.example.com → 1.2.3.4
等待 DNS 生效(几分钟~几小时)
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
如果你 不想用 GitLab 自带 Nginx,可以禁用并自己配:
nginx['enable'] = false
sudo gitlab-ctl reconfigure
server {
listen 80;
server_name gitlab.example.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
letsencrypt['enable'] = true
letsencrypt['contact_emails'] = ['admin@example.com']
sudo gitlab-ctl reconfigure
浏览器访问:
http://gitlab.example.com
或
https://gitlab.example.com
sudo gitlab-ctl status
curl http://gitlab.example.com
如果你愿意,可以告诉我:
我可以给你更精确的配置方案。