ubuntu22.04使用shadowsocks配置全局代理
ubuntu22.04使用shadowsocks配置全局代理
参考链接
https://zhuanlan.zhihu.com/p/506030897
1.安装shadowsocks
pip install https://github.com/shadowsocks/shadowsocks/archive/master.zip
2.配置shadowsocks
vim /etc/shadowsocks.json
配置格式参考
{
"server":"***.***.***.***", # need to find on your own
"local_address": "127.0.0.1",
"local_port":1080,
"server_port": 1000, # need to find on your own
"password":"************", # need to find on your own
"timeout":600,
"method":"aes-256-sha"
}
3.启动和停止
sslocal -c /etc/shadowsocks.json -d start/stop
扩展脚本如下,如ss_script.sh
#!/bin/bash
if [ "$1" = "start" ]; then
sslocal -c /etc/shadowsocks.json -d start
elif [ "$1" = "stop" ]; then
sslocal -c /etc/shadowsocks.json -d stop
elif [ "$1" = "restart" ]; then
sslocal -c /etc/shadowsocks.json -d stop
sslocal -c /etc/shadowsocks.json -d start
else
echo "Invalid argument. Please provide 'start', 'stop', or 'restart'."
exit 1
fi
赋予脚本权限
chmod +x ss_script.sh
启动脚本
./ss_script.sh start
停止脚本
./ss_script.sh stop
重启脚本
./ss_script.sh restart
4.privoxy配置
安装privoxy
apt-get install privoxy
编辑文件
vim /etc/privoxy/config
forward-socks5 / 127.0.0.1:1080 . ##新增该行
重启服务
systemctl restart privoxy
5.配置环境变量
vim ~/.bashrc
export http_proxy=http://127.0.0.1:8118/
export https_proxy=https://127.0.0.1:8118/
source ~/.bashrc
6.本地测试,有数据返回说明代理成功
curl www.google.com
ubuntu22.04使用shadowsocks配置全局代理
http://example.com/2023/06/08/shadowsocks/