esplora is just the web ui frontend, you also need to setup the (forked) electrs backend for indexing and for providing the HTTP API that esplora queries.
electrs can index the bitcoin block chain using two methods: by reading the
blk files directly out of disk, or by querying for blocks using the bitcoind rpc. The first method is significantly faster, but requires electrs to have filesystem access to the bitcoin datadir, which would typically mean running them on the same server (you could technically do this remotely but you'll lose most of the performance gain, so not much point in doing that). The second method can work if you have two separate servers, but I wouldn't recommend it (would be painfully slow).
To setup electrs, install Rust and:
$ sudo apt install clang cmake # required for building rust-rocksdb
$ git clone https://github.com/blockstream/electrs && cd electrs
$ git checkout new-index
$ cargo run --release --bin electrs -- -vvv --daemon-dir ~/.bitcoin
If the bitcoin datadir is not at
--daemon-dir to point to it. It should automatically pick up the rpc credentials from the cookie file. If you want to index from a remote bitcoind node, set
--jsonrpc-import --daemon-rpc-addr <addr:port> --cookie <user:pass>.
By default, electrs will bind its HTTP API server on
127.0.0.1:3000. To enable remote access, it is recommended to setup a reverse proxy with tls (like nginx) in front of electrs. You could also set
--http-addr <host:ip> to have electrs accept remote connections directly, but you probably shouldn't.
The initial indexing process will take quite some time and disk space (up to 1TB at the peak during the indexing, which then shrinks down to about 450GB after compaction). To test it worked, you can try issuing requests to the electrs HTTP API:
$ curl http://localhost:3000/blocks/tip/height
$ curl http://localhost:3000/address/1EMBaSSyxMQPV2fmUsdB7mMfMoocgfiMNw
Then, to start esplora and point it to your electrs server, install nodejs and:
$ git clone https://github.com/Blockstream/esplora && cd esplora
$ npm install
# needs to be set to the URL where the electrs HTTP API is available for
# requests coming from the user's browser. if you're browsing from the same
# machine running electrs, this should work:
$ export API_URL=http://localhost:3000/
# start a dev server on port 5000 (on-the-fly babel/browserify transpilation, slow, cpu hog)
$ npm run dev-server
# or pre-build the web ui as a static directory with:
$ npm run dist
You will then have the esplora web ui available at http://localhost:5000/. As with electrs, it is recommend to setup a tls-enabled frontend http server for remote access, either reverse proxying the dev server, or (more ideally) directly serving the pre-built static files.
The last thing that you'll need to do is configure electrs to accept cross-origin requests from the esplora web ui. Do to this, add
--cors <origin> to the end of the
cargo run command. If you're accessing esplora locally,
--cors localhost:5000 should work. Otherwise, set it to the origin that the esplora web ui is served from. Or just use
--cors '*' if you're okay allowing cors requests from all origins.
Alternatively, you could also use the esplora docker image that makes setting up everything (bitcoind+electrs+esplora) much easier, but that doesn't play nicely with an existing bitcoind node.