使用国内服务器经常会遇到下载国外源 速度非常慢 有没有什么办法使用代理来下载呢?
v2ray ssr ss 都默认监听1080端口 其实都可以使用 socks5
以v2为例子
首先下载v2ray 到服务器
(服务端和客户端其实是一个程序区别在于配置文件)
# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
然后配置Config.json
(也可以使用windows的配置文件)
{
"inbounds": [
{
"port": 1080,
"listen": "127.0.0.1",
"protocol": "socks",
"sniffing": {
"enabled": true,
"destOverride": ["http", "tls"]
},
"settings": {
"auth": "noauth",
"udp": false
}
}
],
"outbounds": [
{
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "mydomain.me",
"port": 443,
"users": [
{
"id": "b831381d-6324-4d53-ad4f-8cda48b30811",
"alterId": 64
}
]
}
]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"wsSettings": {
"path": "/ray"
}
}
}
]
}
之后启动v2ray
手动启动:
在 Windows 和 macOS 中,配置文件通常是 V2Ray 同目录下的 config.json 文件。直接运行 v2ray 或 v2ray.exe 即可。
在 Linux 中,配置文件通常位于 /etc/v2ray/config.json
文件。运行 v2ray --config=/etc/v2ray/config.json
,或使用 systemd
等工具把 V2Ray 作为服务在后台运行。
自动脚本:
此脚本会配置自动运行脚本。自动运行脚本会在系统重启之后,自动运行 V2Ray。目前自动运行脚本只支持带有 Systemd 的系统,以及 Debian / Ubuntu 全系列。
运行脚本位于系统的以下位置:
  /etc/systemd/system/v2ray.service: Systemd
  /etc/init.d/v2ray: SysV
脚本运行完成后,你需要:
编辑 /etc/v2ray/config.json
文件来配置你需要的代理方式;
运行 service v2ray start
来启动 V2Ray 进程;
之后可以使用 service v2ray start|stop|status|reload|restart|force-reload
控制 V2Ray 的运行。
socks5代理
1.命令行代理神器 proxychains
目前支持的平台主要是 Linux 和 Mac
安装前准备(本文使用的centos7系统)
# yum -y install git
# yum -y install gcc automake autoconf libtool make
下载git库
# git clone https://github.com/rofl0r/proxychains-ng.git
打开文件
# cd proxychains-ng
./configure
编译安装
# make && sudo make install
复制配置文件
# cp ./src/proxychains.conf /etc/proxychains.conf
删除安装文件
# cd .. && rm -rf proxychains-ng
编辑配置文件
# vi /etc/proxychains.conf
把最后面的
  socks4 127.0.0.1 1080
改成v2ray的socks5端口
  socks5 127.0.0.1 10808
之后运行命令前加上 proxychains4
就可以使用代理了
测试一下是不是显示代理ip了
# proxychains4 curl ifconfig.io
2.privoxy 全局代理
Linux貌似默认不支持直接使用socks代理,使用privoxy将socks5转换为http代理安装
当然你也可以测试一下你的系统是否支持
直接运行以下环境变量 是否会出错 如果成功 恭喜你不用往下看了:)
# export http_proxy="socks5://127.0.0.1:10808"
# export https_proxy="socks5://127.0.0.1:10808"
失败了就来安装privoxy 吧
# yum install -y privoxy
配置privoxy
# vim /etc/privoxy/config
在末尾增加下面内容,/后面是代理服务器的地址:端口,注意最后还有个. 点
forward-socks5t / x.x.x.x:10808 .
启动服务
# systemctl start privoxy
设置一下系统代理变量(8118是privoxy默认使用的端口)
# export http_proxy=http://127.0.0.1:8118
# export https_proxy=http://127.0.0.1:8118
测试一下是不是显示代理ip了
#curl ifconfig.io
取消代理 断开当前会话自动失效
也可以使用命令临时取消
unset http_proxy
unset https_proxy
ps:这种环境配置之后大部分软件会读取变量值,然后走代理。但不是所有的软件都这样。例如git就不走需要单独设置
git config --global http_proxy http://127.0.0.1:8118
git config --global https_proxy http://127.0.0.1:8118
谢谢
By greg at May 1st, 2022 at 08:13 am.
@greg
不客气,能帮到你我很高兴
By 舒歌 at June 27th, 2022 at 04:16 pm.