This buildpack sets up a Tor v3 onion service for your application on Heroku. v2 has been disabled as of 2021.
I will be regularly and manually updating the Tor version and my doing so may require you to clear your build cache upon your next git push for your application. Easy instructions can be found here. This is in order to stay current with Tor's bugfixes and patches.
This buildpack is meant for hobbyists and is not intended for use involving any serious requirement of anonymity. If you are deploying for any such purpose, please look into other sources and methods.
-
Install the buildpack like you would with any other buildpack
-
Modify your
Procfile
as follows:web: ./tor/bin/run_tor & <your-usual-dyno-cmd>
-
Deploy your application
-
Run
heroku logs --tail
to see the.onion
address you generated; with this setup the address will change with each redeploy, but the next section will explain how to set up a persistent address
- Obtain the following files for a
.onion
address by using mkp224ohostname
hs_ed25519_public_key
hs_ed25519_secret_key
- Create a new environment variable for your application in Heroku
- Key:
ONION_LOCATION
- Value: the
.onion
address inside thehostname
file
- Key:
- Create a
config
directory in your application's root folder - Copy and paste your
hs_ed25519_public_key
andhs_ed25519_secret_key
files into this newconfig
directory - Create a
torrc.erb
file in theconfig
directory and ensureHiddenServiceDir
has the value/app/onion-service/
(example) - Modify your
Procfile
as outlined in the previous section if you haven't yet done so - Deploy your application
The free .herokuapp.com
domain automatically redirects to HTTPS, which will normally break your visit to your onionsite, but you can use a custom port to circumvent this.
Add the following to your torrc.erb
(referred to above):
HiddenServicePort <pick-a-port> 127.0.0.1:<your-port>
Your onionsite should then be available at yourv3onionaddress.onion:your-port
If you get stuck, jtschoonhoven's fork and associated Medium story provide related and much more in-depth tutorials. Most of the instructions there apply except for those specific to v2 .onion addresses, regarding private_key. I've updated those for v3 .onion
addresses here.