mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[GH-ISSUE #2258] url routing 只能访问根目录,如何配置使其递归访问所有资源 #1793
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#1793
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 @deqoder on GitHub (Feb 26, 2021).
Original GitHub issue: https://github.com/fatedier/frp/issues/2258
版本
客户端与服务器用的都是最新0.35.1
配置文件
frps.ini配置了bind_port和vhost_http_portfrpc.ini[common]段配置了server_addrserver_port[web-laptop]段配置了typelocal_portlocationscustom_domains,其中locations = /laptop测试
测试一:通过服务器IP加
vhost_http_port端口,加/laptop可以访问本地网页根目录,但发现网页中请求的其他资源无法访问测试二:修改网页中资源的请求路径为相对路径,结果其他资源仍无法访问,返回404
测试三:修改
frpc.ini中的locations = /laptop/,多了个斜杠,结果返回200,但内容却是根目录的网页,我的网页在本地127.0.0.1访问都正常。测试四:内网自己写的http服务器增加请求的url输出,远程访问,内网控制台显示,请求的url都是
/laptop/xxx,也就是是由于我内网服务器找不到资源,默认返回了根目录。所以,location字段好像只是路由,并没有替换请求的url问题
怎么配置才能递归访问所有资源。
@fatedier commented on GitHub (Feb 26, 2021):
locations = /laptop会将所有 URL Prefix 为/laptop的 HTTP 请求转发给你的应用,前提是你自己的 HTTP 服务确实是使用这样的请求路径,frp 不会修改任何你的网页内容。你的场景应该是内网服务自身去增加
/laptop这个 URL 前缀。@deqoder commented on GitHub (Feb 26, 2021):
@fatedier 我这个'laptop'是作为客户端id的,所以你说内网服务自身增加'/laptop'这个前缀不现实。我知道正规的做法是通过子域名来区分,但我目前服务器没域名,所以想通过增加url路径前缀来区分。
应该能修改源码实现,代理时r.url.path去掉一层就行了,只是我不知道修改哪个文件哪一行
@fatedier commented on GitHub (Feb 26, 2021):
在你的内网服务前加上 nginx 之类的代理,应该可以通过配置实现你的需求。