1
0
mirror of https://github.com/actix/examples synced 2024-11-23 22:41:07 +01:00
examples/middleware/middleware-http-to-https
2022-12-30 16:25:40 +00:00
..
src Use captured args in format string (#558) 2022-06-08 03:53:38 +01:00
Cargo.toml use workspace deps for log and env_logger 2022-12-30 16:25:40 +00:00
cert.pem add background-jobs example 2022-12-30 16:23:24 +00:00
key.pem add background-jobs example 2022-12-30 16:23:24 +00:00
README.md add middleware-encrypted-payloads example 2022-12-18 21:10:03 +00:00

Middleware: Redirect Any HTTP Connection To Use HTTPS Connection

Alternatives

A pre-built solution is soon to be built-in. For now, see RedirectHttps from actix-web-lab.

This Example

This example is the next step after implementing this example : Setup TLS via rustls.

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).

Now, the only problem left to solve is, to listen to HTTP connections as well and redirect them to use HTTPS

Usage

cd middleware/middleware-http-to-https
cargo run