axum-server icon indicating copy to clipboard operation
axum-server copied to clipboard

HTTP and HTTPS on the same port

Open daxpedda opened this issue 3 years ago • 7 comments

I wrote an Acceptor that allows handling of HTTP and HTTPS on the same port. The implementation is fairly minimal and simple. Is it in scope for axum-server to add something like this? Happy to start a PR of course.

My use-case is hosting a HTTPS server on a custom port, unlike the example, there is only one port. So connecting with HTTP to that server errors out. The idea is if I accept both protocols, I can design a middleware that handles the redirect.

daxpedda avatar Jul 25 '22 21:07 daxpedda

I think it is out of scope. Keep the issue open for a while in case there is a demand for this.

programatik29 avatar Jul 25 '22 22:07 programatik29

I released a crate doing all of this now: https://crates.io/crates/axum-server-dual-protocol.

daxpedda avatar Jul 28 '22 20:07 daxpedda

When I send http request to my https server, the server just close the connection, reply me nothing, while I expect an error code like 497.

hangj avatar Sep 19 '22 08:09 hangj

@hangj I assume you mean this is the current behavior of axum-server and not axum-server-dual-protocol?

daxpedda avatar Sep 19 '22 08:09 daxpedda

@daxpedda yes, its the current behavior of axum-server

hangj avatar Sep 19 '22 08:09 hangj

When I send http request to my https server, the server just close the connection, reply me nothing, while I expect an error code like 497.

You can't use same port for http and https if you are asking that. You might want to check out axum-server-dual-protocol if you want to do that. If the problem is that https not working then write an example and I will look into it.

programatik29 avatar Sep 20 '22 13:09 programatik29

When I send http request to my https server, the server just close the connection, reply me nothing, while I expect an error code like 497.

You can't use same port for http and https if you are asking that. You might want to check out axum-server-dual-protocol if you want to do that. If the problem is that https not working then write an example and I will look into it.

Thank you, I'll check it out, and see what I can do.

hangj avatar Sep 20 '22 17:09 hangj