{"id":16801087,"url":"https://github.com/daxpedda/axum-server-dual-protocol","last_synced_at":"2026-03-14T03:30:46.308Z","repository":{"id":50403198,"uuid":"518933689","full_name":"daxpedda/axum-server-dual-protocol","owner":"daxpedda","description":"Host a HTTP and HTTPS server on the same port with `axum-server`","archived":false,"fork":false,"pushed_at":"2024-07-31T14:01:31.000Z","size":190,"stargazers_count":18,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T05:52:21.420Z","etag":null,"topics":["axum","axum-server","rust","server","web"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daxpedda.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["daxpedda"]}},"created_at":"2022-07-28T17:17:15.000Z","updated_at":"2025-01-19T17:59:32.000Z","dependencies_parsed_at":"2023-12-06T12:31:38.031Z","dependency_job_id":"4ae46382-b021-4564-befe-d6e1cf85adf4","html_url":"https://github.com/daxpedda/axum-server-dual-protocol","commit_stats":{"total_commits":61,"total_committers":2,"mean_commits":30.5,"dds":0.08196721311475408,"last_synced_commit":"fc8e1870cedc88d1f2762a1ac31929d48837e82a"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daxpedda%2Faxum-server-dual-protocol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daxpedda%2Faxum-server-dual-protocol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daxpedda%2Faxum-server-dual-protocol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daxpedda%2Faxum-server-dual-protocol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daxpedda","download_url":"https://codeload.github.com/daxpedda/axum-server-dual-protocol/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253141392,"owners_count":21860535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["axum","axum-server","rust","server","web"],"created_at":"2024-10-13T09:35:52.380Z","updated_at":"2026-03-14T03:30:46.273Z","avatar_url":"https://github.com/daxpedda.png","language":"Rust","funding_links":["https://github.com/sponsors/daxpedda"],"categories":[],"sub_categories":[],"readme":"# axum-server-dual-protocol\n\n[![Crates.io Version](https://img.shields.io/crates/v/axum-server-dual-protocol.svg)](https://crates.io/crates/axum-server-dual-protocol)\n[![Live Build Status](https://img.shields.io/github/check-runs/daxpedda/axum-server-dual-protocol/main?label=CI)](https://github.com/daxpedda/axum-server-dual-protocol/actions?query=branch%3Amain)\n[![Docs.rs Documentation](https://img.shields.io/docsrs/axum-server-dual-protocol?label=docs.rs)](https://docs.rs/crate/axum-server-dual-protocol)\n[![Main Documentation](https://img.shields.io/github/actions/workflow/status/daxpedda/axum-server-dual-protocol/documentation.yaml?branch=main\u0026label=main%20docs)](https://daxpedda.github.io/axum-server-dual-protocol/axum_server_dual_protocol/index.html)\n\n## Description\n\nProvides utilities to host a [`axum-server`] server that accepts the HTTP and HTTPS protocol on the\nsame port. See [`bind_dual_protocol()`].\n\nA common use case for this is if a HTTPS server is hosted on a non-traditional port, having no\ncorresponding HTTP port. This can be an issue for clients who try to connect over HTTP and get a\nconnection reset error. See [`ServerExt::set_upgrade()`].\n\n## Usage\n\nThe simplest way to start is to use [`bind_dual_protocol()`]:\n\n```rust\nlet app = Router::new().route(\n\t\"/\",\n\trouting::get(|request: Request\u003cBody\u003e| async move {\n\t\tmatch request.extensions().get::\u003cProtocol\u003e().unwrap() {\n\t\t\tProtocol::Tls =\u003e \"Hello, secure World!\",\n\t\t\tProtocol::Plain =\u003e \"Hello, insecure World!\",\n\t\t}\n\t}),\n);\n\n// User-supplied certificate and private key.\nlet config = RustlsConfig::from_der(certificate, private_key).await?;\n\naxum_server_dual_protocol::bind_dual_protocol(address, config)\n\t.serve(app.into_make_service())\n\t.await?;\n```\n\nWe now have a server accepting both HTTP and HTTPS requests! Now we can automatically upgrade\nincoming HTTP requests to HTTPS using [`ServerExt::set_upgrade()`] like this:\n\n```rust\nuse axum_server_dual_protocol::ServerExt;\n\naxum_server_dual_protocol::bind_dual_protocol(address, config)\n\t.set_upgrade(true)\n\t.serve(app.into_make_service())\n\t.await?;\n```\n\nAlternatively [`UpgradeHttpLayer`] can be used:\n\n```rust\nlet app = Router::new()\n\t.route(\"/\", routing::get(|| async { \"Hello, world!\" }))\n\t.layer(UpgradeHttpLayer);\n```\n\n## Features\n\n### `default`\n\nBy default the [`aws-lc-rs`] [`CryptoProvider`] is enabled.\n\n## Conditional Configurations\n\n### `docsrs`\n\nThis requires Rust nightly and enhances the documentation. It must only be used with `RUSTDOCFLAGS`,\nnot with `RUSTFLAGS`.\n\n## MSRV\n\nAs this library heavily relies on [`axum-server`], [`axum`], [`tower`] and [`hyper`] the MSRV\ndepends on theirs. At the point of time this was written the highest MSRV was [`axum`] with 1.66.\n\n## Changelog\n\nSee the [CHANGELOG] file for details.\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE] or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT license ([LICENSE-MIT] or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the\nwork by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any\nadditional terms or conditions.\n\n[CHANGELOG]: https://github.com/daxpedda/axum-server-dual-protocol/blob/v0.7.0/CHANGELOG.md\n[LICENSE-MIT]: https://github.com/daxpedda/axum-server-dual-protocol/blob/v0.7.0/LICENSE-MIT\n[LICENSE-APACHE]: https://github.com/daxpedda/axum-server-dual-protocol/blob/v0.7.0/LICENSE-APACHE\n[`aws-lc-rs`]: https://docs.rs/aws-lc-rs/1\n[`axum`]: https://docs.rs/axum/0.7\n[`axum-server`]: https://docs.rs/axum-server/0.7.0\n[`bind_dual_protocol()`]:\n\thttps://docs.rs/axum-server-dual-protocol/0.7.0/axum_server_dual_protocol/fn.bind_dual_protocol.html\n[`CryptoProvider`]: https://docs.rs/rustls/0.23/rustls/crypto/struct.CryptoProvider.html\n[`hyper`]: https://docs.rs/hyper/1\n[`Layer`]: https://docs.rs/tower-layer/0.3/tower_layer/trait.Layer.html\n[`Router`]: https://docs.rs/axum/0.7/axum/struct.Router.html\n[`ServerExt::set_upgrade()`]:\n\thttps://docs.rs/axum-server-dual-protocol/0.7.0/axum_server_dual_protocol/trait.ServerExt.html#tymethod.set_upgrade\n[`tower`]: https://docs.rs/tower/0.4\n[`UpgradeHttpLayer`]:\n\thttps://docs.rs/axum-server-dual-protocol/0.7.0/axum_server_dual_protocol/struct.UpgradeHttpLayer.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaxpedda%2Faxum-server-dual-protocol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaxpedda%2Faxum-server-dual-protocol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaxpedda%2Faxum-server-dual-protocol/lists"}