在 Linux 上部署 GitLab 时,常见端口配置如下(以 Omnibus GitLab 为例):
| 服务 | 默认端口 | 说明 |
|---|---|---|
| HTTP | 80 | Web 访问 |
| HTTPS | 443 | 启用 SSL 时 |
| SSH | 22 | Git SSH 克隆 |
| Prometheus | 9090 | 监控(内部) |
| PostgreSQL | 5432 | 数据库(内部) |
| Redis | 6379 | 缓存(内部) |
编辑配置文件:
sudo vim /etc/gitlab/gitlab.rb
示例:
external_url 'http://gitlab.example.com:8080'
# 或
external_url 'https://gitlab.example.com:8443'
重新配置:
sudo gitlab-ctl reconfigure
gitlab_rails['gitlab_shell_ssh_port'] = 2222
同时修改系统 SSH(如需要):
sudo vim /etc/ssh/sshd_config
Port 2222
重启:
sudo systemctl restart sshd
sudo gitlab-ctl restart
docker run -d \
-p 8080:80 \
-p 8443:443 \
-p 2222:22 \
--name gitlab \
gitlab/gitlab-ee
sudo gitlab-ctl status
netstat -tunlp | grep gitlab
如果你是用 源码安装 / Docker / Kubernetes / 内网环境,可以告诉我具体场景,我给你精确端口方案。