610 字
2 分钟
Ubuntu系统设置终端、Docker、CasaOS代理
配置桌面代理(图形化窗口):
Ubuntu20版本安装clash-verge
1.手机挂代理访问github.com/clash-verge-rev/clash-verge-rev下载1.6.5appimage版本的文件,然后通过QQ上传到Ubuntu系统的下载目录。
2.下载FUSE工具库,才能挂载appimage格式软件
sudo apt updatesudo apt install libfuse23.手动运行软件包
进入下载目录
cd ~/下载赋予执行权限
chmod +x clash-verge_1.6.5_amd64.AppImage运行程序
./clash-verge_1.6.5_amd64.AppImage配置终端代理:
设置终端环境变量(核心步骤)
临时生效(推荐调试用)
export https_proxy=http://127.0.0.1:7890export http_proxy=http://127.0.0.1:7890export all_proxy=socks5://127.0.0.1:7890永久生效(远程控制必备)
修改~/.bashrc 文件:
nano ~/.bashrc终端重新读取.bashrc 文件
source ~/.bashrc文件末尾添加“开关”函数,可以随时开启或关闭代理:
# 代理开关功能alias proxy_on='export https_proxy=http://127.0.0.1:7890; export http_proxy=http://127.0.0.1:7890; export all_proxy=socks5://127.0.0.1:7890; echo "Proxy ON"'alias proxy_off='unset https_proxy; unset http_proxy; unset all_proxy; echo "Proxy OFF"'终端开启代理:
proxy_on终端关闭代理:
proxy_off测试代理有没有开启
1.测试连接 Google(返回 HTTP 状态码)
curl -I https://www.google.com2.查询当前终端的出口 IP
curl ifconfig.meClash内核安装:
1.下载并安装核心 (Mihomo/Clash Meta)
确认架构, 下载“兼容性加强版” (Compatible),这个版本去掉了所有高级优化,只保留最核心的运行能力:
# 以 x86_64 为例wget -O mihomo.gz https://github.com/MetaCubeX/mihomo/releases/download/v1.18.10/mihomo-linux-amd64-compatible-v1.18.10.gz解压并安装在/usr/local/bin/clash,在任何地方输入clash都可以启动,不需要切换目录:
gunzip mihomo.gzchmod +x mihomosudo mv mihomo /usr/local/bin/clash2.准备配置文件
使用Sublink Worker将机场订阅链接转换为Clash链接(Clash配置下载地址)
进入配置文件目录,停止旧服务,下载并覆盖配置,重启服务(/usr/local/bin/clash目录为 Clash 内核本地文件):
cd /home/pingzi/mihomo && \sudo systemctl stop clash && \wget -O config.yaml "https://sub.333797.xyz/clash?config=vless%3A%2F%2F7df6f9cc-f776-499c-ba40-0d7b07b123f2%40ooo.6990699.xyz%3A44380%3Ftype%3Dws%26encryption%3Dnone%26path%3D%252F%26host%3D%26security%3Dtls%26fp%3Dchrome%26alpn%3D%23vless-rxxbdvwn&ua=&selectedRules=%5B%22Location%3ACN%22%2C%22Private%22%2C%22Non-China%22%2C%22Github%22%2C%22Google%22%2C%22Youtube%22%2C%22AI+Services%22%2C%22Telegram%22%5D&customRules=%5B%5D" && \sudo systemctl restart clash检查配置文件内容(比如是否出现了 proxies: 或 proxy-groups: 关键词)
head -n 20 config.yaml检查配置文件节点信息:
grep "name:" config.yaml | head -n 103.启动(clash 会自动去 /usr/local/bin 找程序,而 -d . 告诉它使用当前目录下的 config.yaml):
clash -d .4.查看clash内核有没有在运行:
sudo systemctl status clash5.设置clash开机自启动:
创建服务文件:
sudo nano /etc/systemd/system/clash.service添加一下服务文件内容:
[Unit]Description=Clash Meta DaemonAfter=network.target
[Service]Type=simpleUser=pingziExecStart=/usr/local/bin/clash -d /home/pingzi/mihomoRestart=always
[Install]WantedBy=multi-user.target启动并设置自启:
sudo systemctl daemon-reloadsudo systemctl enable clashsudo systemctl start clash配置CasaOS服务代理:
1.注入代理环境变量
sudo systemctl edit casaos[Service]Environment="HTTP_PROXY=http://127.0.0.1:7890"Environment="HTTPS_PROXY=http://127.0.0.1:7890"2.重启服务:(系统重新加载所有服务的配置文件、立即重启 CasaOS 服务)
sudo systemctl daemon-reloadsudo systemctl restart casaos配置Docker服务代理:
1.创建 Docker 服务代理目录
sudo mkdir -p /etc/systemd/system/docker.service.d
2.创建并编辑配置文件
sudo nano /etc/systemd/system/docker.service.d/http-proxy.conf
3.粘贴代理配置
[Service]Environment="HTTP_PROXY=http://127.0.0.1:7890"Environment="HTTPS_PROXY=http://127.0.0.1:7890"Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"4.刷新配置并重启 Docker
# 重新加载系统服务配置sudo systemctl daemon-reload
# 重启 Docker 服务sudo systemctl restart docker5.验证是否生效
sudo docker info | grep Proxy 分享
如果这篇文章对你有帮助,欢迎分享给更多人!
部分信息可能已经过时
相关文章 智能推荐










