Ubuntu18.04上网折腾记录

最终效果: 自动判断国内国外网站, 自动分流

安装ss3.0上网:

sudo apt-get install python-pip
sudo apt install libsodium-dev
sudo 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.service
chmod  777 /etc/systemd/system/shadowsocks.service

/etc/systemd/system/shadowsocks.service下写入以下内容

[Unit]
Description=Shadowsocks Client Service
After=network.target
After=network-online.target

[Service]
#Type=simple
Type=forking
User=root
ExecStart=/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:8118
forward-socks5 / 127.0.0.1:1080 .

设置开机启动

systemctl enable privoxy.service

启动privoxy

systemctl start privoxy.service

安装genpac (省流量)

# 安装 genpac
sudo pip install genpac
sudo  install --upgrade genpac
# 创建目录
sudo mkdir -p ~/soft/pac
# 进入目录
cd  ~/soft/pac
sudo touch user-rules.txt
chmod 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 nginx
sudo 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美化的教程

本文永久更新地址: https://www.v2fy.com/p/ubuntu1804/