webserver的http端口和ws端口都使用的是80端口,frpc仅配置了http协议,这种方式是不是无法正常穿透ws服务?
The solution you want
有何方式能同时实现http和ws吗?
如果是修改ws端口,再做ws的tcp穿透,这样的话每部署一次webserver就要修改一次ws端口了哇。
Alternatives considered
How to implement this function
Application scenarios of this function
ws 基于 HTTP,使用 HTTP 类型配置即可。
http端口和ws端口相同的话,frpc只需要设置一个http类型就行了吗?
[common]
server_addr = frp.xxx.xxxx
server_port = 7000
log_file = /var/log/frpc.log
token = xxxx
admin_addr = 0.0.0.0
admin_port = 7400
admin_user = admin
admin_pwd = xxxx
[frpcweb]
type = http
local_ip = 127.0.0.1
local_port = 80
subdomain = web
这样ws就可以正常穿透了吗?请问还有没有其他需要注意的?
在原有http端口上实现ws的情况下,发起ws请求时,原有的http Transport设置了DisableKeepAlives=true,因此在frps转发请求时发送的request请求会包含Connection: close头信息,导致ws服务会出现无法正常响应的问题。
可以在reverseproxy.go:L279设置DisableKeepAlives=false
if reqUpType != "" {
outreq.Header.Set("Connection", "Upgrade")
outreq.Header.Set("Upgrade", reqUpType)
//addg
p.Transport.(*http.Transport).DisableKeepAlives = false
}
Most helpful comment
http端口和ws端口相同的话,frpc只需要设置一个http类型就行了吗?
这样ws就可以正常穿透了吗?请问还有没有其他需要注意的?