最近在更新Raspberry Pi的时候发现下载631Mb内容预估时间需要10个小时,再看下载速度只有几Kb,遂准备用SSR来加速下载。
环境
- raspberrypi 9
- root login(如何获取root权限)
- SSR节点(获取SSR)
将SSR下载至根目录
1 |
git clone https://github.com/shadowsocksr-backup/shadowsocksr.git |
并初始化 bash ~/shadowsocksr/initcfg.sh
或者从其他地方拷贝一份过来
1 |
scp -r root@gcp.minirplus.com:/root/shadowsocksr /root/shadowsocksr |
配置
编辑配置文件 nano ~/shadowsocksr/user-config.json,节点信息可以在客户端节点配置里获得
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
{ "server": "your-server-domain", //服务器节点域名,在节点配置获得 "server_ipv6": "::", "server_port": your-service-port, //SSR服务端口,客户端添加订阅后在节点信息中获得 "local_address": "127.0.0.1", "local_port": 1080, "password": "your-service-pass", //客户端添加订阅后在节点信息中获得 "method": "aes-256-cfb", "protocol": "auth_aes128_sha1", "protocol_param": "your-service-param", //必填,客户端添加订阅后在节点信息中获得 "obfs": "tls1.2_ticket_auth", "obfs_param": "", "speed_limit_per_con": 0, "speed_limit_per_user": 0, "additional_ports" : {}, // only works under multi-user mode "additional_ports_only" : false, // only works under multi-user mode "timeout": 120, "udp_timeout": 60, "dns_ipv6": false, "connect_verbose_info": 1, "redirect": "", "fast_open": false } |
运行SSR
1 |
python ~/shadowsocksr/shadowsocks/local.py -c ~/shadowsocksr/user-config.json |
测试SSR
1 |
curl -x socks5://127.0.0.1:1080 https://ipapi.co/json/ |
安装Privoxy
1 |
apt install privoxy |
配置转发
1 2 3 4 5 6 |
# 添加本地ssr服务到配置文件 echo 'forward-socks5 / 127.0.0.1:1080 .' >> /etc/privoxy/config # 可选,修改监听端口 nano /etc/privoxy/config listen-address 127.0.0.1:8089 listen-address [::1]:8089 |
运行Privoxy
1 2 3 4 |
service privoxy start service privoxy stop service privoxy restart start|stop|rotate|restart|force-reload|status |
配置全局代理
永久有效
注意:重启后如果SSR服务没有运行,那么shell命令将无法进行联网操作,建议将SSR服务加入开机自启动
1 2 3 |
/etc/profile export http_proxy=http://127.0.0.1:8089 export https_proxy=http://127.0.0.1:8089 |
应用配置
1 |
source /etc/profile |
当前 session 临时有效
1 2 |
export http_proxy=http://127.0.0.1:8089 export https_proxy=http://127.0.0.1:8089 |
测试Privoxy
1 |
curl https://ipapi.co/json/ |
返回SSR主机IP而非本地IP说明配置完成
配置后台运行
1 2 3 |
python ~/shadowsocksr/shadowsocks/local.py -c ~/shadowsocksr/user-config.json -d start python ~/shadowsocksr/shadowsocks/local.py -c ~/shadowsocksr/user-config.json -d stop python ~/shadowsocksr/shadowsocks/local.py -c ~/shadowsocksr/user-config.json -d restart |
日志
1 |
tail -f /var/log/shadowsocksr.log |
将SSR服务加入开机自启动
1 |
nano /etc/rc.local |
如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # start the ssr service /usr/bin/python /root/shadowsocksr/shadowsocks/local.py -c /root/shadowsocksr/user-config.json -d start # Print the IP address _IP=$(hostname -I) || true if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi exit 0 |
总结
设置好之后apt upgrade从10个小时降到了10分钟
There are no comments yet