Skip to main content

Turn any Gunicorn application into a Tor Onion Service

Project description

Gunicorn Torify

Turn any Gunicorn server into a Tor Onion Service

Installation

It's available on PyPI! Just use pip to install

$ pip install gunicorn-torify

You must have Tor installed to use gunicorn-torify. This might look like

$ pacman -S tor    # Arch
$ apt install tor  # Debian/Ubuntu
$ apk add tor      # Alpine

Usage

Just add these imports to your Gunicorn config file (or create some python file such as ./gunicorn-conf.py with the line):

from gunicorn_torify import on_starting, on_exit

When starting Gunicorn, be sure to include the --config ./gunicorn-conf.py flag.

Persistence

By default, the Onion Service will store its secret keys in ./secrets/tor. To override this you can set the TOR_SERVICE_DIR environment variable before running for the first time. According to the tor docs this directory contains private keys and should be treated carefully.

If deploying in Docker, it's important to persist this directory (otherwise your onion address could change) either with a named volume or a mapped directory. An example deployment could be done with

$ docker volume create my-onion-service
$ docker run -v my-onion-service:/app/secrets/tor afiorillo/gunicorn-torify:flask

Contributing

To setup the development environment, it's convenient to use pyenv and the pyenv virtualenv plugin. For example

$ pyenv virtualenv 3.8.1 gunicorn-torify-3.8
$ pyenv activate gunicorn-torify-3.8
$ pip install -r requirements_dev.txt

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 gunicorn-torify, version 19.12.2710
Filename, size File type Python version Upload date Hashes
Filename, size gunicorn_torify-19.12.2710-py3-none-any.whl (4.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size gunicorn-torify-19.12.2710.tar.gz (3.1 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 DigiCert DigiCert EV certificate StatusPage StatusPage Status page