FRP Ubuntu 服务端 + MacOS 客户端配置

一、服务端配置

1、下载frp并解压

bash 复制代码
# 创建目录并进入
mkdir -p /opt/frp && cd /opt/frp
# 下载最新版(替换URL为GitHub发布页最新版本)
wget https://github.com/fatedier/frp/releases/download/v0.59.0/frp_0.59.0_linux_amd64.tar.gz
# 解压
tar -zxvf frp_*_linux_amd64.tar.gz
mv frp_*_linux_amd64/* .
rm -rf frp_*_linux_amd64*

2、配置文件

bash 复制代码
nano frps.toml

文件如下:

bash 复制代码
bindPort = 7000
auth.token = "token text"
# 服务端仪表盘的端口, 可以用浏览器访问查看
webServer.addr = "0.0.0.0"
webServer.port = 7500
# 服务端仪表盘的用户密码
webServer.user = "admin"
webServer.password = "admin"
# 虚拟主机端口
vhostHTTPPort = 8080

3、启动服务

bash 复制代码
./frps -c ./frps.toml

4、开放防火墙端口

bash 复制代码
# 开放7500 端口
sudo ufw allow 7500
# 开放 8088端口
sudo ufw allow 8088
# 查看状态
sudo ufw status numbered

5、访问 http://192.168.88.88:7500/ (IP换成自己的)成功即代表启动成功

6、配置自启动

bash 复制代码
# 创建 systemd 服务文件
sudo nano /etc/systemd/system/frps.service

内容如下:

bash 复制代码
[Unit]
Description=Frp Server
After=network.target
[Service]
Type=simple
WorkingDirectory=/opt/frp
ExecStart=/opt/frp/frps -c /opt/frp/frps.toml
Restart=on-failure
[Install]
WantedBy=multi-user.target
bash 复制代码
# 设置权限
sudo chmod 644 /etc/systemd/system/frpc.service
# 重载
sudo systemctl daemon-reload
# 启用开机自启
sudo systemctl enable frpc
# 立即启动服务
sudo systemctl start frpc 
# 验证
sudo systemctl status frpc

二、客户端配置

1、安装 frp

bash 复制代码
brew install frpc

2、配置 frpc

bash 复制代码
# 创建文件夹
sudo mkdir -p /opt/homebrew/etc/frp
# 创建 frpc.toml 文件
sudo nano /opt/homebrew/etc/frp/frpc.toml

3、配置 frpc.toml

  1. 打开 frpc.toml
bash 复制代码
sudo nano /opt/homebrew/etc/frp/frpc.toml
  1. 编辑 frpc.toml
bash 复制代码
serverAddr = "192.169.88.88" #你的公网IP
serverPort = 7000
auth.method = "token"
auth.token = "token text"

[[proxies]]
name = "name"
type = "tcp"
localIP = "127.0.0.1"
localPort = 8088
remotePort = 8088

# 其他端口
[[proxies]]
name = "xxx"
type = "tcp"
localIP = "127.0.0.1"
localPort = 9099
remotePort = 9099

#...proxies

4、启动

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

5、自启动配置

  1. 创建 launchd 服务文件
bash 复制代码
nano ~/Library/LaunchAgents/com.user.frpc.plist
  1. 编辑内容
bash 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.$
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.user.frpc</string>  <!-- 服务名称 -->
    <key>ProgramArguments</key>
    <array>
        <string>/opt/homebrew/bin/frpc</string>  <!-- frpc可执行文件路$
        <string>-c</string>
        <string>/opt/homebrew/etc/frp/frpc.toml</string>  <!-- 配置文件$
    </array>
    <key>RunAtLoad</key>
    <true/>  <!-- 开机自动启动 -->
    <key>KeepAlive</key>
    <true/>  <!-- 崩溃后自动重启 -->
    <key>StandardOutPath</key>
    <string>/opt/homebrew/etc/frp/frpc.log</string>  <!-- 输出日志 -->
    <key>StandardErrorPath</key>
    <string>/opt/homebrew/etc/frp/frpc_error.log</string>  <!-- 错误日$
</dict>
</plist>
  1. 设置权限并加载服务
bash 复制代码
chmod +x /opt/homebrew/bin/frpc
  1. 加载服务(无需重启立即生效):
bash 复制代码
launchctl load ~/Library/LaunchAgents/com.user.frpc.plist
  1. 验证服务状态
bash 复制代码
launchctl list | grep com.user.frpc
相关推荐
夜听莺儿鸣2 小时前
502-002_Linux驱动开发模块化编程
linux·驱动开发·模块化编程
wuminyu3 小时前
C++协程实现接收端的零拷贝Buffer管理原理剖析
java·linux·c语言·jvm·c++
科力锐品牌君3 小时前
应用级灾备 | 海量非结构化数据如何实现高效数据保护
linux·运维·网络·安全·系统安全·数据安全·灾备
zhangrelay4 小时前
ROS项目设计案例智能大模型正经乱答案例
linux·笔记·学习·ubuntu·机器人
流浪0014 小时前
Linux系统篇39——线程(四) pthread库的由来和线程的创建与等待
linux·操作系统·线程·pthread库
Lancker4 小时前
chnroute-linux — 中国大陆 IP 段每日自动更新 + 「仅允许国内访问」落地
linux·运维·tcp/ip
高山有多高5 小时前
【Linux笔记】Linux进程与守护进程
linux
大侠归来6 小时前
Ubuntu 搭建 APUE 环境:从源码编译到第一个示例跑通
linux·运维·ubuntu
shdkfbbv7 小时前
【无标题】
linux·运维·服务器
周洲08308 小时前
STM32片内Flash读写深度详解|掉电参数保存、底层原理
linux·前端·stm32