問題
在mac上,SS沒有windows 版本所具有的允許本地設備連接功能。screenshot_287.png
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