Installing a mempool self-hosted instance
Want your own mempool space instance? here a detailed howto, to run it now
Mempool.space is a great opensource project and tool. It is useful also to broadcast the transactions and for its amazing API. But what do you think about installing on your own VPS server? It is great. Obviously you need to have a full Bitcoin Core node install running. In this example they are on the same VPS.
Mempool is also great for its API and the lot of tools there are available. For example it is easy to broadcast tx and to do a lot of things more.
What you need
Debian 12
Bitcoin Core running on your local VPS (Debian12)
docker (latest stable available), running and available for user “dev”
mempool (docker version)
a domain or subdomain to be pointed to the VPS address, needed for the mempool installed to be public exposed
optional: electrs if you want to be able to analyze the Bitcoin addresses as well (rif: https://github.com/romanz/electrs/blob/master/doc/install.md )
Basic parameters on Core
On your running VPS you should have already installed a full node with Bitcoin Core. It is important that you have parameters in your bitcoin.conf file. Feel free to change rpc connection details, or use the rpc auth generator: https://jlopp.github.io/bitcoin-core-rpc-auth-generator/ by J. Lopp.
The network 172.16.0.0/12
is the docker network.
server=1
txindex=1
# Network
listen=1
# rpc
rpcuser=mempool
rpcpassword=mempool
rpcbind=172.17.0.1
rpcallowip=172.16.0.0/12
Network and firewall
where 172.17.0.1 is the docker0 interface. Infact the mempool server will connect from docker to the local machine through the 172.17.0.1 interface.
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:1b:a3:04:27 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
Now configure the firewall in this way
sudo ufw allow 80/tcp # needed for certbot
sudo ufw allow 443/tcp
sudo ufw allow from 172.16.0.0/12 to any port 8332
sudo ufw allow 22/tcp
Now wait for Bitcoin core to be fully in sync, create a dir mempool and put the following docker-compose.yml file
Mempool
version: "3.7"
services:
web:
environment:
FRONTEND_HTTP_PORT: "8080"
BACKEND_MAINNET_HTTP_HOST: "api"
image: mempool/frontend:latest
user: "1000:1000"
restart: on-failure
stop_grace_period: 1m
command: "./wait-for db:3306 --timeout=720 -- nginx -g 'daemon off;'"
ports:
- 3000:8080
api:
environment:
MEMPOOL_BACKEND: "none"
CORE_RPC_HOST: "172.17.0.1"
CORE_RPC_PORT: "8332"
CORE_RPC_USERNAME: "mempool"
CORE_RPC_PASSWORD: "mempool"
DATABASE_ENABLED: "true"
DATABASE_HOST: "db"
DATABASE_DATABASE: "mempool"
DATABASE_USERNAME: "mempool"
DATABASE_PASSWORD: "mempool"
STATISTICS_ENABLED: "true"
image: mempool/backend:latest
user: "1000:1000"
restart: on-failure
stop_grace_period: 1m
command: "./wait-for-it.sh db:3306 --timeout=720 --strict -- ./start.sh"
volumes:
- ./data:/backend/cache
db:
environment:
MYSQL_DATABASE: "mempool"
MYSQL_USER: "mempool"
MYSQL_PASSWORD: "mempool"
MYSQL_ROOT_PASSWORD: "admin"
image: mariadb:10.5.21
user: "1000:1000"
restart: on-failure
stop_grace_period: 1m
volumes:
- ${PWD}/mysql/data:/var/lib/mysql
In this way i can run the mempool server which listen on port 3000 and connects to the Bitcoin core running on the base VPS, via docker0 network connection. Please be informed that if you want to be able to inspect addresses in your mempool setup you must use a backend like electrs or esplora, otherwise that functionality will be unavailable on your install.
Now you can run with
docker compose up
you can checkout logs with
docker compose logs -t -f --tail 300
Check if all is running by invoking your instance to test, in this way
http://mempool.yourdomain.com:3000
https on the web interface
At this point you must configure nginx to run your system under https. You have to put in sites-available of nginx the following file mempool.yourdomain.com.conf file and adjust on your needs.
server {
listen 443 ssl;
server_name mempool.yourdomain.com; # Replace with your domain
ssl_certificate /etc/letsencrypt/live/mempool.yourdomain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mempool.yourdomain.com/privkey.pem; # managed by Certbot
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256';
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:3000; # Replace with Mempool container's port, if different
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Now you can restart nginx
certificate autorenew
sudo apt-get install certbot
sudo certbot renew --force-renewal
sudo certbot renew --dry-run
This will setup your certificate to auto renew automatically at expire time. That’s it, your mempool will be available at
https://mempool.yourdomain.com
For your VPS needs you can contact https://denali.eu Please like and share this article if you found it interesting and useful.