Hello
I'm trying to setup my LNBits manually without using the easy way which is installing Caddy. I want to set it up by hand and have full control of what is going on.
My setup is the following:
Device: RockPro64
Router: NetGear R7800 running OpenWrt
OS: Debian BullsEye - Linux rockpro64 5.10.0-8-arm64 #1 SMP Debian 5.10.46-4 (2021-08-03) aarch64 GNU/Linux
LN node: C-Lightning v0.10.1-38-g8f782b0
LNBits: repository cloned from github, so I think it's master branch version
Web Server: nginx/1.18.0
I follwoned these steps to install LNBits, from their github:
git clone https://github.com/lnbits/lnbits.git
cd lnbits/
# ensure you have virtualenv installed, on debian/ubuntu 'apt install python3-venv' should work
python3 -m venv venv
./venv/bin/pip install -r requirements.txt
cp .env.example .env
mkdir data
./venv/bin/quart assets
./venv/bin/quart migrate
./venv/bin/hypercorn -k trio --bind 0.0.0.0:5000 'lnbits.app:create_app()'
I also watched this video, until Caddy part:
https://www.youtube.com/watch?v=WJRxJtYZAn4My LNBits
.env file is like this (the relevant parts):
$ cat .env
QUART_APP=lnbits.app:create_app()
QUART_ENV=development
QUART_DEBUG=true
HOST=127.0.0.1
PORT=5000
LNBITS_ALLOWED_USERS=""
LNBITS_DEFAULT_WALLET_NAME="LNBits wallet"
LNBITS_DATA_FOLDER="./data"
# disable selected extensions, or use "all" to disable all extensions
LNBITS_DISABLED_EXTENSIONS="amilk,ngrok"
LNBITS_FORCE_HTTPS=true
LNBITS_SERVICE_FEE="0.0"
# Change theme
LNBITS_SITE_TITLE="LNbits"
LNBITS_SITE_TAGLINE="free and open-source lightning wallet"
LNBITS_SITE_DESCRIPTION="My awesome message"
# Choose from mint, flamingo, salvador, autumn, monochrome, classic
LNBITS_THEME_OPTIONS="mint, flamingo, classic, autumn, monochrome, salvador"
# Choose from LNPayWallet, OpenNodeWallet, LntxbotWallet, LndWallet (gRPC),
# LndRestWallet, CLightningWallet, LNbitsWallet, SparkWallet
LNBITS_BACKEND_WALLET_CLASS=CLightningWallet
# CLightningWallet
CLIGHTNING_RPC="/home/rp64/.lightning/bitcoin/lightning-rpc"
My nginx config file, which is in
/etc/nginx/conf.d/my.awesome.lnbits.site.com is like this:
server {
listen 5000 ssl http2 default_server;
listen [::]:5000 ssl http2 default_server;
server_name my.awesome.lnbits.site.ddns.net; # ---------> this site name is setup in in noip.com to avoid IP changes, if they happen
ssl_certificate /etc/nginx/ssl/my.awesome.lnbits.site.crt;
ssl_certificate_key /etc/nginx/ssl/my.awesome.lnbits.site.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
location / {
proxy_pass https://localhost:5000/; # ----> directive that sets up the reverse proxy in nginx
}
}
My
/etc/nginx/sites-available/default files is the default one. Didn't touch it!
My router firewall rule to forward the traffic to my rp64 is the following:
config redirect
option dest_port '5000'
option src 'wan'
option name 'lnbits'
option src_dport '5000'
option target 'DNAT'
option dest_ip '192.168.1.153'
option dest 'lan'
option proto 'tcp'
So, after all this, when I try to run the command:
./venv/bin/hypercorn -k trio --bind 0.0.0.0:5000 'lnbits.app:create_app()'
I get this error:
✔️ CLightningWallet seems to be connected and with a balance of [i]not enough[/i] msat.
Traceback (most recent call last):
File "/home/rp64/Downloads/lnbits/./venv/bin/hypercorn", line 8, in
sys.exit(main())
File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/hypercorn/__main__.py", line 267, in main
run(config)
File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/hypercorn/run.py", line 34, in run
worker_func(config)
File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/hypercorn/trio/run.py", line 119, in trio_worker
trio.run(partial(worker_serve, app, config, sockets=sockets, shutdown_trigger=shutdown_trigger))
File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/trio/_core/_run.py", line 1896, in run
raise runner.main_task_outcome.error
File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/hypercorn/trio/run.py", line 51, in worker_serve
sockets = config.create_sockets()
File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/hypercorn/config.py", line 177, in create_sockets
insecure_sockets = self._create_sockets(self.bind)
File "/home/rp64/Downloads/lnbits/venv/lib/python3.9/site-packages/hypercorn/config.py", line 240, in _create_sockets
sock.bind(binding)
OSError: [Errno 98] Address already in use
If I use
http://my.awesome.lnbits.site.ddns.net:5000, the site works, no idea how if LNBits is not running!
Note: I changed some folder names so that I can keep some of my privacy. I also changed the site name for the same reasons. So, this location
"/home/rp64/Downloads/ doesn't really exist, but you all get the point. Same for the site name
my.awesome.lnbits.site.ddns.net and ssl certificates.