Blog

1. 安装v2ray服务

wget https://obsbot-script.oss-cn-shenzhen.aliyuncs.com/software/VPN/linux/v2raya.deb

dpkg -i v2raya.deb

systemctl start v2raya
systemctl enable v2raya
systemctl status v2raya

《ubuntu配置v2ray代理》文章正文配图 — STARBUCKET BLOG

2. 在控制台导入代理配置

《ubuntu配置v2ray代理》文章正文配图(配图 2)— STARBUCKET BLOG

把订阅链接复制进去,点击确认 《ubuntu配置v2ray代理》文章正文配图(配图 3)— STARBUCKET BLOG

导入成功后,server里面会显示代理信息 《ubuntu配置v2ray代理》文章正文配图(配图 4)— STARBUCKET BLOG

添加到PROXY,并在左上角启动服务 《ubuntu配置v2ray代理》文章正文配图(配图 5)— STARBUCKET BLOG

3. 设置系统强制走代理网络

sudo tee /etc/profile.d/proxy.sh << 'EOF'
export ALL_PROXY="socks5://127.0.0.1:20170"
export all_proxy="socks5://127.0.0.1:20170"
export http_proxy="http://127.0.0.1:20171"
export https_proxy="http://127.0.0.1:20171"
export HTTP_PROXY="http://127.0.0.1:20171"
export HTTPS_PROXY="http://127.0.0.1:20171"
# 设置成自己的网段
export no_proxy="localhost,127.0.0.1,172.10.10.0/24,172.17.0.0/16,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.aliyuncs.com,.aliyun.com"
export NO_PROXY="$no_proxy"
EOF

sudo chmod +x /etc/profile.d/proxy.sh
source /etc/profile.d/proxy.sh

验证:

curl -I --max-time 15 https://www.google.com
# 或强制指定代理
curl -x http://127.0.0.1:20171 -I --max-time 15 https://www.google.com

4. 设置Docker代理网络

sudo mkdir -p /etc/systemd/system/docker.service.d

sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf << 'EOF'
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:20171"
Environment="HTTPS_PROXY=http://127.0.0.1:20171"
Environment="NO_PROXY=localhost,127.0.0.1,172.10.10.0/24,172.17.0.0/16,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
EOF

sudo systemctl daemon-reload
sudo systemctl restart docker

# 确认已加载
systemctl show docker --property=Environment

5. 在v2ray里面查看日志,确认是否有流量日志产生,如果有就大功告成!

《ubuntu配置v2ray代理》文章正文配图(配图 6)— STARBUCKET BLOG

Comments & discussion

The first comment in each thread opens a topic. Signed-in readers can keep the conversation going under that topic.

No comments yet. Sign in to start a topic.

Start a new topic

Sign in to start a topic or join the discussion.