macOS 上使用 Homebrew 安装和配置 frp 客户端

macOS 上使用 Homebrew 安装和配置 frp 客户端 (frpc) 指南

frp (Fast Reverse Proxy) 是一款高性能的反向代理应用,常用于内网穿透。本文将介绍在 macOS 上使用 Homebrew 安装 frpc,并进行配置和管理。


一、安装 frpc

使用 Homebrew 安装(推荐)

  1. 确保已安装 Homebrew

  2. 给终端中执行:

    bash 复制代码
    brew install frpc

安装完成后,frpc 可执行文件通常位于:

  • M1/M2 系列芯片:/opt/homebrew/bin/frpc
  • Intel 版 mac:/usr/local/bin/frpc

二、配置 frpc

创建配置文件

  1. 创建配置文件目录:

    bash 复制代码
    sudo mkdir -p /opt/homebrew/etc/frp
  2. 创建并编辑 frpc.toml

    bash 复制代码
    sudo nano /opt/homebrew/etc/frp/frpc.toml
  3. 配置示例:

    toml 复制代码
     # 公共配置
     serverAddr = "阿里云服务器公网IP"
     serverPort = 7000
     auth.method = "token"
     auth.token = "你的token"
     
     # Gitea 服务转发
     [[proxies]]
     name = "Gitea"
     type = "tcp"
     localIP = "127.0.0.1"
     localPort = 3000            # Gitea 在群晖上的端口
     remotePort = 3000           # 阿里云上的访问端口
     
     # GitLab 服务转发
     [[proxies]]
     name = "GitLab"
     type = "tcp"
     localIP = "127.0.0.1"
     localPort = 8888            # GitLab 在群晖上的端口
     remotePort = 8888           # 阿里云上的访问端口

注意:不要在 serverAddr 前加 http:// 或 https://


三、启动和关闭 frpc

启动 frpc

bash 复制代码
/opt/homebrew/bin/frpc -c /opt/homebrew/etc/frp/frpc.toml

如果配置正确,将看到例如下面的输出:

复制代码
[I] [service.go:288] login to server success, get run id [xxxxxxx]

关闭 frpc

bash 复制代码
pkill frpc

四、设置开机自启动

使用 Homebrew Services

  1. 先确保已安装 services 接口:

    bash 复制代码
    brew tap homebrew/services
  2. 启动 frpc 服务:

    bash 复制代码
    brew services start frpc

    默认会使用 /opt/homebrew/etc/frp/frpc.toml

  3. 停止 frpc 服务:

    bash 复制代码
    brew services stop frpc

五、查看日志

bash 复制代码
tail -f /opt/homebrew/var/log/frpc.log

附录:常见配置错误

错误示例:

复制代码
parse "http://[http://47.97.xx.xx]:7000": missing ']' in host

原因: serverAddr 中包含了 http:// 前缀

解决: 不要加 http://,直接写 IP 或域名


附录:推荐的 GUI 端

相关推荐
witton3 小时前
MacOS中在目录或者文件右键菜单中添加“使用VSCode打开”
vscode·macos·文件·目录·服务·automator·右键菜单
山外有山a3 小时前
【实战】M系列芯片Mac本地部署Qwen2.5:Ollama + Open WebUI 全流程与3个关键优化参数
macos
思盛iOS签名上架19 小时前
App苹果签名有什么作用?
macos·ios·cocoa
MartinYeung51 天前
[论文学习]MAC:多智能体宪章学习
人工智能·学习·macos
greasyfork1 天前
Mac Sketch v2026.3 矢量图设计工具
macos·ui·sketch
无定义_1 天前
萌新联赛(六)
macos·objective-c·cocoa
风安•辛幸2 天前
mac上微信最新v4以上版客户端多开教程,亲测可用
macos·微信
weixin_531670892 天前
Interlude起来:动作动画和文字通知哪个更适合休息提醒?Mac上有没有用桌宠做动作引导的软件?
人工智能·macos·mac·swift
FairGuard手游加固2 天前
iOS 游戏加固技术解析:代码混淆、资源加密、内存保护与重签名检测
安全·游戏·macos·unity·ios·objective-c
思盛iOS签名上架2 天前
iOS企业签名原理是什么?
macos·ios·cocoa