【Proxy机器】
yum -y instal squid && yum install httpd-tools -y
vim /etc/squid/squid.conf
创建用户:
htpasswd -c /etc/squid/passwords USER
验证密码:
/usr/lib64/squid/basic_ncsa_auth /etc/squid/passwords
输入USER PASSWORD
OK
以下注释:
# http_access deny !Safe_ports
# http_access deny CONNECT !SSL_ports
# http_access deny to_localhost
# http_access allow localnet
# http_access deny all
末尾添加:
# 定义每个IP最大允许16个连接,防止攻击
acl OverConnLimit maxconn 16
# 选择的认证方式为basic,定义认证程序路径和密码文件路径。
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwords
# 认证程序的进程数
auth_param basic children 5
# 定义认证的用户
acl authenticated proxy_auth REQUIRED
# 超出之前设定的连接数则拒绝
http_access deny OverConnLimit
# 允许认证的用户访问
http_access allow authenticated
# 拒绝所有其它访问
http_access deny all
# 自定义DNS
dns_nameservers 8.8.8.8 8.8.4.4
# 修改端口
http_port PORT
保存
systemctl enable squid && systemctl start squid
【Docker容器内】
设置:
git config --global http.proxy http://USER:PASSWORD@IP:PORT
git config --global https.proxy https://USER:PASSWORD@IP:PORT
取消:
git config --global --unset http.proxy
git config --global --unset https.proxy
【测试】
curl --proxy IP:PORT -U USER:PASSWORD ip.sb