New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URL路由无法转发 #1257
Comments
2334 那个端口的服务确认没有问题? |
确定没有问题,因为不使用路由,不同custom_domains时都可以访问 |
可以继续看一下 frps 的日志,确认一下这个 404 是你的服务返回的,还是 frps 返回的。 |
我也碰到类似问题,locations现在好像不起作用。 |
@woniuyangwang 尽量不要使用 提供可复现的环境和配置,以及详细的日志更有助于解决问题。 |
我尝试搭建了一个本地环境 vhost_http_port = 8081 log_file = ./frps.log log_level = info log_max_days = 3 frpc配置如下: [web01] [web02] frps日志如下: web01可以正常访问 |
frps 没有看到异常日志,你再看看你 2334 的服务,是否有收到请求,以及返回的请求结果如何。 |
Now listening on: http://[::]:2334 frp似乎没有正确处理路由,而是直接把请求转发到了服务 |
所以 404 是你自身的服务返回的,frps 已经正确地将 /admin 为前缀的请求转发给了你的 2334 端口绑定的服务。 你在 2334 端口绑定的服务,应该能够正确处理这个请求 PATH。 |
emmmm,locations只是将配置的字符串加到域名后面,可不可以配置转发请求时不把locations加到请求中?这样不用修改代码就能通过域名:端口/locations访问不同资源 |
路由的功能就是根据请求的某些不同参数将请求转发给对应的服务,不会对请求本身内容做任何修改。 你的需求应该通过 vhost 来实现,而不是通过 URL 路由。或者在你的服务前面再加一个 proxy (例如 nginx),来实现你的需求。 |
感谢大佬的协助~ |
每个人的需求不同,场景不同,作为一个反向代理,不修改请求内容是合理的。 |
你好,我也遇到了同样的问题。请问能以你上面举出的例子为例说一说你是怎么解决的吗?谢谢! |
使用nginx代理,监听 /admin 转发到本地服务 |
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通过路由区分访问网站
The text was updated successfully, but these errors were encountered: