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 端

相关推荐
九丝城主1 天前
2025使用VM虚拟机安装配置Macos苹果系统下Flutter开发环境保姆级教程--上篇
服务器·flutter·macos·vmware
芳草萋萋鹦鹉洲哦1 天前
【vue3+tauri+rust】如何实现下载文件mac+windows
windows·macos·rust
梅名智2 天前
IOS 蓝牙连接
macos·ios·cocoa
帅次2 天前
Objective-C面向对象编程:类、对象、方法详解(保姆级教程)
flutter·macos·ios·objective-c·iphone·swift·safari
fengyun28912 天前
fcpx音视频剪辑编辑 Final Cut Pro X(Mac电脑)
macos·mac
fengyun28912 天前
Mac电脑 卸载工具 App Cleaner
macos
aerror3 天前
Xbox One 控制器转换为 macOS HID 设备的工作原理分析
macos·xbox
晴风向上3 天前
mac mini m4安装node.js@16以下版本方法
macos·node.js
JPCstorm3 天前
Mac homebrew 安装教程
macos
秋窗73 天前
Mac 部署Latex OCR并优化体验(打包成App并支持全局快捷键)
macos·ocr·latex