Skip to content
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

Hertz做http反向代理时,遇到协议升级没能正确处理 #1249

Closed
shawdongGithub opened this issue Dec 15, 2024 · 4 comments
Closed
Labels

Comments

@shawdongGithub
Copy link

shawdongGithub commented Dec 15, 2024

Describe the bug
使用hertz做7层http反向代理,没有正确处理协议升级。
To Reproduce

  1. 反向代理的相关代码
# packge hadler
func Proxy(ctx context.Context, c *app.RequestContext) {
	target := "http://xx.xx.xx.xx:port"
	p, _ := reverseproxy.NewSingleHostReverseProxy(target)
	p.ServeHTTP(ctx, c)
}
  1. hertz 服务启动的相关代码
func main() {
	h := server.Default()
	h.NoRoute(handler.Proxy)
	h.Spin()
}
  1. 当我代理的目标站点存在某个websocket连接资源时,会报错无法建立websocket连接。

Expected behavior
hertz作为http7层反向代理时能够正确处理协议升级维持长连接

Hertz version: v0.9.3

@github-actions github-actions bot added the invalid issue invalid issue (not related to Hertz or described in document or not enough information provided) label Dec 15, 2024
Copy link

This issue has been marked as invalid question, please give more information by following the issue template. The issue will be closed in 1 days if no further activity occurs.

@github-actions github-actions bot added stale and removed invalid issue invalid issue (not related to Hertz or described in document or not enough information provided) labels Dec 15, 2024
@shawdongGithub shawdongGithub changed the title Hertz做http反向代理时,没处理协议升级 Hertz做http反向代理时,遇到协议升级没能正确处理 Dec 16, 2024
@xiaost
Copy link
Contributor

xiaost commented Dec 18, 2024

暂不支持。

@xiaost xiaost closed this as completed Dec 18, 2024
@rogerogers
Copy link
Contributor

reverseproxy 有个 NewWSReverseProxy 方法能满足需求吗

@shawdongGithub
Copy link
Author

reverseproxy 有个 NewWSReverseProxy 方法能满足需求吗

针对特定的url直接配置成NewWSReverseProxy确实能满足,但比较麻烦不太灵活。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants