axum-reverse-proxy 1.3.0

A flexible and efficient reverse proxy implementation for Axum web applications
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use axum::{Router, serve};
use axum_reverse_proxy::ReverseProxy;
use tokio::net::TcpListener;

#[tokio::main]
async fn main() {
    // Create a reverse proxy that forwards requests to httpbin.org
    let proxy = ReverseProxy::new("/", "https://httpbin.org");
    let app: Router = proxy.into();

    // Create a TCP listener
    let listener = TcpListener::bind("0.0.0.0:3000").await.unwrap();
    println!("Server running on http://localhost:3000");

    // Run the server
    serve(listener, app).await.unwrap();
}