1 开启宿主机http代理服务,确认可以在局域网访问代理端口
2 修改http_proxy和https_proxy配置,在wsl2的ubuntu中输入:
cat << EOF > ./proxy.sh
export http_proxy='http://172.19.224.1:10809'
export https_proxy='http://172.19.224.1:10809'
EOF
sudo cp ./proxy.sh /etc/profile.d/proxy.sh
source /etc/profile.d/proxy.sh
3 测试代理访问
curl -vv gxxxle.com
* Uses proxy env variable http_proxy == 'http://172.19.224.1:10809'
* Trying 172.19.224.1:10809...
* TCP_NODELAY set
* Connected to 172.19.224.1 (172.19.224.1) port 10809 (#0)
> GET http://gxxxle.com/ HTTP/1.1
> Host: gxxxle.com
> User-Agent: curl/7.68.0
> Accept: */*
> Proxy-Connection: Keep-Alive
...