mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[GH-ISSUE #2641] 现在能否实现1个顶级域名下面的泛域名全部协议,进行转发? #2104
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#2104
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 @haifding on GitHub (Oct 30, 2021).
Original GitHub issue: https://github.com/fatedier/frp/issues/2641
Describe the feature request
现在能否实现1个顶级域名下面的泛域名全部协议,进行转发?
情况说明:
1台内网服务器IP: 192.168.0.50
1台外网服务器IP:55.55.55.55. 域名: ccc.com
我想把所有访问 *.ccc.com 这个域名(包括所有子域名)的请求全部转发到 192.168.0.50 端口都是全部对应一样的(80对80端口,443对443端口)
要怎么弄,配置文件要怎么处理。主要是我这个子域名是会不停的增加的。
Describe alternatives you've considered
No response
Affected area
@blizard863 commented on GitHub (Oct 30, 2021):
可以,详细阅读一下文档。
@yusanshi commented on GitHub (Nov 1, 2021):
如果要强调全部端口/协议的话,你的这个需求是做不到的;如果只是要求 80/443 端口的话是没问题的。
比如现在顶级域名 ccc.com 和某个子域名 subdomain.ccc.com 都指向 55.55.55.55,如果我没有理解错的话,你是希望 subdomain.ccc.com 的所有端口都同端口转发到内网 192.168.0.50,但是直接访问 ccc.com 和 55.55.55.55 时能继续保持指向外网服务器。如果需求是这样的话,很多协议在工作时,服务端是没有办法知道客户端要访问的 hostname 是什么(比如 SSH 服务,你
ssh user@subdomain.ccc.com -p 22和ssh user@55.55.55.55 -p 22是等价的,没法一个到达外网服务器一个到达内网服务器)。如果只要求 HTTP/HTTPS 的话,HTTP 通过 Host Header、HTTPS 通过 Server Name Indication 来告诉服务端要访问的 hostname,这样服务端能区分请求是指向 55.55.55.55 还是 ccc.com 还是 subdomain.ccc.com,所以是可以实现的。比如下面结合 Nginx 的例子:
首先用外网服务器 8080/8443 端口来映射到内网服务器的 80/443 端口:
然后外网服务器添加 Nginx 配置(以 443 为例):
@haifding commented on GitHub (Nov 4, 2021):
我大概理解了,但是配置还是不会,运行不起来。达不到效果。
确实只需要 HTTP/HTTPS 转发就好。目的就是把内网服务器里面的网站全部给映射到外网上。
内网服务器(做web服务器) 192.168.0.50
外网服务器(就是做个转发) 55.55.55.55 域名 *.ccc.com 已经指向了该外网服务器,该域名的SSL也已经部署好了
我的内外网服务器都安装了宝塔,2台frp都正常启动了。
需求是外网访问子域名 https://a1.ccc.com 可以访问到内网服务器上的网站(内网服务器上也同样设置1个这样的域名a1.ccc.com的网站)。
至于主域名可以不用,IP也可以不用。
外网服务器的frps配置
[common]
bind_addr = 0.0.0.0
bind_port = 7000
bind_udp_port = 7001
外网的 Nginx 配置 配置了反向代理按上面的教程
内网服务器的frpc配置
[common]
server_addr = 55.55.55.55
server_port = 7000
[range:tcp_port]
type = tcp
local_ip = 127.0.0.1
local_port = 80,443
remote_port = 8080,8443
@GhostLee commented on GitHub (Nov 7, 2021):
我也有这个需求。。。。
由于远端服务器配置很弱,没有部署nginx,远端服务器A上只存在frps,监听来自外部的http或https请求,同时将监听到的请求转发给本地Nginx服务器B,本地Nginx服务器再根据自己的规则配置解析到不同的本地服务上。
现在使用的是监听80、443 tcp端口的方式,无法获取到用户的真实IP、无法使用Cloudflare的防护功能。
想知道有没有更优雅的方式来实现这种远端转发,本地解析的形式。
感谢各位大佬
@BackT0TheFuture commented on GitHub (Nov 8, 2021):
@GhostLee
你这完全用反了,nginx是一个功能强大的反代和webserver,有完备的安全、限流等等功能,而且如果仅仅用作反代和静态文件服务,占用内存也是很少的,frp应该放在反代后面,不应该直接对外暴露
@GhostLee commented on GitHub (Nov 8, 2021):
晓得了晓得了,我把nginx推到最外层,感谢大佬指正
@yusanshi commented on GitHub (Nov 8, 2021):
可以检查一下外网和内网服务器 Nginx 的日志:比如可以开两个终端分别连接两个服务器,
tail -f /var/log/nginx/access.log,然后浏览器访问 https://a1.ccc.com,检查两个日志是否都有实时输出,看看问题出在哪一步。另外,Nginx 默认的日志没有记录 Host header,可能不便于 debug,可以在 nginx.conf 里给两个 Nginx 的日志都加上 $http_host,比如这样:
@github-actions[bot] commented on GitHub (Dec 9, 2021):
Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.