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 端

相关推荐
degree5202 小时前
全平台轻量浏览器推荐|支持Win/macOS/Linux,极速加载+隐私保护+扩展插件,告别广告与数据追踪!
windows·macos·电脑
冯浩(grow up)9 小时前
macos 安装nodepad++ (教程+安装包+报错后的解决方法)
macos
2501_928094651 天前
Ps 2025 图像编辑 Photoshop(Mac中文)
图像处理·macos·photoshop·ps
Magnetic_h1 天前
【iOS】锁的原理
笔记·学习·macos·ios·objective-c·cocoa·xcode
Cosmoshhhyyy2 天前
mac环境下安装git并配置密钥等
git·macos
肥肥呀呀呀2 天前
mac 安卓模拟器 blueStacks
macos
csdn_aspnet2 天前
如何在 MacOS 上安装 SQL Server
macos·sqlserver
共享家95273 天前
linux-数据链路层
linux·网络·macos
CZIDC4 天前
MacOS字体看起来比在 Windows 上更好?
macos
Cosmoshhhyyy4 天前
linux远程部署dify和mac本地部署dify
linux·运维·macos