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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for gunicorn-torify-19.12.2710.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3a7f1ab2f88d725a6cb9ba7f89a0a073e8375248857ee5dc17aa466ab13a565 |
|
MD5 | 752fcebd4659c18d765766a3a15bc27d |
|
BLAKE2b-256 | 492b30a62e2a4f50a98aff315a3e74fa68f15bb3b69aa775b587204f12f6d74b |
Hashes for gunicorn_torify-19.12.2710-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f98a5917f6e92a559ed6076e039cb1432c332dd30291f26cf21059a7d9348e5 |
|
MD5 | 2a1d19bec9c5b0870a9918b92dd5b3f8 |
|
BLAKE2b-256 | d0e424c3e6d6db5a8b081018fb15e352762d17856434f1d9c6db2de746eb2674 |