我的代理服务器的地址是 127.0.0.1
,HTTP 端口 12333
,本地监听端口 1080
。
ProxyChains
代理工具 ProxyChains 可以让任意有缘分的程序使用代理,配置一次,省心一生。如果这个能解决问题,就不用看后面的了。
1
2
3
4
5
6
7
8
9
|
# 安装
sudo apt install proxychains4
# 创建配置文件
mkdir ~/.proxychains
cp /etc/proxychains4.conf ~/.proxychains/proxychains.conf
# 编辑配置文件
nano ~/.proxychains/proxychains.conf
|
滚到文档最后面,把 socks4 127.0.0.1 9050
改为 socks5 127.0.0.1 1080
,保存。现在在命令前加上 proxychains
就可以使用代理了,例如:
1
|
proxychains curl -I https://www.google.com
|
终端
1
2
3
4
5
6
7
8
|
# 设置代理
export http_proxy="http://127.0.0.1:12333" https_proxy="http://127.0.0.1:12333"
# 检查代理
echo $http_proxy $https_proxy
# 取消代理
unset http_proxy https_proxy
|
APT
1
2
3
4
5
6
7
8
|
# 方法 1
export http_proxy="http://127.0.0.1:12333"
sudo -E apt update # -E, --preserve-env(preserve user environment when running command)
sudo -E apt upgrade
# 方法 2
sudo http_proxy=http://127.0.0.1:12333 apt update
sudo http_proxy=http://127.0.0.1:12333 apt upgrade
|
Git
SSH
新建 ~/.ssh/config
,把以下内容复制进去(端口请按实际情况填写):
1
2
3
|
Host github.com
User git
ProxyCommand nc -x localhost:1080 %h %p
|
HTTP/HTTPS
有两个方法可以让 Git 的 HTTP/HTTPS 流量使用代理,选择其中一个即可。
环境变量
1
2
3
4
5
6
7
8
|
# 设置变量
export http_proxy=socks5://localhost:1080 https_proxy=socks5://localhost:1080
# 检查变量
echo $http_proxy $https_proxy
# 取消变量
unset http_proxy https_proxy
|
git config
1
2
3
4
5
6
7
8
9
|
# 设置代理
git config --global http.proxy socks5://localhost:1080
git config --global https.proxy socks5://localhost:1080
# 检查代理
git config --global http.proxy; git config --global https.proxy
# 取消代理
git config --global --unset http.proxy; git config --global --unset https.proxy
|
参考资料
浏览器
浏览器使用 SwitchyOmega 设置代理,下载地址:Chrome 商店、Edge 商店、GitHub。
设置步骤:
- 点击
Options -> New profile -> Proxy Profile
- 填写
Profile name=ssr
- 点击
Create
- 填写配置
Protocol=HTTP、Server=127.0.0.1、Port=12333
- 点击
Apply changes
现在切换到 ssr 档案就可以使用代理了。另外,SwitchyOmega 可以使用白名单和黑名单规则。
Thunderbird
- 点击右上角的菜单图标(三条横线)
- 点击
Preferences
- 搜索
proxy
- 点击
Settings
- 填写
HTTP Proxy=127.0.0.1、Port=12333
- 勾选
Also use this proxy for HTTPS
- 点击
OK
文章作者
叶寻
上次更新
2021-04-18
(6567648)
许可协议
CC BY-NC-SA 4.0