Skip to content

A simple configurable Reverse Proxy for the Actix framework.

License

Notifications You must be signed in to change notification settings

felipenoris/actix-reverse-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages