CentOS7 網(wǎng)絡(luò)代理配置指南
系統(tǒng)環(huán)境變量配置
通過全局配置文件設(shè)置代理:
vi /etc/profile
# 添加以下內(nèi)容
export http_proxy="http://proxy_ip:proxy_port"
export https_proxy="http://proxy_ip:proxy_port"
export no_proxy="localhost,127.0.0.1"
source /etc/profile
Yum代理配置
修改yum配置文件:
vi /etc/yum.conf
# 添加代理參數(shù)
proxy=http://proxy_ip:proxy_port
proxy_username=user
proxy_password=pass
應(yīng)用程序代理支持
Curl命令代理
curl -x http://proxy_ip:proxy_port https://example.com
Wget代理配置
vi /etc/wgetrc
# 取消注釋并修改
http_proxy = http://proxy_ip:proxy_port
https_proxy = http://proxy_ip:proxy_port
Squid代理服務(wù)器搭建
安裝與配置
yum install squid
vi /etc/squid/squid.conf
# 修改訪問控制規(guī)則
acl localnet src 192.168.1.0/24
http_access allow localnet
防火墻配置
firewall-cmd --permanent --add-port=3128/tcp
firewall-cmd --reload
systemctl start squid
代理測試與驗(yàn)證
curl -I --proxy http://proxy_ip:3128 https://www.example.com
tail -f /var/log/squid/access.log
配置注意事項(xiàng)
- 確保代理服務(wù)器端口在防火墻中開放
- 敏感憑證建議使用加密配置文件存儲
- 容器環(huán)境需單獨(dú)配置代理參數(shù)
- 使用HTTPS代理時注意證書驗(yàn)證