Coder Social home page Coder Social logo

reverse-proxy's Introduction

Reverse Proxy

Description

In addition to fulfilling the typical functionality of a reverse proxy, this tool is capable of blocking requests based on a specified list of blockers. Additionally, it has the functionality to conceal sensitive information in the response body. Notably, this feature is applied exclusively to the response of GET requests.

Features

  • Configuration file-based setting of blockers.
  • Blocker list includes MethodBlocker, PathBlocker, ParamBlocker, and HeaderBlocker.
  • Includes two maskers: CreditCardMasker, EmailMasker.
  • Easy to extend with new blockers and maskers.
  • Log all incoming requests and responses in human-readable format.
  • Simple, only use standard library besides a logger.
  • Graceful shutdown.
  • Support for https target servers.

How to Set Up

Prerequisites

Configuration

The app uses a configuration file in TOML format. The configuration path is set with -config command option when running the app. The app will use an example configuration file in internal/config/example_config.toml if not provided.

Toml example

TargetURL = "http://localhost:8080"
ReverseProxyPort = 8081
[HeaderBlocker]
  [HeaderBlocker.HeaderMap]
    X-Blocker = "Block"
    Authorization = "Secret"
[ParamBlocker]
  [ParamBlocker.ParamsMap]
    apikey = "token"
[PathBlocker]
  path = ["/admin", "/private"]
[MethodBlocker]
  method = ["POST", "PUT"]

Build the app

make build

And then run the app with the configuration file path

./reverse-proxy -config /folder/config.toml

Run the examples

Run the example to test against a mock target server:

make example

After running make example, you can test the reverse proxy with the target_server_example located in test/ folder.

curl -X GET -v http://localhost:8081/get 

Run the tests

make tests

Future Work - Nice To Have

  • In order to be production ready it needs more work with:
    • Streaming.
    • Websockets.
    • Compresses data.
    • More testing with the mask to avoid leaks.
  • Healthcheck, readiness endpoint.
  • Expose the reverse proxy with TLS support.
  • Add Timeout configuration to the reverse proxy.
  • Metrics.
  • Benchmarking and performance testing:
    • Improve the mask regexes with others libs hyperscan re2
    • Check blockers concurrently.
  • Add more test cases of strange and edge cases.

Contributors

reverse-proxy's People

Contributors

sgrodriguez avatar

Stargazers

 avatar

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.