Code Monkey home page Code Monkey logo

hrt-rust-reverse-proxy's Introduction

Simple And Minimal Rust Reverse Proxy

How to test it

Add this entries to /etc/hosts:

test1.local 127.0.0.1
test2.local 127.0.0.1
test3.local 127.0.0.1

Open 3 terminals:

Terminal One:

cd hrt-reverse-proxy
cargo run
....
LISTEN on 127.0.0.1:13900

Terminal Two:

# test1.local
cd hrt-reverse-proxy/html
php -S localhost:13901

Terminal Three:

curl -L -X GET http://test1.local:13900

And you will see that the request will be redirected according to your host.

How To Configure:

Go to config/config.json and change your configuration to your needs. You can redirect request by host header or by path. There are no other options for now. You can change the bind address and port to your needs. If port is 80, it must be run as root. For example, if you want to redirect mysite.com to localhost:8080, you will write this in config/config.json:

{
    "bind_to_host": "127.0.0.1",
    "bind_to_port": "80",
    "routes": [
        {
            "match": "mysite.com",
            "type": {
                "what": "header"
            },
            "forward_to": "http://localhost:8080"
        }
    ]
}

Build Release

cargo build --release

hrt-rust-reverse-proxy's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.