Giter Site home page Giter Site logo

proxy-demo's Introduction

proxy-demo

Demo project of HTTP proxy server with JWT encoded header injection support.

Requirement: Python 3.10, SQLAlchemy, Flask, uWSGI

ย 

Local server setup

Note that local server usage is for testing only!

Install the requirements:

$ pip3 install -r requirements.txt

Run server:

$ python3 -m proxy.uwsgi

For older Flask versions, you can use FLASK_ENV to enable development config:

$ FLASK_ENV=Development python3 -m proxy.uwsgi

Status page should be available now: http://<ip_or_domain>:8077/api/v1/status

Default server public port is 8077.

You can change it by setting environment variable HTTP_PORT via CLI:

$ HTTP_PORT=7171 python3 -m proxy.uwsgi

or via .env file.

Docker compose management

Build docker image:

$ make build

Start proxy:

$ make

or

$ make start

Status page should be available now: http://<ip_or_domain>:8077/api/v1/status

Stop proxy:

$ make stop

Restart proxy:

$ make restart

Display docker logs:

$ make logs

Default server public port is 8077.

You can change it by setting environment variable HTTP_PORT via CLI:

$ HTTP_PORT=7171 make build
$ HTTP_PORT=7171 make start
$ HTTP_PORT=7171 make test

or via .env file.

API

Proxy status page:

$ [GET] /api/v1/status

Proxy JWT injection:

$ [POST] /api/v1/proxy-jwt

Payload: { "payload": "sample_data" }
Returns: JSON with original + injected JWT headers, original payload

Proxy dummy echo service:

$ [POST] /api/v1/echo

Payload: { "payload": "sample_data" }
Returns: JSON with original headers and original payload

CURL testing example:

$ curl http://localhost:8077/api/v1/proxy-jwt -H "Content-Type: application/json" -d '{ "payload": "sample_data" }' -v | jq .

Automatic tests

Python unittest is using to cover test cases. Below installs test env requirements and run the tests.

$ make test

Logs

Logs are stored to the 'logs' dir inside container.

Logs dir is also exposed via docker-compose "volumes", so you can check log files directly at 'logs' dir where docker-compose is called from.

system.log - Contains system events and requests data

db.log - Contains database related events

uwsgi.log - Contains uWSGI HTTP server events

Documentation

In-code documentation is avaiable:

$ python3 -c "import proxy; help(proxy)"

proxy-demo's People

Contributors

dkashin avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

josephril

proxy-demo's Issues

Update the admin code with admin web files

Hello Dmitry,

Kindly update the repository frontend for node Admin control for accounts & adding Nodes.

if this a commercial license kindly ping me official email ID

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.