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

期望启用https时提供http的重定向能力 #1240

Closed
Jeremyly opened this issue Nov 28, 2024 · 2 comments
Closed

期望启用https时提供http的重定向能力 #1240

Jeremyly opened this issue Nov 28, 2024 · 2 comments

Comments

@Jeremyly
Copy link

Is your feature request related to a problem? Please describe.

用户有时候访问时,可能输入的是http,但监听的是https。目前提供的WithTLS()不具备该参数。且http请求直接被拒绝,没有开放自定义处理的接口。

Describe the solution you'd like

期望的是,提供一个配置方法,支持自定义处理http请求,比如重定向到https。

Additional context

hertz version: v0.9.3

@xiaost
Copy link
Contributor

xiaost commented Dec 6, 2024

重定向,只需要几行代码,没必要放到hertz本身实现。如果有需要,请自行重定向。

@xiaost xiaost closed this as completed Dec 6, 2024
@Jeremyly
Copy link
Author

Jeremyly commented Dec 6, 2024

重定向,只需要几行代码,没必要放到hertz本身实现。如果有需要,请自行重定向。

关键在于https并不是使用默认端口443。而是使用了特定的端口,一个端口只能起一个监听。无法再起一个同端口的http监听的呀。
比如正确的访问路径是:https://127.0.0.1:8443/ping。但是由于用户未输入s:http://127.0.0.1:8443/ping。此时框架报错:

[Error] HERTZ: Error=tls: first record does not look like a TLS handshake, remoteAddr=127.0.0.1:54825
[Error] HERTZ: Error=remote error: tls: unknown certificate, remoteAddr=127.0.0.1:54910

我期望的就是这种场景,可以提供一个自定义接口,可以由用户自定义处理这种错误。

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

No branches or pull requests

2 participants