Skip to main content

A simple python wrapper script for bootstrapping a reverse proxy inside a docker container.

Project description

Build Status PyPI License PyPI Version PyPI Python versions

A simple yet extensible python wrapper script for templating a proxy nginx configuration that functions as host mapped reverse proxy container.

Why and when to use?

Modern browsers enforce CORS policy and won’t let you make requests from your frontend running on localhost:8080 to your backend at localhost:4000. To solve this problem, start a proxy at localhost:5000 (or any other spare port) and proxy requests based on paths:

  • localhost:5000/api and localhost:5000/buy will be routed to the backend localhost:4000
  • localhost:5000/ will be routed to the frontend localhost:8080

Installation and usage

pip install proxybootstrap # using pip
pipx install proxybootstrap # using pipx

Note: You will need docker for running the proxy container

Start the proxy server with your configuration

python \
    --port 5000 \
    /api@ /buy@ /@


Option Description Default
locations service locations to proxy. None
-c / -config nginx config template file ./config/default.conf
--port listening port for the reverse proxy 5000
--verbose enable verbose output False
--sync force synchronous communication with the proxy False
--tag docker tag for the reverse proxy container dev/cors-reverse-proxy
--dockerfile dockerfile for building the container ./Dockerfile

Under the hood, configuration options are applied to the --config template file and rendered using jinja2. If you wish, you can pass additional arguments and use them in the config template. Example:

python \
    -my_var1 Test1 \
    --my_var2 Test2 \
    --port 5000 \

can be accessed in a template with

{{ my_var1 }}
{{ my_var2 }}


  • Write a custom proxy configuration for nginx or other proxy servers like trafik, envoy or haproxy
  • When using webpack or another popular tool there might be some plugins like devserver-proxy for vuejs
  • Mess around with headers to allow specific CORS requests


If you do not have pipx and pipenv, install with

python3 -m pip install --user pipx
python3 -m pipx ensurepath
pipx install pipenv

Install all dependencies with

pipenv install --dev

To format, sort imports and check PEP8 conformity, run

pipenv run black .
pipenv run isort
pipenv run flake8

(These are also configured as a git pre commit hook)


This configuration is very minimal and intended for development use only.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for proxybootstrap, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size proxybootstrap-0.1.3.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page