1
0
mirror of https://github.com/actix/examples synced 2024-11-27 16:02:57 +01:00
examples/middleware/http-to-https/README.md

21 lines
832 B
Markdown
Raw Permalink Normal View History

2022-02-18 03:18:44 +01:00
## Middleware: Redirect Any HTTP Connection To Use HTTPS Connection
2022-06-26 06:07:57 +02:00
## Alternatives
2024-05-25 06:36:36 +02:00
A pre-built solution is soon to be built-in. For now, see [`RedirectHttps`](https://docs.rs/actix-web-lab/0.20/actix_web_lab/middleware/struct.RedirectHttps.html) from [`actix-web-lab`](https://crates.io/crates/actix-web-lab).
2022-06-26 06:07:57 +02:00
## This Example
2024-07-19 16:44:43 +02:00
This example is the next step after implementing this example : [Setup TLS via rustls](https://github.com/actix/examples/tree/master/https-tls/rustls).
2022-02-18 03:18:44 +01:00
You might have already implemented TLS (using one of the ways mentioned in the example of security section), and have setup your server to listen to port 443 (for HTTPS).
2022-02-18 03:18:44 +01:00
Now, the only problem left to solve is, to listen to **HTTP** connections as well and redirect them to use **HTTPS**
2022-02-18 03:19:57 +01:00
## Usage
2022-02-18 04:36:04 +01:00
```sh
2023-10-30 00:51:05 +01:00
cd middleware/http-to-https
2022-02-18 03:19:57 +01:00
cargo run
```