2

How can I make Tor functions on Heroku? I'm using tor as a proxy rotator along with my python project for web crawling. Everything works fine on localhost but I don't find how to make tor functions on Heroku? do I just install it on the Heroku server?
or are there any other solutions?

4
  • 1
    I don't think you're going to get a definite answer because I don't think anyone has put a lot of thought into it. With that said, I do have some experience with Cloud Foundry which isn't so different than Heroku. My guess is that you would need to build a custom Tor buildpack that could bake the tor executable in with any app that is being published. When an app is created and started, instead of being reachable from the outside like a normal web app, the tor executable will turn the app into an onion service.
    – elmerjfudd
    Commented Apr 26, 2020 at 12:55
  • Are there any other solutions to dynamically change IP address of the dyno while running, without having to use tor?
    – Imen
    Commented Apr 26, 2020 at 13:28
  • I know that you can create an ingress in Cloud Foundry. I have no idea how that works with Heroku. You should really ask than community for more info on how to do that.
    – elmerjfudd
    Commented Apr 26, 2020 at 16:16
  • I think I just solved the problem, I found an already built buildpack for tor. thank you, though :)
    – Imen
    Commented Apr 28, 2020 at 12:00

2 Answers 2

1

@lmen is probably talking about Tor Proxy Buildpack for Heroku, it can setup Tor on a heroku node with socks5 and control port available (They can be configured in the environment values).

All you need to do is run

$ heroku buildpacks:add https://github.com/iamashks/heroku-buildpack-tor-proxy.git

And it will automatically setup a proxy that you can use at port 9050.

0

Can you add few lines of code as an example cause I follow the instructions of the buildback but does not work with the following code

PROXY = "socks5://mysite.com:9050"# IP:PORT or HOST:PORT
CHROMEDRIVER_PATH = "/app/.chromedriver/bin/chromedriver"
chrome_bin =os.environ.get('GOOGLE_CHROME_SHIM', None)

options = webdriver.ChromeOptions()
options.binary_location = chrome_bin
options.add_argument(" — disable-gpu")
options.add_argument(" — no-sandbox")
options.add_argument('--disable-dev-shm-usage') 

options.add_argument('--remote-debugging-port=9222')
options.add_argument('--disable-infobars')

options.add_argument('--proxy-server=%s' % PROXY)

try:

    driver = webdriver.Chrome(executable_path="chromedriver", chrome_options=options)
    driver.get("http://check.torproject.org")
    print ('opening ')
except Exception as e:
    print (str(e))

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .