[GH-ISSUE #2195] ws和http #1750

Closed
opened 2026-05-05 13:07:35 -06:00 by gitea-mirror · 4 comments
Owner

Originally created by @jlikeme on GitHub (Jan 17, 2021).
Original GitHub issue: https://github.com/fatedier/frp/issues/2195

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

Originally created by @jlikeme on GitHub (Jan 17, 2021). Original GitHub issue: https://github.com/fatedier/frp/issues/2195 <!-- From Chinese to English by machine translation, welcome to revise and polish. --> webserver的http端口和ws端口都使用的是80端口,frpc仅配置了http协议,这种方式是不是无法正常穿透ws服务? **The solution you want** <!--A clear and concise description of the solution you want. --> 有何方式能同时实现http和ws吗? 如果是修改ws端口,再做ws的tcp穿透,这样的话每部署一次webserver就要修改一次ws端口了哇。 **Alternatives considered** <!--A clear and concise description of any alternative solutions or features you have considered. --> **How to implement this function** <!--Implementation steps for the solution you want. --> **Application scenarios of this function** <!--Make a clear and concise description of the application scenario of the solution you want. -->
gitea-mirror 2026-05-05 13:07:36 -06:00
Author
Owner

@fatedier commented on GitHub (Jan 17, 2021):

ws 基于 HTTP,使用 HTTP 类型配置即可。

<!-- gh-comment-id:761806904 --> @fatedier commented on GitHub (Jan 17, 2021): ws 基于 HTTP,使用 HTTP 类型配置即可。
Author
Owner

@jlikeme commented on GitHub (Jan 17, 2021):

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就可以正常穿透了吗?请问还有没有其他需要注意的?

<!-- gh-comment-id:761811539 --> @jlikeme commented on GitHub (Jan 17, 2021): 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就可以正常穿透了吗?请问还有没有其他需要注意的?
Author
Owner

@jlikeme commented on GitHub (Jan 18, 2021):

在原有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
	}

<!-- gh-comment-id:762189292 --> @jlikeme commented on GitHub (Jan 18, 2021): 在原有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 } ```
Author
Owner

@github-actions[bot] commented on GitHub (Mar 5, 2021):

Issues go stale after 45d of inactivity. Stale issues rot after an additional 10d of inactivity and eventually close.

<!-- gh-comment-id:791071377 --> @github-actions[bot] commented on GitHub (Mar 5, 2021): Issues go stale after 45d of inactivity. Stale issues rot after an additional 10d of inactivity and eventually close.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#1750
No description provided.