路由

URL 路由

frp 支持根据请求的 URL 路径路由转发到不同的后端服务。

通过配置文件中的 locations 字段指定一个或多个 proxy 能够匹配的 URL 前缀(目前仅支持最大前缀匹配,之后会考虑正则匹配)。例如指定 locations = "/news",则所有 URL 以 /news 开头的请求都会被转发到这个服务。

# frpc.toml
    [[proxies]]
    name = "web01"
    type = "http"
    localPort = 80
    customDomains = ["web.yourdomain.com"]
    locations = ["/"]
    
    [[proxies]]
    name = "web02"
    type = "http"
    localPort = 81
    customDomains = ["web.yourdomain.com"]
    locations = ["/news", "/about"]
    

按照上述的示例配置后,web.yourdomain.com 这个域名下所有以 /news 以及 /about 作为前缀的 URL 请求都会被转发到 web02,其余的请求会被转发到 web01。

最后修改 November 15, 2023: fix 404 (#71) (626ce4d)

Routin

URL Routin

FRP supports forwarding to different backend services based on the requested URL path Routing

Specify one or more proxies through the locations field in the Configuration file Matchable URLs Prefix (currently only supports maximum prefix matching, regular matching will be considered in the future). For example, specifying locations="a/ News", all URLs will be marked as Requests starting with/newswill be forwarded to this service.

# frpc.toml
    [[proxies]]
    name = "web01"
    type = "http"
    localPort = 80
    customDomains = ["web.yourdomain.com"]
    locations = ["/"]
    
    [[proxies]]
    name = "web02"
    type = "http"
    localPort = 81
    customDomains = ["web.yourdomain.com"]
    locations = ["/news", "/about"]
    

After following the above ExampleConfiguration,Web. yourdomain. com All domain names under/newsand URL requests prefixed with/aboutwill be forwarded to Web02, the remaining requests will be forwarded to web01.

Last modified November 15, 2023: fix 404 (#71) (626ce4d)