Skip to content
0

frp URL 路由

之前内网穿透是通过 cloudflare 的 Origin Rules 进行重定向到指定端口的

这种做法有 10 个 Origin Rules 配置的限制

实际上我们可以使用 frp 的 URL 路由功能来实现这个需求

cloudflare 配置

如果我们是在 cloudflare 家买的域名,例如我的 peterroe.me,那么我们可以在 cloudflare 的 DNS 中配置

添加 DNS A 记录,例如将二级域名 test.peterroe.me 解析到我们的主机 x.x.x.x

frp 配置

服务端关键配置,我们配置 vhostHTTPPortsubDomainHost

kcpbindPort = 7000
bindPort = 7000
vhostHTTPPort = 80
vhostHTTPSPort = 443
subDomainHost = "peterroe.me"

客户端关键配置,在 common 中配置 custom_domains。在其他配置中配置 subdomain

[common]
server_addr = x.x.x.x
server_port = 7000
protocol = tcp
custom_domains = peterroe.me

[TEST]
type = http
local_ip = 127.0.0.1
local_port = 5800
subdomain = test

我们就可以通过 https://test.peterroe.me 访问到 frp 客户端中的 5800 端口的服务了

附录

frpc 和 frps 都允许 ini 和 toml 格式的配置文件,所以这里给出的完整配置参考:

根据需求转换对应的配置即可

Released under the MIT License.