![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLi0zaHRGcWdUYuVzVa9GczoVdG1mWfVGc5RHLwkzX39GZhh2csATMflHLwEzX4xSZz91ZsADMx8FdsYkRGZkRG9lcvx2bjxSa2EWNhJTW1AlUxEFeVRUUfRHelRHL2EzXlpXazxyayFWbyVGdhd3LcV2Zh1Wa9M3clN2byBXLzN3btg3PnVGcq5iMxY2N3kjZkZWZ2EzY4IzYiZ2YkFmYyYjZjFGOlNjY58CXzIzLcdDMxIDMy8CXn9Gbi9CXzV2Zh1WavwVbvNmLvR3YxUjLzM3Lc9CX6MHc0RHaiojIsJye.jpeg)
最终效果: 自动判断国内国外网站, 自动分流
安装ss3.0上网:
sudo apt-get install python-pipsudo apt install libsodium-devsudo pip install https://www.v2fy.com/asset/ubuntu1804/shadowsocks-master.zip
配置文件/etc/shadowsocks.json (格式是对的,但password是假的)
{ "server": "sz-vip1.0oxq7.site", "server_port": 50402, "local_port": 1080, "password": "Bm0079E", "method": "chacha20-ietf-poly1305"}
启动ss
sudo sslocal -c /etc/shadowsocks.json // 前台启动sudo sslocal -c /etc/shadowsocks.json -d start // 后台启动sudo sslocal -c /etc/shadowsocks.json -d stop // 后台停止
创建root管理员账户
sudo passwd root
在/etc/systemd/system 新建shadowsocks.service, 权限777
touch /etc/systemd/system/shadowsocks.servicechmod 777 /etc/systemd/system/shadowsocks.service
在/etc/systemd/system/shadowsocks.service下写入以下内容
[Unit]Description=Shadowsocks Client ServiceAfter=network.targetAfter=network-online.target
[Service]#Type=simpleType=forkingUser=rootExecStart=/usr/local/bin/sslocal -c /etc/shadowsocks.json -d start
[Install]WantedBy=multi-user.target
将ss转为开机启动服务
systemctl enable shadowsocks.service
开启服务
systemctl start shadowsocks.service
关闭服务
systemctl start shadowsocks.service
查看服务状态
systemctl status shadowsocks.service
重启服务
systemctl restart shadowsocks.service
参考资料: https://unix.stackexchange.com/questions/303022/systemd-exec-format-error
socks转为http
sudo apt install privoxy
编辑privoxy配置文件
# 进入目录cd /etc/privoxy/# 备份cp config config_before# 开始编辑sudo vim /etc/privoxy/config
在/etc/privoxy/config里面填入,可以将1080端口开启的sock5服务,转换到8118端口的http服务
listen-address 0.0.0.0:8118forward-socks5 / 127.0.0.1:1080 .
设置开机启动
systemctl enable privoxy.service
启动privoxy
systemctl start privoxy.service
安装genpac (省流量)
# 安装 genpacsudo pip install genpacsudo pip install --upgrade genpac# 创建目录sudo mkdir -p ~/soft/pac# 进入目录cd ~/soft/pacsudo touch user-rules.txtchmod 777 user-rules.txt# 生成pac文件sudo genpac --pac-proxy "SOCKS5 127.0.0.1:1080" --output="autoproxy.pac" --gfwlist-url="https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt" --user-rule-from="user-rules.txt"
安装nginx
sudo apt install nginxsudo touch /etc/nginx/conf.d/shadowsocks.conf
在/etc/nginx/conf.d/shadowsocks.conf中添加以下内容
server{ listen 80; #注意这里不用":"隔开,listen后面没有冒号 server_name 127.0.0.1; #注意这里不用":"隔开,server_name后面没有冒号 location /autoproxy.pac { alias /home/zhaoolee/soft/pac/autoproxy.pac; }}
在/etc/nginx/mime.types 添加pac后缀解析为text格式
text/plain pac;
在浏览器中查看
nginx 设置开机自启动
systemctl enable nginx
在网络中设置
http://127.0.0.1/autoproxy.pac
打开浏览器可以查看各种网站了
本篇文章 好看 破10, 一天内出一期ubuntu18.04美化的教程