Files
nexus/openclaw/knowledgebase/FRP 配置详细笔记.md
2026-03-24 09:52:46 +08:00

532 lines
11 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# FRP 配置详细笔记
#frp #macos #ubuntu
## 概述
本文档记录 macmini、ubuntu1、ubuntu2、NAS 四个服务器上的 FRPFast Reverse Proxy客户端配置信息。
---
## 服务器配置总览
| 服务器 | FRP目录 | 配置文件 |
| ------- | ---------------------------------- | ----------- |
| macmini | `/opt/frp/frp_0.65.0_darwin_arm64` | `frpc.toml` |
| ubuntu1 | `/opt/frp/frp_0.65.0_linux_amd64` | `frpc.toml` |
| ubuntu2 | `/opt/frp/frp_0.65.0_linux_amd64` | `frpc.toml` |
| NAS | `/opt/frp/frp_0.65.0_linux_amd64` | `frpc.toml` |
| | | |
---
## FRP 服务器信息
| 配置项 | 值 |
|--------|-----|
| serverAddr | 192.227.222.142 (VPS1) |
| serverPort | 7000 |
| auth.token | Gg8sqHJVgh42KQ0oTatMjl6AywWqAzaaT0B77a4qD46tXtoH9j9mXb2k1YitObhs |
| webServer.addr | 127.0.0.1 |
| webServer.port | 7400 |
| webServer.user | admin |
| webServer.password | admin |
---
## 1. MacMini 配置
### 基本信息
- **FRP目录**: `/opt/frp/frp_0.65.0_darwin_arm64`
- **配置文件**: `frpc.toml`
- **运行用户**: root (通过 tmux 管理)
### 代理配置列表
| 名称 | 类型 | LocalPort | RemotePort | 说明 |
|------|------|------------|-------------|------|
| macmini-ssh | tcp | 22 | 60026 | SSH反向代理 |
| n8n | tcp | 5678 | 15679 | n8n自动化工具 |
| vaultwarden | tcp | 5151 | 15151 | 密码管理器 |
| it-tools | tcp | 8999 | 18999 | IT工具集合 |
| drawio | tcp | 8085 | 18085 | 绘图工具 |
### 完整配置文件内容
```toml
# frpc.toml
# 客户端配置文件
# 服务器地址与认证
serverAddr = "192.227.222.142"
serverPort = 7000
auth.method = "token"
auth.token = "Gg8sqHJVgh42KQ0oTatMjl6AywWqAzaaT0B77a4qD46tXtoH9j9mXb2k1YitObhs"
# 日志配置
log.level = "info"
log.maxDays = 3
log.disablePrintColor = false
# 管理界面(可选)
webServer.addr = "127.0.0.1"
webServer.port = 7400
webServer.user = "admin"
webServer.password = "admin"
# 代理配置
[[proxies]]
name = "macmini-ssh"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 60026
[[proxies]]
name = "n8n"
type = "tcp"
localIP = "127.0.0.1"
localPort = 5678
remotePort = 15679
[[proxies]]
name = "vaultwarden"
type = "tcp"
localIP = "127.0.0.1"
localPort = 5151
remotePort = 15151
[[proxies]]
name = "it-tools"
type = "tcp"
localIP = "127.0.0.1"
localPort = 8999
remotePort = 18999
[[proxies]]
name = "drawio"
type = "tcp"
localIP = "127.0.0.1"
localPort = 8085
remotePort = 18085
```
## 2. Ubuntu1 配置
### 基本信息
- **FRP目录**: `/opt/frp/frp_0.65.0_linux_amd64`
- **配置文件**: `frpc.toml`
- **运行用户**: root (通过 systemd 管理)
### 代理配置列表
| 名称 | 类型 | LocalPort | RemotePort | 说明 |
|------|------|------------|-------------|------|
| ubuntu1-ssh | tcp | 22 | 60022 | SSH反向代理 |
| transmission | tcp | 9091 | 19091 | BT下载 |
| grafana | tcp | 3000 | 13000 | 监控面板 |
| homarr | tcp | 7575 | 17575 | 导航面板 |
| superset | tcp | 8777 | 18777 | 数据可视化 |
| tk | tcp | 8888 | 18888 | TikTok生产环境 |
| portainer | tcp | 9000 | 19443 | Docker管理 |
| stq | tcp | 5173 | 15173 | STQ开发 |
| stq-admin | tcp | 7000 | 17000 | STQ管理后台 |
| stq-n8n | tcp | 62000 | 15678 | STQ n8n |
### 完整配置文件内容
```toml
# frpc.toml
# 客户端配置文件
# 服务器地址与认证
serverAddr = "192.227.222.142"
serverPort = 7000
auth.method = "token"
auth.token = "Gg8sqHJVgh42KQ0oTatMjl6AywWqAzaaT0B77a4qD46tXtoH9j9mXb2k1YitObhs"
# 日志配置
log.level = "info"
log.maxDays = 3
log.disablePrintColor = false
# 管理界面(可选)
webServer.addr = "127.0.0.1"
webServer.port = 7400
webServer.user = "admin"
webServer.password = "admin"
[[proxies]]
name = "transmission"
type = "tcp"
localIP = "127.0.0.1"
localPort = 9091
remotePort = 19091
[[proxies]]
name = "grafana"
type = "tcp"
localIP = "127.0.0.1"
localPort = 3000
remotePort = 13000
[[proxies]]
name = "ubuntu1-ssh"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 60022
[[proxies]]
name = "homarr"
type = "tcp"
localIP = "127.0.0.1"
localPort = 7575
remotePort = 17575
[[proxies]]
name = "superset"
type = "tcp"
localIP = "127.0.0.1"
localPort = 8777
remotePort = 18777
[[proxies]]
name = "tk"
type = "tcp"
localIP = "127.0.0.1"
localPort = 8888
remotePort = 18888
[[proxies]]
name = "ubuntu1-portainer"
type = "tcp"
localIP = "127.0.0.1"
localPort = 9000
remotePort = 19443
[[proxies]]
name = "stq"
type = "tcp"
localIP = "127.0.0.1"
localPort = 5173
remotePort = 15173
[[proxies]]
name = "stq-admin"
type = "tcp"
localIP = "127.0.0.1"
localPort = 7000
remotePort = 17000
[[proxies]]
name = "stq-n8n"
type = "tcp"
localIP = "127.0.0.1"
localPort = 62000
remotePort = 15678
```
---
## 3. Ubuntu2 配置
### 基本信息
- **FRP目录**: `/opt/frp/frp_0.65.0_linux_amd64`
- **配置文件**: `frpc.toml`
- **运行用户**: root (通过 systemd 管理)
### 代理配置列表
| 名称 | 类型 | LocalPort | RemotePort | 说明 |
|------|------|------------|-------------|------|
| ubuntu2-ssh | tcp | 22 | 60024 | SSH反向代理 |
| tk-dev | tcp | 8888 | 18889 | TikTok开发环境 |
### 完整配置文件内容
```toml
# frpc.toml
# 客户端配置文件
# 服务器地址与认证
serverAddr = "192.227.222.142"
serverPort = 7000
auth.method = "token"
auth.token = "Gg8sqHJVgh42KQ0oTatMjl6AywWqAzaaT0B77a4qD46tXtoH9j9mXb2k1YitObhs"
# 日志配置
log.level = "info"
log.maxDays = 3
log.disablePrintColor = false
# 管理界面(可选)
webServer.addr = "127.0.0.1"
webServer.port = 7400
webServer.user = "admin"
webServer.password = "admin"
# 示例1SSH 反向代理(将本地 22 端口暴露到服务器的 60024 端口)
[[proxies]]
name = "ubuntu2-ssh"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 60024
[[proxies]]
name = "tk-dev"
type = "tcp"
localIP = "127.0.0.1"
localPort = 8888
remotePort = 18889
```
---
## 4. NAS 配置
### 基本信息
- **FRP目录**: `/opt/frp/frp_0.65.0_linux_amd64`
- **配置文件**: `frpc.toml`
- **运行用户**: root (通过 systemd 管理)
### 代理配置列表
| 名称 | 类型 | LocalPort | RemotePort | 说明 |
|------|------|------------|-------------|------|
| nas | tcp | 5000 | 15000 | DSM管理界面 |
| navidrome | tcp | 4533 | 14533 | 音乐服务器 |
| calibre | tcp | 8083 | 18083 | 电子书管理 |
| webdav | tcp | 5005 | 65005 | WebDAV服务 |
| miniflux | tcp | 8080 | 18080 | RSS阅读器 |
| zipline | tcp | 3333 | 13333 | URL短链接 |
| nas_ssh | tcp | 22 | 60023 | SSH反向代理 |
| mysql | tcp | 3307 | 63307 | MySQL数据库 |
| nas_web | tcp | 80 | 10080 | Web服务 |
| jellyfin | tcp | 8096 | 18096 | 媒体服务器 |
### 完整配置文件内容
```toml
# FRP Client Configuration for NAS
# Converted from frpc.ini
serverAddr = "192.227.222.142"
serverPort = 7000
[auth]
token = "Gg8sqHJVgh42KQ0oTatMjl6AywWqAzaaT0B77a4qD46tXtoH9j9mXb2k1YitObhs"
[[proxies]]
name = "nas"
type = "tcp"
localIP = "127.0.0.1"
localPort = 5000
remotePort = 15000
[[proxies]]
name = "navidrome"
type = "tcp"
localIP = "127.0.0.1"
localPort = 4533
remotePort = 14533
[[proxies]]
name = "calibre"
type = "tcp"
localIP = "127.0.0.1"
localPort = 8083
remotePort = 18083
[[proxies]]
name = "webdav"
type = "tcp"
localIP = "127.0.0.1"
localPort = 5005
remotePort = 65005
[[proxies]]
name = "miniflux"
type = "tcp"
localIP = "127.0.0.1"
localPort = 8080
remotePort = 18080
[[proxies]]
name = "zipline"
type = "tcp"
localIP = "127.0.0.1"
localPort = 3333
remotePort = 13333
[[proxies]]
name = "nas_ssh"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 60023
[[proxies]]
name = "mysql"
type = "tcp"
localIP = "127.0.0.1"
localPort = 3307
remotePort = 63307
[[proxies]]
name = "nas_web"
type = "tcp"
localIP = "127.0.0.1"
localPort = 80
remotePort = 10080
[[proxies]]
name = "jellyfin"
type = "tcp"
localIP = "127.0.0.1"
localPort = 8096
remotePort = 18096
```
---
## 端口映射汇总
### 按 RemotePort 排序
| RemotePort | 服务器 | 服务名称 |
|------------|--------|----------|
| 60022 | ubuntu1 | ubuntu1-ssh |
| 60023 | NAS | nas_ssh |
| 60024 | ubuntu2 | ubuntu2-ssh |
| 60026 | macmini | macmini-ssh |
| 10080 | NAS | nas_web |
| 13000 | ubuntu1 | grafana |
| 13333 | NAS | zipline |
| 14533 | NAS | navidrome |
| 15000 | NAS | nas |
| 15151 | macmini | vaultwarden |
| 15173 | ubuntu1 | stq |
| 15678 | ubuntu1 | stq-n8n |
| 15679 | macmini | n8n |
| 17000 | ubuntu1 | stq-admin |
| 17575 | ubuntu1 | homarr |
| 18083 | NAS | calibre |
| 18085 | macmini | drawio |
| 18096 | NAS | jellyfin |
| 18777 | ubuntu1 | superset |
| 18888 | ubuntu1 | tk |
| 18889 | ubuntu2 | tk-dev |
| 18999 | macmini | it-tools |
| 19091 | ubuntu1 | transmission |
| 19443 | ubuntu1 | portainer |
| 63307 | NAS | mysql |
| 65005 | NAS | webdav |
---
## FRP 管理命令
### MacMini
#### 查看状态
```bash
# SSH到服务器后连接tmux会话
ssh <服务器名>
tmux attach -t frpc
```
#### 重启FRP
```bash
# 在tmux中按 Ctrl+C 停止,然后重新运行
./frpc -c frpc.toml
```
### Ubuntu1/Ubuntu2/NAS
#### 查看状态
```bash
ssh <服务器名>
systemctl status frpc
```
#### 重启FRP
```bash
systemctl restart frpc
```
#### 配置FRP service
```bash
# Reload systemd manager configuration
systemctl daemon-reload
# Stop Service
systemctl stop frpc
# Start Service
systemctl start frpc
# Check service status
systemctl status frpc
```
#### 配置frpc.service
```
cd /etc/systemd/system
# ubuntu1/ubuntu2
nano frpc.service
# nas
vi frpc.service
```
```python
[Unit]
Description=frp client
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/opt/frp/frp_0.65.0_linux_amd64/frpc -c /opt/frp/frp_0.65.0_linux_amd64/frpc.toml
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
```
### 常用命令速查
| 服务器 | SSH别名 | FRP目录 | 启动命令 |
| ------- | ------------- | -------------------------------- | ---- |
| macmini | `ssh macmini` | /opt/frp/frp_0.65.0_darwin_arm64 | frpc |
| ubuntu1 | `ssh ubuntu1` | /opt/frp/frp_0.65.0_linux_amd64 | frpc |
| ubuntu2 | `ssh ubuntu2` | /opt/frp/frp_0.65.0_linux_amd64 | frpc |
| NAS | `ssh nas` | /opt/frp/frp_0.65.0_linux_amd64 | frpc |
---
## 相关域名映射
| 域名 | 服务器 | 目标服务 | RemotePort |
|------|--------|----------|------------|
| n8n.ishenwei.online | macmini | n8n | 15679 |
| vaultwarden.ishenwei.online | NAS | vaultwarden | 15151 |
| it-tools.ishenwei.online | macmini | it-tools | 18999 |
| drawio.ishenwei.online | macmini | drawio | 18085 |
| tk.ishenwei.online | ubuntu1 | tk | 18888 |
| tk-dev.ishenwei.online | ubuntu2 | tk-dev | 18889 |
| grafana.ishenwei.online | ubuntu1 | grafana | 13000 |
| superset.ishenwei.online | ubuntu1 | superset | 18777 |
| dashboard.ishenwei.online | ubuntu1 | homarr | 17575 |
| transmission.ishenwei.online | ubuntu1 | transmission | 19091 |
| nas.ishenwei.online | NAS | DSM | 15000 |
| navidrome.ishenwei.online | NAS | navidrome | 14533 |
| calibre.ishenwei.online | NAS | calibre-web | 18083 |
| jellyfin.ishenwei.online | NAS | jellyfin | 18096 |
| zipline.ishenwei.online | NAS | zipline | 13333 |