GitLab在Debian中的網絡配置要點如下:
安裝依賴與GitLab
sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl
EXTERNAL_URL
參數指定服務器IP或域名。配置網絡接口(Debian 12+使用netplan)
/etc/netplan/01-netcfg.yaml
,設置靜態IP、網關、DNS等,例如:network:
version: 2
renderer: networkd
ethernets:
ens4:
addresses: [192.168.1.100/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
sudo netplan apply
。設置GitLab外部訪問
/etc/gitlab/gitlab.rb
,配置external_url
為服務器IP或域名,如external_url 'http://192.168.1.100'
。配置防火墻
sudo ufw allow 80; sudo ufw allow 443; sudo ufw reload
。可選:Nginx反向代理(提升性能與安全)
sudo apt-get install nginx
/etc/nginx/sites-available/gitlab
),設置反向代理規則,例如:server {
listen 80;
server_name your_domain_or_ip;
location / {
proxy_pass http://localhost:8022; # GitLab默認端口
proxy_set_header Host $host;
}
}
sudo systemctl restart nginx; sudo gitlab-ctl reconfigure
。驗證配置
http://your_server_ip
,首次訪問需設置管理員密碼。注意:配置前建議備份網絡配置文件,確保IP、端口等信息正確無誤。如需HTTPS,可啟用Let’s Encrypt證書。