Linux 服务器使用 mihomo 代理经验
1. 推荐:使用 SSH 端口转发,转发本地 socks5 端口
推荐方法,更安全,更方便
跑如下命令建立 ssh 端口转发,将本地的 7890 端口(mihomo http/socks5 代理端口)转发到服务器上
ssh -R 7890:localhost:7890 username@your-server-address
在服务器上设置命令行代理:
source enable-proxy.sh
,如下:
echo Tips:请使用source执行本脚本以修改父shell的变量
HTTP_PROXY_URL=http://127.0.0.1:7890
SOCK5_PROXY_URL=socks5://127.0.0.1:7890
PROXY_BYPASS=192.168..,172.16..,.local,localhost,127.0.0.1
# 配置http和https代理
export http_proxy=${HTTP_PROXY_URL}
export https_proxy=${HTTP_PROXY_URL}
export all_proxy=${SOCK5_PROXY_URL}
export no_proxy=${PROXY_BYPASS}
# ftp代理看需求配置
# export ftp_proxy= http_proxy
# 设置git代理
git config --global https.proxy ${HTTP_PROXY_URL}
git config --global http.proxy ${HTTP_PROXY_URL}
如果 shell 环境设置的代理不能满足要求,可以进一步尝试使用 tproxy/tun2socks 截获并转发流量至 socks5 端口
2. 不推荐:直接在服务器运行 mihomo 内核
⚠此方法仅供备用,存在代理服务被检测的可能性,后果自担
从 github 仓库下载 mihomo 的 deb 包,使用
dpkg -i
安装手动下载 geoip & geosite & country.mmdb 这几个数据库,放到
/etc/mihomo
下载面板前端页面(比如
metacubexd/yacd
仓库的gh-pages
分支)并放到/etc/mihomo/ui/
git clone https://github.com/metacubex/metacubexd.git -b gh-pages /etc/mihomo/ui --depth=1
将 mihomo 配置文件上传到服务器上并放入
/etc/mihomo
,配置文件中修改external-controller: 0.0.0.0:9090
,设置secrets
,增加external-ui: /etc/mihomo/ui
执行
systemctl start mihomo
启动 mihomo 服务浏览器打开
http://<ip>/ui/
使用面板进行管理设置命令行代理:
source enable-proxy.sh
,如下:
echo Tips:请使用source执行本脚本以修改父shell的变量
HTTP_PROXY_URL=http://127.0.0.1:7890
SOCK5_PROXY_URL=socks5://127.0.0.1:7890
PROXY_BYPASS=192.168..,172.16..,.local,localhost,127.0.0.1
# 配置http和https代理
export http_proxy=${HTTP_PROXY_URL}
export https_proxy=${HTTP_PROXY_URL}
export all_proxy=${SOCK5_PROXY_URL}
export no_proxy=${PROXY_BYPASS}
# ftp代理看需求配置
# export ftp_proxy= http_proxy
# 设置git代理
git config --global https.proxy ${HTTP_PROXY_URL}
git config --global http.proxy ${HTTP_PROXY_URL}
如果 shell 代理无法满足要求,可以在 mihomo 配置文件中打开 tun,使用原生的 tun 模块来拦截处理所有流量
Linux 服务器使用 mihomo 代理经验
https://blog.openyq.top/posts/50255/