mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 16:15:49 -06:00
[GH-ISSUE #1257] URL路由无法转发 #994
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#994
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Cyaim on GitHub (May 24, 2019).
Original GitHub issue: https://github.com/fatedier/frp/issues/1257
Issue is only used for submiting bug report and documents typo. If there are same issues or answers can be found in documents, we will close it directly.
(为了节约时间,提高处理问题的效率,不按照格式填写的 issue 将会直接关闭。)
Use the commands below to provide key information from your environment:
You do NOT have to include this information if this is a FEATURE REQUEST
What version of frp are you using (./frpc -v or ./frps -v)?
frp 0.25.3
What operating system and processor architecture are you using (
go env)?Windwos Server 2008 R2企业版
Configures you used:
[web01]
type = http
custom_domains = web.yourdomain.com
local_port = 2333
locations = /
[web02]
type = http
custom_domains = web.yourdomain.com
local_port = 2334
locations = /admin,/admins
Steps to reproduce the issue:
1.服务器为A,本地个人电脑为B
2.在A上执行frpc -c frpc.ini
3.在B浏览器上可以通过web.yourdomain.com:vhost_port成功访问web01,而通过web.yourdomain.com:vhost_port/admin访问,则404
4.日志上打出:
2019/05/24 16:49:54 [I] [service.go:221] login to server success, get run id [2a
90bfae1816c566], server udp port [7001]
2019/05/24 16:49:54 [I] [proxy_manager.go:137] [2a90bfae1816c566] proxy added: [web01 web02]
2019/05/24 16:49:54 [I] [control.go:144] [web01] start proxy success
2019/05/24 16:49:54 [I] [control.go:144] [web02] start proxy success
Describe the results you received:
web01和web02通过路由区分访问网站
@fatedier commented on GitHub (Jun 4, 2019):
2334 那个端口的服务确认没有问题?
@Cyaim commented on GitHub (Jun 4, 2019):
确定没有问题,因为不使用路由,不同custom_domains时都可以访问
@fatedier commented on GitHub (Jun 4, 2019):
可以继续看一下 frps 的日志,确认一下这个 404 是你的服务返回的,还是 frps 返回的。
@woniuyangwang commented on GitHub (Jun 4, 2019):
我也碰到类似问题,locations现在好像不起作用。
@fatedier commented on GitHub (Jun 4, 2019):
@woniuyangwang 尽量不要使用
+1或我也遇到xxx这样没有帮助的回复。提供可复现的环境和配置,以及详细的日志更有助于解决问题。
@Cyaim commented on GitHub (Jun 4, 2019):
我尝试搭建了一个本地环境
frps配置如下:
[common]
bind_addr = 0.0.0.0
bind_port = 7000
token = 123456
vhost_http_port = 8081
log_file = ./frps.log
log_level = info
log_max_days = 3
frpc配置如下:
[common]
server_addr = 0.0.0.0
server_port = 7000
token = 123456
[web01]
type = http
custom_domains = web.yourdomain.com
local_port = 2333
locations = /
[web02]
type = http
custom_domains = web.yourdomain.com
local_port = 2334
locations = /admin
frps日志如下:
2019/06/04 15:33:52 [I] [service.go:136] frps tcp listen on 0.0.0.0:7000
2019/06/04 15:33:52 [I] [service.go:178] http service listen on 0.0.0.0:8081
2019/06/04 15:33:52 [I] [root.go:204] Start frps success
2019/06/04 15:33:53 [I] [service.go:337] client login info: ip [127.0.0.1:55701] version [0.25.3] hostname [] os [windows] arch [amd64]
2019/06/04 15:33:53 [I] [http.go:67] [d594be04eaab7fdd] [web01] http proxy listen for host [web.yourdomain.com] location [/]
2019/06/04 15:33:53 [I] [control.go:397] [d594be04eaab7fdd] new proxy [web01] success
2019/06/04 15:33:53 [I] [http.go:67] [d594be04eaab7fdd] [web02] http proxy listen for host [web.yourdomain.com] location [/admin]
2019/06/04 15:33:53 [I] [control.go:397] [d594be04eaab7fdd] new proxy [web02] success
2019/06/04 15:35:47 [I] [proxy.go:80] [d594be04eaab7fdd] [web01] get a new work connection: [127.0.0.1:55701]
2019/06/04 15:35:49 [I] [proxy.go:80] [d594be04eaab7fdd] [web01] get a new work connection: [127.0.0.1:55701]
2019/06/04 15:35:49 [I] [proxy.go:80] [d594be04eaab7fdd] [web01] get a new work connection: [127.0.0.1:55701]
2019/06/04 15:35:49 [I] [proxy.go:80] [d594be04eaab7fdd] [web01] get a new work connection: [127.0.0.1:55701]
2019/06/04 15:35:49 [I] [proxy.go:80] [d594be04eaab7fdd] [web01] get a new work connection: [127.0.0.1:55701]
2019/06/04 15:35:49 [I] [proxy.go:80] [d594be04eaab7fdd] [web01] get a new work connection: [127.0.0.1:55701]
2019/06/04 15:35:49 [I] [proxy.go:80] [d594be04eaab7fdd] [web01] get a new work connection: [127.0.0.1:55701]
2019/06/04 15:35:49 [I] [proxy.go:80] [d594be04eaab7fdd] [web01] get a new work connection: [127.0.0.1:55701]
2019/06/04 15:35:49 [I] [proxy.go:80] [d594be04eaab7fdd] [web01] get a new work connection: [127.0.0.1:55701]
2019/06/04 15:35:50 [I] [proxy.go:80] [d594be04eaab7fdd] [web01] get a new work connection: [127.0.0.1:55701]
2019/06/04 15:35:50 [I] [proxy.go:80] [d594be04eaab7fdd] [web01] get a new work connection: [127.0.0.1:55701]
2019/06/04 15:35:50 [I] [proxy.go:80] [d594be04eaab7fdd] [web01] get a new work connection: [127.0.0.1:55701]
2019/06/04 15:35:50 [I] [proxy.go:80] [d594be04eaab7fdd] [web01] get a new work connection: [127.0.0.1:55701]
2019/06/04 15:36:12 [I] [proxy.go:80] [d594be04eaab7fdd] [web02] get a new work connection: [127.0.0.1:55701]
web01可以正常访问
web02 404
@fatedier commented on GitHub (Jun 4, 2019):
frps 没有看到异常日志,你再看看你 2334 的服务,是否有收到请求,以及返回的请求结果如何。
@Cyaim commented on GitHub (Jun 4, 2019):
Now listening on: http://[::]:2334
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://web.yourdomain.com:8081/admin
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 85.6568ms 404
frp似乎没有正确处理路由,而是直接把请求转发到了服务
@fatedier commented on GitHub (Jun 4, 2019):
所以 404 是你自身的服务返回的,frps 已经正确地将 /admin 为前缀的请求转发给了你的 2334 端口绑定的服务。
你在 2334 端口绑定的服务,应该能够正确处理这个请求 PATH。
@Cyaim commented on GitHub (Jun 4, 2019):
emmmm,locations只是将配置的字符串加到域名后面,可不可以配置转发请求时不把locations加到请求中?这样不用修改代码就能通过域名:端口/locations访问不同资源
@fatedier commented on GitHub (Jun 4, 2019):
路由的功能就是根据请求的某些不同参数将请求转发给对应的服务,不会对请求本身内容做任何修改。
你的需求应该通过 vhost 来实现,而不是通过 URL 路由。或者在你的服务前面再加一个 proxy (例如 nginx),来实现你的需求。
@Cyaim commented on GitHub (Jun 4, 2019):
感谢大佬的协助~
已通过nginx实现,建议locations只在frp中用于转发,请求中不包含locations路由,这个功能真的鸡肋,因为使用这个功能在不同的环境下用还得修改服务代码。
@fatedier commented on GitHub (Jun 4, 2019):
每个人的需求不同,场景不同,作为一个反向代理,不修改请求内容是合理的。
@JasonJarvan commented on GitHub (Jan 28, 2023):
你好,我也遇到了同样的问题。请问能以你上面举出的例子为例说一说你是怎么解决的吗?谢谢!
@ssssmy commented on GitHub (Dec 11, 2023):
使用nginx代理,监听 /admin 转发到本地服务