Configure VPS Proxy

常见虚拟机或者VPS配置代理服务

MAC虚拟机代理设置

偏好设置里HTTP代理,默认监听127.0.0.1,修改为0.0.0.0,并开启 http 代理服务器

zsh 配置

export http_proxy=http://192.168.199.39:1087
export https_proxy=http://192.168.199.39:1087

docker配置 proxy

mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/http-proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=http://192.168.199.39:1087" "HTTPS_PROXY=http://192.168.199.39:1087"
EOF

如有不需要代理的可以加上NO_PROXY

然后更新配置

systemctl daemon-reload
systemctl restart docker

测试一下

kubeadm config images pull
I0630 10:22:10.882571   19186 feature_gate.go:230] feature gates: &{map[]}
[config/images] Pulled k8s.gcr.io/kube-apiserver-amd64:v1.11.0
[config/images] Pulled k8s.gcr.io/kube-controller-manager-amd64:v1.11.0
[config/images] Pulled k8s.gcr.io/kube-scheduler-amd64:v1.11.0
[config/images] Pulled k8s.gcr.io/kube-proxy-amd64:v1.11.0
[config/images] Pulled k8s.gcr.io/pause-amd64:3.1
[config/images] Pulled k8s.gcr.io/etcd-amd64:3.2.18
[config/images] Pulled k8s.gcr.io/coredns:1.1.3

腾讯云Debian配置proxy

安装shadowsocks

apt update
apt install python-apt python-pip git -y
pip install git+https://github.com/shadowsocks/shadowsocks.git@master

配置 shadowsocks

cat /root/conf/proxy.json
{
    "server":"<ip>",
    "server_port":<port>,
    "local_address": "127.0.0.1",
    "local_port":1080,
    "password":"<passwd>",
    "timeout":300,
    "workers":4,
    "method":"salsa20",
    "fast_open": false
}

配置salsa20

$ wget https://download.libsodium.org/libsodium/releases/LATEST.tar.gz
tar zxf LATEST.tar.gz
cd libsodium*
./configure
make && sudo make install

#将下面的代码追加到 `/etc/ld.so.conf`:
/lib
/usr/lib64
/usr/local/lib

# 再重新载入配置:
$ ldconfig

启动proxy

root@VM-0-5-debian:~/bin# cat start.sh
nohup sslocal -c /root/conf/proxy.json  2>&1 &
# 或者添加到/etc/rc.local开机启动

🌹🐔, sslocal支持daemon,具体见评论

配置http代理

使用Privoxy将sock5代理映射为http代理.

apt update
apt install privoxy
# 编辑  /etc/privoxy/config

forward-socks5 / 127.0.0.1:1080 .
listen-address 127.0.0.1:8118

# 重启
service privoxy restart

# 配置代理

export http_proxy=http://127.0.0.1:8118
export https_proxy=http://127.0.0.1:8118