
最終效果: 自動判斷國内國外網站, 自動分流
安裝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美化的教程