[GH-ISSUE #4198] [Feature Request] 我现在想使用URL路由 根据访问的路由代理到不同的服务器,比如 访问www.baidu.com:8060/aaa 代理到本机1.100的80端口,访问www.baidu.com:8060/bbb代理到本机1.110的80端口.服务… #3305

Closed
opened 2026-05-05 14:07:56 -06:00 by gitea-mirror · 7 comments
Owner

Originally created by @WWTBNBWN on GitHub (May 2, 2024).
Original GitHub issue: https://github.com/fatedier/frp/issues/4198

Describe the feature request

我现在想使用URL路由 根据访问的路由代理到不同的服务器,比如 访问www.baidu.com:8060/aaa 代理到本机1.100的80端口,访问www.baidu.com:8060/bbb代理到本机1.110的80端口.服务器端和客户端怎么配置呢 请教

Describe alternatives you've considered

No response

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @WWTBNBWN on GitHub (May 2, 2024). Original GitHub issue: https://github.com/fatedier/frp/issues/4198 ### Describe the feature request 我现在想使用URL路由 根据访问的路由代理到不同的服务器,比如 访问www.baidu.com:8060/aaa 代理到本机1.100的80端口,访问www.baidu.com:8060/bbb代理到本机1.110的80端口.服务器端和客户端怎么配置呢 请教 ### Describe alternatives you've considered _No response_ ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
Author
Owner

@xqzr commented on GitHub (May 3, 2024):

# frps.toml
vhostHTTPPort = 8060
# frpc.toml
[[proxies]]
name = "aaa"
type = "http"
localIP = "127.0.1.100"
localPort = 80
customDomains = ["www.baidu.com"]
locations = ["/aaa"]

[[proxies]]
name = "bbb"
type = "http"
localIP = "127.0.1.110"
localPort = 80
customDomains = ["www.baidu.com"]
locations = ["/bbb"]

https://gofrp.org/zh-cn/docs/features/http-https/route/

<!-- gh-comment-id:2093618410 --> @xqzr commented on GitHub (May 3, 2024): ```toml # frps.toml vhostHTTPPort = 8060 ``` ```toml # frpc.toml [[proxies]] name = "aaa" type = "http" localIP = "127.0.1.100" localPort = 80 customDomains = ["www.baidu.com"] locations = ["/aaa"] [[proxies]] name = "bbb" type = "http" localIP = "127.0.1.110" localPort = 80 customDomains = ["www.baidu.com"] locations = ["/bbb"] ``` https://gofrp.org/zh-cn/docs/features/http-https/route/
Author
Owner

@WWTBNBWN commented on GitHub (May 4, 2024):

我看着文档配置过一次。我就是上述配置
frps
bindPort = 7000
#tcpmuxHTTPConnectPort = 8099
vhostHTTPPort = 8090

frpc
serverAddr = "88.88.88.88"
serverPort = 7000

frpc.toml

webServer.addr = "127.0.0.1"
webServer.port = 7002
webServer.user = "admin"
webServer.password = "admin"

proxies
name = "bbb"
type = "http"
localPort = 80
localIP = "192.168.1.164"
customDomains = ["www.aaa.aaa"]
remotePort = 8090
locations = ["/bbb"]

proxies
name = "aaa"
type = "http"
localPort = 80
localIP = "192.168.1.108"
remotePort = 8090
customDomains = ["www.aaa.aaa"]
locations = ["/aaa"]
访问浏览器 www.aaa.aaa:8090/aaa 页面直接提示
Access Error: 404 -- Not Found
Can't locate document: /aaa
frps的日志
2024/05/04 08:05:37 [I] [service.go:563] [f858b1a9b5d18616] client login info: ip [121.14.15.87:45791] version [0.53.2] hostname [] os [windows] arch [amd64]
2024/05/04 08:05:37 [I] [http.go:110] [f858b1a9b5d18616] [aaa] http proxy listen for host [www.aaa.aaa] location [/aaa] group [], routeByHTTPUser []
2024/05/04 08:05:37 [I] [control.go:401] [f858b1a9b5d18616] new proxy [aaa] type [http] success
2024/05/04 08:05:37 [I] [http.go:110] [f858b1a9b5d18616] [bbb] http proxy listen for host [www.aaa.aaa] location [/bbb] group [], routeByHTTPUser []
2024/05/04 08:05:37 [I] [control.go:401] [f858b1a9b5d18616] new proxy [bbb] type [http] success

<!-- gh-comment-id:2093901839 --> @WWTBNBWN commented on GitHub (May 4, 2024): 我看着文档配置过一次。我就是上述配置 frps bindPort = 7000 #tcpmuxHTTPConnectPort = 8099 vhostHTTPPort = 8090 frpc serverAddr = "88.88.88.88" serverPort = 7000 # frpc.toml webServer.addr = "127.0.0.1" webServer.port = 7002 webServer.user = "admin" webServer.password = "admin" [[proxies]] name = "bbb" type = "http" localPort = 80 localIP = "192.168.1.164" customDomains = ["www.aaa.aaa"] remotePort = 8090 locations = ["/bbb"] [[proxies]] name = "aaa" type = "http" localPort = 80 localIP = "192.168.1.108" remotePort = 8090 customDomains = ["www.aaa.aaa"] locations = ["/aaa"] 访问浏览器 www.aaa.aaa:8090/aaa 页面直接提示 Access Error: 404 -- Not Found Can't locate document: /aaa frps的日志 2024/05/04 08:05:37 [I] [service.go:563] [f858b1a9b5d18616] client login info: ip [121.14.15.87:45791] version [0.53.2] hostname [] os [windows] arch [amd64] 2024/05/04 08:05:37 [I] [http.go:110] [f858b1a9b5d18616] [aaa] http proxy listen for host [www.aaa.aaa] location [/aaa] group [], routeByHTTPUser [] 2024/05/04 08:05:37 [I] [control.go:401] [f858b1a9b5d18616] new proxy [aaa] type [http] success 2024/05/04 08:05:37 [I] [http.go:110] [f858b1a9b5d18616] [bbb] http proxy listen for host [www.aaa.aaa] location [/bbb] group [], routeByHTTPUser [] 2024/05/04 08:05:37 [I] [control.go:401] [f858b1a9b5d18616] new proxy [bbb] type [http] success
Author
Owner

@xqzr commented on GitHub (May 4, 2024):

locations = ["/aaa/"]
locations = ["/bbb/"]
<!-- gh-comment-id:2094147545 --> @xqzr commented on GitHub (May 4, 2024): ```toml locations = ["/aaa/"] locations = ["/bbb/"] ```
Author
Owner

@WWTBNBWN commented on GitHub (May 4, 2024):

locations = ["/aaa/"]
locations = ["/bbb/"]

结果一样的,浏览器也是提示Access Error: 404 -- Not Found
Can't locate document: /aaa
我试了。还有什么其他的方案吗 不能使用nginx还有其他的吗 谢谢

<!-- gh-comment-id:2094192449 --> @WWTBNBWN commented on GitHub (May 4, 2024): > ```toml > locations = ["/aaa/"] > locations = ["/bbb/"] > ``` 结果一样的,浏览器也是提示Access Error: 404 -- Not Found Can't locate document: /aaa 我试了。还有什么其他的方案吗 不能使用nginx还有其他的吗 谢谢
Author
Owner

@xqzr commented on GitHub (May 4, 2024):

locations = ["/aaa/"]
locations = ["/bbb/"]

结果一样的,浏览器也是提示Access Error: 404 -- Not Found Can't locate document: /aaa 我试了。还有什么其他的方案吗 不能使用nginx还有其他的吗 谢谢

看起来是 本地服务返回的错误
你的场景 可能需要 frpc 改写请求路径(/aaa/bbb 改写为 /)再请求 本地服务,而 frpc 没有这个功能。可以让本地服务适应。

另外,可以看看使用端口 路由它们

# frpc.toml
[[proxies]]
name = "aaa"
type = "tcp"
localIP = "127.0.1.100"
localPort = 80
remotePort = 8010

[[proxies]]
name = "bbb"
type = "tcp"
localIP = "127.0.1.110"
localPort = 80
remotePort = 8011
<!-- gh-comment-id:2094288992 --> @xqzr commented on GitHub (May 4, 2024): > > ```toml > > locations = ["/aaa/"] > > locations = ["/bbb/"] > > ``` > > 结果一样的,浏览器也是提示Access Error: 404 -- Not Found Can't locate document: /aaa 我试了。还有什么其他的方案吗 不能使用nginx还有其他的吗 谢谢 看起来是 本地服务返回的错误 你的场景 可能需要 frpc 改写请求路径(`/aaa` 或 `/bbb` 改写为 `/`)再请求 本地服务,而 frpc 没有这个功能。可以让本地服务适应。 另外,可以看看使用端口 路由它们 ```toml # frpc.toml [[proxies]] name = "aaa" type = "tcp" localIP = "127.0.1.100" localPort = 80 remotePort = 8010 [[proxies]] name = "bbb" type = "tcp" localIP = "127.0.1.110" localPort = 80 remotePort = 8011 ```
Author
Owner

@WWTBNBWN commented on GitHub (May 5, 2024):

locations = ["/aaa/"]
locations = ["/bbb/"]

结果一样的,浏览器也是提示Access Error: 404 -- Not Found Can't locate document: /aaa 我试了。还有什么其他的方案吗 不能使用nginx还有其他的吗 谢谢

看起来是 本地服务返回的错误 你的场景 可能需要 frpc 改写请求路径(/aaa/bbb 改写为 /)再请求 本地服务,而 frpc 没有这个功能。可以让本地服务适应。

另外,可以看看使用端口 路由它们

# frpc.toml
[[proxies]]
name = "aaa"
type = "tcp"
localIP = "127.0.1.100"
localPort = 80
remotePort = 8010

[[proxies]]
name = "bbb"
type = "tcp"
localIP = "127.0.1.110"
localPort = 80
remotePort = 8011

tcp的我试了是可以的但是这样需要大量端口。如果我单独访问每台机器的ip(http://192.168.1.100)是可以的访问的。我就是想少开端口通过路由来访问。但是没找到方案。您这有什么方式么

<!-- gh-comment-id:2094536065 --> @WWTBNBWN commented on GitHub (May 5, 2024): > > > ```toml > > > locations = ["/aaa/"] > > > locations = ["/bbb/"] > > > ``` > > > > > > 结果一样的,浏览器也是提示Access Error: 404 -- Not Found Can't locate document: /aaa 我试了。还有什么其他的方案吗 不能使用nginx还有其他的吗 谢谢 > > 看起来是 本地服务返回的错误 你的场景 可能需要 frpc 改写请求路径(`/aaa` 或 `/bbb` 改写为 `/`)再请求 本地服务,而 frpc 没有这个功能。可以让本地服务适应。 > > 另外,可以看看使用端口 路由它们 > > ```toml > # frpc.toml > [[proxies]] > name = "aaa" > type = "tcp" > localIP = "127.0.1.100" > localPort = 80 > remotePort = 8010 > > [[proxies]] > name = "bbb" > type = "tcp" > localIP = "127.0.1.110" > localPort = 80 > remotePort = 8011 > ``` tcp的我试了是可以的但是这样需要大量端口。如果我单独访问每台机器的ip(http://192.168.1.100)是可以的访问的。我就是想少开端口通过路由来访问。但是没找到方案。您这有什么方式么
Author
Owner

@vikii0210 commented on GitHub (May 6, 2024):

frpc+nginx hahaha

<!-- gh-comment-id:2095038515 --> @vikii0210 commented on GitHub (May 6, 2024): frpc+nginx hahaha
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#3305
No description provided.