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

Serve same app on http and https #108

Open
hpsjakob opened this issue Jan 25, 2024 · 1 comment
Open

Serve same app on http and https #108

hpsjakob opened this issue Jan 25, 2024 · 1 comment

Comments

@hpsjakob
Copy link

Hello,

thanks for developing this very useful crate!
I want to run a server that serves the same app with http and https on different ports.
I've seen there's an example for running different apps on http and https.
I could achieve this by running app.clone():

let a = axum_server::bind_rustls(
    "0.0.0.0:8080".parse().unwrap(),
    tls_config,
)
  .handle(server_handle)
  .serve(app.clone().into_make_service());
let b = axum_server::bind("0.0.0.0:8081".parse().unwrap()).serve(app.into_make_service());
select! {
    _ = a => {},
    _ = b => {}
}

However, this increased the memory usage of the server significantly. So I'm wondering if there is a better way to achieve this? Can someone maybe give me a hint?

@hpsjakob hpsjakob changed the title Serve http and https Serve same app on http and https Jan 25, 2024
@hpsjakob
Copy link
Author

I just measured the RAM usage again and found that my previous results were not accurate. The clone does not cost measurable more memory.

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

No branches or pull requests

1 participant