最终一键脚本:ssc-1key-linux
系统: Ubuntu 22.04
shadowsocks相关
- 将系统更新到最新版
- 安装shadowsocks及必要组件
pip install https://github.com/shadowsocks/shadowsocks/archive/master.zip -U
sudo apt-get install -y libsodium* - 配置shadowsocks client
sudo vi /etc/shadowsocks.json
{
"server": "您服务器地址",
"server_port": 9999,
"local_address": "127.0.0.1",
"local_port": 1080,
"password": "密码",
"timeout": 600,
"method": "aes-256-cfb"
}
-
解决sodium库问题
sudo ln -s /usr/lib/x86_64-linux-gnu/libsodium.a /usr/lib/x86_64-linux-gnu/liblibsodium.a -
设置路径权限
sudo chmod 777 /var/log
sudo chmod 777 /var/run -
shadowsocks 开机自启动
sudo vim /etc/systemd/system/shadowsocks.service:Description=Shadowsocks Client Service After=network.target [Service] Type=simple User=root ExecStart=/usr/local/bin/sslocal -c /etc/shadowsocks.json restart [Install] WantedBy=multi-user.target
systemctl enable shadowsocks.service
HTTP全局代理
实现全局代理,我们可以使用polipo
-
polipo 安装
wget http://archive.ubuntu.com/ubuntu/pool/universe/p/polipo/polipo_1.1.1-8_amd64.deb
安装sudo dpkg -i polipo_1.1.1-8_amd64.deb
配置vi /etc/polipo/config
logSyslog = true logFile = /var/log/polipo/polipo.log proxyAddress = "0.0.0.0" socksParentProxy = "127.0.0.1:1080" socksProxyType = socks5 chunkHighMark = 50331648 objectHighMark = 16384 serverMaxSlots = 64 serverSlots = 16 serverSlots1 = 32
polipo安装后会自动运行。
-
通过polipo设置本地http代理
export http_proxy=http://127.0.0.1:8123 export https_proxy=http://127.0.0.1:8123
取消代理
unset http_proxy
unset https_proxy
pac代理
如果想使用http下的pac机制,可以考虑用provoxy替换polipo
-
provoxy 安装
安装:sudo apt-get install -y privoxy
cp /etc/privoxy/config /etc/privoxy/config.bak
vim /etc/privoxy/config
确保listen-address 127.0.0.1:8118
打开
在/etc/profile, ~/.bashrc,~/.bash_profile 中添加:proxy="http://127.0.0.1:8118" export https_proxy=$proxy export http_proxy=$proxy export ftp_proxy=$proxy
systemctl enable privoxy
systemctl restart privoxy -
GFWList2Privoxy 制作pac条目
pip install gfwlist2privoxy
添加自定义域名:在生成的gfwlist.action文件中添加需要通过proxy访问的域名
使pac生效:在/etc/privoxy/config文件中加上actionsfile gfwlist.action,然后重启privoxy服务
issue shooting:
- AttributeError: module 'collections' has no attribute 'MutableMapping'
解决:/home/zcj/.local/lib/python3.10/site-packages/shadowsocks/lru_cache.py
34行MutableMapping
前面加上abc.
- [Errno 2] No such file or directory: b'liblibsodium.a'
解决:sudo ln -s /usr/lib/x86_64-linux-gnu/libsodium.a /usr/lib/x86_64-linux-gnu/liblibsodium.a