http-to-https-redirect 0.1.0

A lightweight HTTP to HTTPS redirect server
http-to-https-redirect-0.1.0 is not a library.

http-to-https-redirect

A lightweight Rust server that listens on port 80 and automatically redirects all HTTP requests to HTTPS using 301 (Moved Permanently) status codes, preserving the hostname, path, and query parameters.

Features

  • Automatic HTTP to HTTPS redirection with 301 status code
  • Preserves full request URI (path and query parameters)
  • Respects the Host header for proper domain redirection
  • Lightweight and fast, built with Hyper and Tokio
  • Zero configuration needed

Installation

cargo install http-to-https-redirect

Usage

Simply run the binary with appropriate permissions:

sudo http-to-https-redirect

Note: Running on port 80 requires root privileges or CAP_NET_BIND_SERVICE capability.

Running without sudo (Linux)

Grant the binary permission to bind to privileged ports:

sudo setcap 'cap_net_bind_service=+ep' $(which http-to-https-redirect)
http-to-https-redirect

Example

When a client requests:

http://example.com/path?query=value

They will be redirected to:

https://example.com/path?query=value

Use Case

Run this alongside your HTTPS server to ensure all traffic uses secure connections. This is particularly useful for:

  • Enforcing HTTPS across your entire site
  • Meeting security requirements that mandate encrypted connections
  • Improving SEO (search engines prefer HTTPS)
  • Providing a seamless redirect experience for users

Building from Source

git clone https://github.com/jvtubergen/http-to-https-redirect
cd http-to-https-redirect
cargo build --release

The binary will be available at target/release/http-to-https-redirect.

License

Licensed under the MIT License. See LICENSE.md or http://opensource.org/licenses/MIT for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.