git 阅读 3561
GIT 第19章 linux下配置V2ray作为客户端来访问GitHub

GIT 第19章 linux下配置V2ray作为客户端来访问GitHub

2023-07-19 • lulubin

一、下载安装包

从 https://github.com/v2ray/v2ray-core/releases/tag/v4.28.2 下载 v2ray-linux-64.zip 文件并解压,实际上选择合适自己机器的就行了,这里选用的是最小包解压即用。

二、配置 config.json 文件

因为我们的 v2ray 此时是用来作为客户端工作 所以需要配置节点

节点的配置文件为 config.json

节点文件可以从 v2ray 的 Windows 客户端导出

https://file.lulublog.cn/images/3/2023/07/JsumSYIU2ImY6eIQiGzget56YwQisg.jpg?sign=f3ee1203f3fd1b33ae2766823f22b006&t=6acd0400

前提是我们在 Windows 客户端使用的 v2ray 已经有服务器节点可用;则此操作就是更便捷的为 Linux下的 v2ray 客户端配置服务器节点。

三、运行

切换到文件目录:检查配置文件,成功效果如下

./v2ray -test -config config.json

https://file.lulublog.cn/images/3/2023/07/lE797HE4wdyllQpehll9AvgLAEeh4w.jpg?sign=c5f363848b16f760b90db33129f492bc&t=6acd0400

运行

./v2ray -config config.json

https://file.lulublog.cn/images/3/2023/07/Mqqz6v2L2hqzQXZE20u2UQFV2u2HVP.jpg?sign=1fe3cc5f274251eed763f869e014cae9&t=6acd0400

linux 让进程在后台可靠运行的几种方法:https://lulublog.cn/p/1uqMT2

宝塔可以安装:进程守护管理器

https://file.lulublog.cn/images/3/2025/10/NW9HV5AJEWWblw605a9hBlwGHZ96JA.png?sign=f7b2a36e8257d8e2bcd35a3910f39e7c&t=6acd0400

四、github

socks5 代理

git config --global http.https://github.com.proxy socks5://127.0.0.1:10808
git config --global https.https://github.com.proxy socks5://127.0.0.1:10808

其中的 10808 端口为我们配置文件中配置的端口,每个人的可能都不相同

https://file.lulublog.cn/images/3/2023/07/u0399LAZa7PFF00l093Dua0d0vPcfA.jpg?sign=10e5ccd7e7e5ed64a99a8047fa537b34&t=6acd0400

http 代理

git config --global http.https://github.com.proxy https://127.0.0.1:1080
git config --global https.https://github.com.proxy https://127.0.0.1:1080

取消设置

git config --global --unset http.proxy
git config --global --unset https.proxy

五、配置curl、wget等命令使用代理

5.1、方法一

(推荐)

修改文件“/etc/profile”,在文件结束位置增加如下内容:

# 设置http代理
export http_proxy=socks5://127.0.0.1:10808
# 设置https代理
export https_proxy=socks5://127.0.0.1:10808
# 设置ftp代理
export ftp_proxy=socks5://127.0.0.1:10808
# 17.16.x.x为我们自己的云服务器的内网IP 配置为no_proxy代表内网传输不走代理
export no_proxy="172.16.x.x"

修改重启

source /etc/profile

5.2、方法二

(在当前终端临时生效)

使代理生效

export http_proxy=socks5://127.0.0.1:10808
export https_proxy=socks5://127.0.0.1:10808
export ftp_proxy=socks5://127.0.0.1:10808
export no_proxy="172.16.x.x"

使代理失效

unset http_proxy
unset https_proxy
unset ftp_proxy
unset no_proxy

5.3、方法三

(针对单用户生效)

编辑文件 vim ~/.bashrc 添加以下内容

# set proxy
function setproxy() {
   export http_proxy=socks5://127.0.0.1:10808
   export https_proxy=socks5://127.0.0.1:10808
   export ftp_proxy=socks5://127.0.0.1:10808
   export no_proxy="172.16.x.x"
}
# unset proxy
function unsetproxy() {
   unset http_proxy https_proxy ftp_proxy no_proxy
}

保存退出,执行 source ~/.bashrc ,使得配置立即生效。

在终端执行 setproxy 使代理生效

在终端执行 unsetproxy 使代理生效

打赏

×

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开微信扫一扫,即可进行扫码打赏哦