kylemanna / docker-bitcoind

💰 Bitcoind Docker image that runs the Bitcoin node in a container for easy deployment
https://hub.docker.com/r/kylemanna/bitcoind/
MIT License
622 stars 403 forks source link

Can we run this behind TOR? #77

Open samsong opened 3 years ago

samsong commented 3 years ago

I have setup using docker & everything working. How can I run this behind a TOR?

I have also setup EZNODE docker container which runs a TOR, BTC RPC Explorer It would be nice to connect to the TOR created by that.

Any advice on this?

laverdet commented 3 years ago

You can edit bitcoin.conf in the /bitcoin/.bitcoin volume. You would add proxy=... and maybe listenonion=0 if you don't want to publish a hidden service.

realSConway commented 3 years ago

I want to route bitcoin only through tor, using peterdavehello/tor-socks-proxy container as tor proxy.

I first run tor container

podman run --detach \
--name tor-socks-proxy \
--publish 127.0.0.1:9150:9150/tcp \
peterdavehello/tor-socks-proxy:latest

Then run bitcoin with:

podman run --rm --detach --tty --interactive \
--name bitcoin \
--network container:tor-socks-proxy \
--env http_proxy=socks5://127.0.0.1:9150 \
--env HTTPS_PROXY=socks5h://127.0.0.1:9150 \
kylemanna/bitcoind:latest

In my bitcoin.conf, I use tor settings.

proxy=10.88.2.2:9150 #ip address of tor-socks-proxy
listen=1
bind=127.0.0.1
onlynet=onion

Should bind also be ip from tor-socks-proxy?

realSConway commented 2 years ago

I have it working!

tor container is running like:

podman run --detach \
--name tor-socks-proxy \
--publish 8333:8333 \
--publish 127.0.0.1:9150:9150/tcp \
 peterdavehello/tor-socks-proxy:latest

Then connect bitcoin-node with tor-socks-proxy network container

podman run --rm --interactive --tty  \
--name bitcoind-node \
--volume bitcoin-data:/home/bitcoin/.bitcoin \
--network container:tor-socks-proxy \
ruimarinho/bitcoin-core  

In bitcoin.conf set proxy to ipaddress:port of tor-socks-proxy

proxy=10.88.0.2:9150
MarcelRobitaille commented 2 years ago

Thanks @realSConway

For those who prefer docker-compose:

version: "3"

services:
  bitcoind:
    image: kylemanna/bitcoind:latest
    container_name: bitcoind
    restart: always
    volumes:
      - /media/bitcoin:/bitcoin/.bitcoin
    network_mode: service:tor
  tor:
    image: peterdavehello/tor-socks-proxy:latest
    container_name: tor-socks-proxy
    ports:
      - "8118:8118"
      - "127.0.0.1:8332:8332"
      - "127.0.0.1:9150:9150/tcp"
dev7ba commented 1 year ago

Thanks @MarcelRobitaille and @realSConway but you can't publish a hidden service this way. I'll try to make a pullrequest by running tor within the same container.