centos

GitLab在CentOS上的网络设置指南

小樊
41
2025-08-10 12:47:28
栏目: 智能运维

以下是GitLab在CentOS上的网络设置指南:

配置网络接口

编辑网络配置文件,如/etc/sysconfig/network-scripts/ifcfg-ens33,设置静态IP地址等参数:

BOOTPROTO=static
IPADDR=192.168.1.100  # 替换为实际IP
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
ONBOOT=yes

保存后重启网络服务:sudo systemctl restart network

配置防火墙

开放GitLab所需端口(HTTP:80、HTTPS:443、SSH:22):

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --permanent --zone=public --add-service=ssh
sudo firewall-cmd --reload

配置GitLab

编辑/etc/gitlab/gitlab.rb,设置external_url为服务器IP或域名,如external_url 'http://192.168.1.100'。若用HTTPS,可设为external_url 'https://192.168.1.100',并配置SSL证书相关参数。保存后执行:

sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

0
看了该问题的人还看了