问题
在mac上,SS没有windows 版本所具有的允许本地设备连接功能。minikube内的docker没有办法直接使用MAC本地SS http代理,同时还能确保安全。
思路
寻找可以让minikube使用本地MAC代理的方式。
解决
SS配置信息
假设mac ss已正确工作。
检查Preferences - advanced
Local Socks5 Listen Address: 127.0.0.1
Local Socks5 Listen Port: 1086
安装privoxy
brew install privoxy
配置privoxy
vim /usr/local/etc/privoxy/config
我的配置,这里可以配置多个侦听端口,因为安全原因,我仅允许minikube所在的192.168.99.1 可以访问
confdir /usr/local/etc/privoxy
logdir /usr/local/var/log/privoxy
actionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.
actionsfile default.action # Main actions file
actionsfile user.action # User customizations
filterfile default.filter
filterfile user.filter # User customizations
logfile logfile
# 4.1. listen-address
listen-address 192.168.99.1:8118 # 因为安全原因,我仅侦听在minikube所在的192.168.99.1
#listen-address 0.0.0.0:8118
toggle 1
enable-remote-toggle 0
enable-remote-http-toggle 0
enable-edit-actions 0
enforce-blocks 0
# 4.7. ACLs: permit-access and deny-access
# permit-access 192.168.45.64/26
# deny-access 192.168.45.73
buffer-limit 4096
enable-proxy-authentication-forwarding 0
# 5. FORWARDING
forward-socks5 / 127.0.0.1:1086 . # 这个要配置与ss配置一致
forwarded-connect-retries 0
# 6. MISCELLANEOUS
accept-intercepted-requests 0
allow-cgi-request-crunching 0
split-large-forms 0
keep-alive-timeout 5
tolerate-pipelining 1
socket-timeout 300
懒人版
echo 'listen-address 0.0.0.0:8118' >> /usr/local/etc/privoxy/config
注:这里一定要0.0.0.0,如果设置成127.0.0.1只能给自己这台机器用
echo 'forward-socks5 / localhost:1086 .' >> /usr/local/etc/privoxy/config
kill 掉之前的privoxy服务,然后再启动
localhost:~ xunyang$ lsof -iTCP -sTCP:LISTEN -n -P | grep 8118
privoxy 23894 xunyang 4u IPv4 0x63b22ebdce88f4e7 0t0 TCP 192.168.99.1:8118 (LISTEN)
privoxy 23894 xunyang 5u IPv4 0x63b22ebdcee58e47 0t0 TCP *:8118 (LISTEN)
localhost:~ xunyang$ kill 23894
localhost:~ xunyang$ lsof -iTCP -sTCP:LISTEN -n -P | grep 8118
localhost:~ xunyang$ /usr/local/Cellar/privoxy/3.0.26/sbin/privoxy /usr/local/etc/privoxy/config
localhost:~ xunyang$ lsof -iTCP -sTCP:LISTEN -n -P | grep 8118
privoxy 24460 xunyang 4u IPv4 0x63b22ebdcc963227 0t0 TCP 192.168.99.1:8118 (LISTEN)
privoxy 24460 xunyang 5u IPv4 0x63b22ebdba720e47 0t0 TCP *:8118 (LISTEN)
启动minikube用下面的参数
minikube start --docker-env http_proxy=http://192.168.99.1:8118 --docker-env https_proxy=http://192.168.99.1:8118 --docker-env no_proxy=127.0.0.1, localhost, 192.168.0.0/16, 10.0.0.0/8