🖥️外网服务器配置
1. frps.toml
toml
bindPort = 7000
# 开启 http 虚拟主机代理
vhostHTTPPort = 8080
vhostHTTPSPort = 8443
auth.method = "token"
auth.token = "12345678"
log.to = "/var/log/frps.log"
log.level = "info"
log.maxDays = 3
2. Caddyfile
caddyfile
app1.yourdomain.com {
reverse_proxy localhost:8080
}
app2.yourdomain.com {
reverse_proxy localhost:8080
}
-
每个子域名都指向 FRP 服务端的 HTTP 入口端口(这里是 8080)。
-
Caddy 会自动申请并续期 HTTPS 证书。
🖥️ 内网客户端配置
frpc.toml
toml
serverAddr = "your.server.com"
serverPort = 7000
auth.method = "token"
auth.token = "12345678"
# 内网服务1:映射到 app1.yourdomain.com
[[proxies]]
name = "app1"
type = "http"
localIP = "127.0.0.1"
localPort = 5000
customDomains = ["app1.yourdomain.com"]
# 内网服务2:映射到 app2.yourdomain.com
[[proxies]]
name = "app2"
type = "http"
localIP = "127.0.0.1"
localPort = 6000
customDomains = ["app2.yourdomain.com"]
🔑 注意事项
-
DNS:确保
app1.yourdomain.com和app2.yourdomain.com都解析到外网服务器 IP。 -
防火墙:开放 80/443 给 Caddy,开放 7000 给 FRP 客户端连接。
-
证书:由 Caddy 自动管理,不需要在 FRP 配置里写证书。
-
安全:建议使用复杂的
auth.token。
这样配置后:
-
外网访问
https://app1.yourdomain.com→ Caddy → FRP → 内网 5000 服务。 -
外网访问
https://app2.yourdomain.com→ Caddy → FRP → 内网 6000 服务。
浙公网安备 33010602011771号