Debian上优化 GitLab 网络连接的实用方案
一 基础网络与端口可达性优化
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
DNS 可在 /etc/resolv.conf 设置如:nameserver 8.8.8.8
nameserver 8.8.4.4
应用后执行:sudo systemctl restart networking。防火墙放行:sudo ufw allow 80,443/tcp && sudo ufw reload。external_url 'https://gitlab.example.com'
nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.example.com.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.example.com.key"
变更后执行:sudo gitlab-ctl reconfigure && sudo gitlab-ctl restart。二 传输层与 TLS 优化
listen 443 ssl http2; # HTTP/2
listen 443 quic reuseport; # HTTP/3/QUIC(需 Nginx 支持)
add_header Alt-Svc 'h3=":443"; ma=86400';
同时优化 TLS:启用 ECDHE 曲线、TLS1.2+、开启 OCSP Stapling、使用 AES-GCM/ChaCha20-Poly1305 等现代套件,禁用过时协议与弱哈希。三 反向代理与并发连接优化
worker_processes auto;
worker_connections 4096;
keepalive_timeout 65;
gzip on;
brotli on;
# /etc/gitlab/gitlab.rb
puma['worker_processes'] = 4
puma['min_threads'] = 4
puma['max_threads'] = 16
sidekiq['concurrency'] = 20
变更后执行:sudo gitlab-ctl reconfigure。四 高可用与带宽利用优化
五 监控与验证