Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/felipenoris/actix-reverse-proxy

A simple configurable Reverse Proxy for the Actix framework.
https://github.com/felipenoris/actix-reverse-proxy

Last synced: 3 months ago
JSON representation

A simple configurable Reverse Proxy for the Actix framework.

Awesome Lists containing this project

README

        

# actix-reverse-proxy

[![License][license-img]](LICENSE)
[![travis][travis-img]][travis-url]

[license-img]: http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat
[travis-img]: https://img.shields.io/travis/felipenoris/actix-reverse-proxy/master.svg?label=Linux
[travis-url]: https://travis-ci.org/felipenoris/actix-reverse-proxy
[![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.](https://www.repostatus.org/badges/latest/abandoned.svg)](https://www.repostatus.org/#abandoned)

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](https://github.com/felipenoris/hyper-reverse-proxy) (see discussion [here](https://github.com/DoumanAsh/actix-reverse-proxy/issues/2)).

## Working Example

Create a new project.

```shell
cargo new myproxy
```

Add the following to your `Cargo.toml`.

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

```rust
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 {
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();
}
```