clash 安装
1.下载对应版本的安装包:https://github.com/lantongxue/clash_for_windows_pkg/releases
2.解压后在同级目录下载配置文件:
curl -o config.yaml 'your profiles'
3.在external-controller: :9090下一行加上secret: 自己设置密钥
4.如果你的网络有公网IP,再加上
authentication: # authentication of local SOCKS5/HTTP(S) server
- "用户名:复杂点的密码"
之后所有http://ip:port
改为http://username:password@ip:port
其中特殊符号需要html编码
5.权限设置:chmod +x clash
6.执行 ./clash -d
. 即可启动 Clash,同时启动 HTTP 代理和 Socks5 代理。
7.如果提示Can't download MMDB, wget https://github.com/Dreamacro/maxmind-geoip/releases/download/20240112/Country.mmdb
8.公共clash dashboard
全局网络代理设置
在/etc/profile.d/proxy.sh
export proxy_ip=127.0.0.1
export http_proxy=http://$proxy_ip:7890
export https_proxy=http://$proxy_ip:7890
export HTTP_PROXY=http://$proxy_ip:7890
export HTTPS_PROXY=http://$proxy_ip:7890
export no_proxy=localhost,127.0.0.1,10.96.0.0/12,192.168.0.1/16,192.168.49.2
export NO_PROXY=localhost,127.0.0.1,10.96.0.0/12,192.168.0.1/16,192.168.49.2
# terminal
#export all_proxy=socks5://127.0.0.1:7891
有时需要设置git
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy https://127.0.0.1:7890
激活设置并查看
source /etc/profile.d/proxy.sh
#查看环境变量进行确认是否生效
env | grep -i proxy
取消设置:
unset proxy
git config --global --unset http.proxy
apt-get代理设置
在/etc/apt/apt.conf.d/apt.conf下
Acquire::http::Proxy "http://127.0.0.1:7890";
Acquire::https::proxy "http://127.0.0.1:7890";
#Acquire::ftp::proxy "ftp://127.0.0.1:7890";
# 如果你的代理需要登陆, 那么将url改为:
# "http://username:password@yourproxyaddress:proxyport";
socks代理配置
对于某些应用程序是无法使用HTTP代理的,这时候,需要设置socket代理, Linux命令行并没有直接设置的方法,需要在系统设置里设置,如果用的软件是cfw,则设置为127.0.0.1:7890.但不是很推荐设置系统里的socks代理,只设置终端就够了.
# terminal
export all_proxy=socks5://127.0.0.1:7890
git ssh端口代理
这里还列出git的原因是, 有时候, 并不通过htps拉取和上传代码, 设置的是SSH端口的仓库链接, 这时候代理就完全没用了, 需要额外设置.
编辑~/.ssh/config
, 然后基本应该没得问题了~ 就再不会因为连接超时报错:kex_exchange_identification: Connection closed by remote host fatal: Could not read from remote repository.
Host github.com
ProxyCommand nc -X connect -x 127.0.0.1:7890 %h %p
ServerAliveInterval 10
用Windows的同学就发现了,模仿上面的内容是没用的,上面只是为Linux和Mac os准备,windows用户需要这样设置:
注意: GIT_PATH和username请务必替换为自己的,不要把方框和变量名也照抄了
安装好git,并记录好git的安装目录: 用变量
GIT_PATH
指代找到ssh的配置文件:
c:\Users\[username]\.ssh\config
Host github.com
ProxyCommand "[GIT_PATH]\mingw64\bin\connect.exe" -S 127.0.0.1:7890 %h %p
ServerAliveInterval 10
Docker代理配置
一般不需要设置,采取本地制作镜像再上传服务器的方式可以应对绝大多数情况,如有需要参考https://docs.docker.com/engine/cli/proxy/
docker pull代理需单独设置:
/etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"
systemctl daemon-reload
systemctl restart docker
评论区