Linux服务器配置上网代理squid

使用公网的服务器上安装代理

1、安装部署squid

yum install squid
cd /etc/squid/
备份文件 cp squid.conf squid.conf_bak 备份文件
修改 把http_access deny all修改为http_access allow all

2、启动squid

squid -k parse
squid -z
service squid start

3、查看squid服务

netstat -tupln | grep squid

4、配置yum使用离线代理

export http_proxy="http://192.168.1.3:3128"   ##配置临时代理地址(重新登录失效)
vi /etc/yum.conf
增加:proxy=http://192.168.1.3:3128

5、全局离线代理设置

vim ~/.bashrc
export http_proxy="http://10.60.1.94:3128"
export https_proxy="http://10.60.1.94:3128"
export ftp_proxy=$http_proxy

6、docker pull使用代理

方法一:编辑 /usr/lib/systemd/system/docker.service
[Service]下增加:Environment="HTTP_PROXY=10.60.1.94:3128" "HTTPS_PROXY=http://10.60.1.94:3128"

Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
Environment="HTTP_PROXY=10.60.1.94:3128" "HTTPS_PROXY=http://10.60.1.94:3128"
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
systemctl daemon-reload
systemctl restart docker

方法二:配置/etc/systemd/system/docker.service.d/

#http
vim /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"

#https
vim /etc/systemd/system/docker.service.d/https-proxy.conf
[Service]
Environment="HTTPS_PROXY=https://proxy.example.com:443/"
posted @ 2020-07-23 22:50  名字很长容易被惦记  阅读(618)  评论(0编辑  收藏  举报