literadix / actix-reverse-proxy

A simple configurable Reverse Proxy for the Actix framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

actix-reverse-proxy

License travis

Project Status: Abandoned – Initial development has started, but there has not yet been a stable, usable release; the project has been abandoned and the author(s) do not intend on continuing development.

This is a simple configurable Reverse Proxy for Actix framework.

Based on https://github.com/DoumanAsh/actix-reverse-proxy.

This project has been abandoned in favor of hyper-reverse-proxy (see discussion here).

Working Example

Create a new project.

cargo new myproxy

Add the following to your Cargo.toml.

[dependencies]
actix-web = "0.7"
futures = "0.1"
actix-reverse-proxy = { git = "https://github.com/felipenoris/actix-reverse-proxy" }

Edit main.rs with the following. In this example, calls to http://0.0.0.0:13900/dummy/anything?hey=you will be proxied to http://127.0.0.1:13901/dummy/anything?hey=you.

extern crate actix_web;
extern crate futures;
extern crate actix_reverse_proxy;

use actix_web::{server, App, HttpRequest};
use futures::Future;
use actix_reverse_proxy::ReverseProxy;

use std::time::Duration;

const REVERSE_PROXY_BIND_ADDRESS: &'static str = "0.0.0.0:13900";

fn dummy(req: HttpRequest) -> impl Future<Item=actix_web::HttpResponse, Error=actix_web::Error> {
    ReverseProxy::new("http://127.0.0.1:13901")
        .timeout(Duration::from_secs(1))
        .forward(req)
}

fn main() {
    server::new(|| App::new()
            .resource("/dummy/{tail:.*}", |r| r.with_async(dummy))
        )
        .bind(REVERSE_PROXY_BIND_ADDRESS)
        .unwrap()
        .run();
}

About

A simple configurable Reverse Proxy for the Actix framework.

License:MIT License


Languages

Language:Rust 100.0%