Browse Source

add config option exposing the rpc api and zmq notifucations to external apps

umbrel
kenshin-samourai 6 years ago
parent
commit
78befef79a
  1. 38
      doc/DOCKER_advanced_setups.md
  2. 1
      doc/DOCKER_setup.md
  3. 22
      docker/my-dojo/conf/docker-bitcoind.conf.tpl
  4. 36
      docker/my-dojo/dojo.sh
  5. 8
      docker/my-dojo/overrides/bitcoind.rpc.expose.yaml

38
doc/DOCKER_advanced_setups.md

@ -0,0 +1,38 @@
# MyDojo - Advanced Setups
## Expose bitcoind RPC API ans ZMQ notifications to external apps ##
By default, access to the RPC API of your bitcoind is restricted to Docker containers hosted on the "dojonet" network.
The following steps allow to expose the RPC API ans ZMQ notifications to applications running on your local machine but outside of Docker.
```
#
# If your Docker runs on macos or windows,
# retrieve the local IP address of the VM
# hosting your Docker containers
#
# Stop your Dojo
./dojo.sh stop
# Edit the bitcoin config file
nano ./conf/docker-bitcoind.conf
#
# Set the value of BITCOIND_RPC_EXTERNAL to "on"
#
# If your Docker runs on macos or windows,
# set the value of BITCOIND_RPC_EXTERNAL_IP to the IP address of the VM
#
# Save and exit nano
#
# Start your Dojo
./dojo.sh start
```
With this setting, external applications running on your local machine but outside of Docker should be able to access the following ports:
* 9501: bitcoind zmqpubrawtx notifications
* 9502: bitcoind zmqpubhashblock notifications
* 28256: bitcoind RPC API

1
doc/DOCKER_setup.md

@ -79,6 +79,7 @@ This procedure allows to install a new Dojo from scratch.
* BITCOIND_RPC_PASSWORD = password protecting the access to the RPC API of your full node.
* If your machine has a lot of RAM, it's recommended that you increase the value of BITCOIND_DB_CACHE for a faster Initial Block Download.
* By default, Dojo creates a new onion address for your full node at each startup. Set the value of BITCOIND_EPHEMERAL_HS to 'off' to keep a static address (not recommended).
* This file also provides a few expert settings for advanced setups (e.g.: expose bitcoind RPC API to external apps). See this [doc](./DOCKER_advanced_setups.md) for more details.
* Edit docker-mysql.conf.tpl and provide a new value for the following parameters:
* MYSQL_ROOT_PASSWORD = password protecting the root account of MySQL,

22
docker/my-dojo/conf/docker-bitcoind.conf.tpl

@ -31,7 +31,27 @@ BITCOIND_MEMPOOL_EXPIRY=72
# Type: numeric
BITCOIND_MIN_RELAY_TX_FEE=0.00001
#
# EXPERT SETTINGS
#
# Generate a new onion address for bitcoind when Dojo is launched
# Activation of this option is recommended for improved privacy.
# Values: on | off
BITCOIND_EPHEMERAL_HS=on
BITCOIND_EPHEMERAL_HS=on
# Expose the RPC API to external apps
# Warning: Do not expose your RPC API to internet!
# See BITCOIND_RPC_EXTERNAL_IP
# Value: on | off
BITCOIND_RPC_EXTERNAL=off
# IP address used to expose the RPC API to external apps
# This parameter is inactive if BITCOIND_RPC_EXTERNAL isn't set to 'on'
# Warning: Do not expose your RPC API to internet!
# Recommended value:
# linux: 127.0.0.1
# macos or windows: IP address of the VM running the docker host
# Type: string
BITCOIND_RPC_EXTERNAL_IP=127.0.0.1

36
docker/my-dojo/dojo.sh

@ -2,18 +2,34 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
if [ -f "$DIR/conf/docker-bitcoind.conf" ]; then
source "$DIR/conf/docker-bitcoind.conf"
fi
# Source a file
source_file() {
if [ -f $1 ]; then
source $1
fi
}
source_file "$DIR/conf/docker-bitcoind.conf"
source_file "$DIR/.env"
# Docker up
docker_up() {
source_file "$DIR/conf/docker-bitcoind.conf"
overrides=""
if [ -f "$DIR/.env" ]; then
source "$DIR/.env"
fi
if [ "$BITCOIND_RPC_EXTERNAL" == "on" ]; then
overrides="-f $DIR/overrides/bitcoind.rpc.expose.yaml"
export BITCOIND_RPC_EXTERNAL_IP
fi
eval "docker-compose -f $DIR/docker-compose.yaml $overrides up $1 -d"
}
# Start
start() {
docker-compose up --remove-orphans -d
docker_up --remove-orphans
}
# Stop
@ -52,7 +68,7 @@ restart() {
sleep 15s
docker-compose down
docker-compose up -d
docker_up
}
# Install
@ -70,7 +86,7 @@ install() {
if [ $launchInstall -eq 0 ]; then
init_config_files
docker-compose up -d --remove-orphans
docker_up --remove-orphans
docker-compose logs --tail=0 --follow
fi
}
@ -106,7 +122,7 @@ upgrade() {
update_config_files
cleanup
docker-compose build --no-cache
docker-compose up -d --remove-orphans
docker_up --remove-orphans
update_dojo_db
docker-compose logs --tail=0 --follow
fi

8
docker/my-dojo/overrides/bitcoind.rpc.expose.yaml

@ -0,0 +1,8 @@
version: "3.2"
services:
bitcoind:
ports:
- "${BITCOIND_RPC_EXTERNAL_IP}:28256:28256"
- "${BITCOIND_RPC_EXTERNAL_IP}:9501:9501"
- "${BITCOIND_RPC_EXTERNAL_IP}:9502:9502"
Loading…
Cancel
Save