programatik29 / axum-server

High level server designed to be used with axum framework.
MIT License
168 stars 56 forks source link

HTTP and HTTPS on the same port #48

Open daxpedda opened 1 year ago

daxpedda commented 1 year ago

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.

programatik29 commented 1 year ago

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

daxpedda commented 1 year ago

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

hangj commented 1 year ago

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.

daxpedda commented 1 year ago

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

hangj commented 1 year ago

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

programatik29 commented 1 year ago

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.

hangj commented 1 year ago

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.