This is a first-version guide. I’ll happily iterate on it based on feedback, I’m sure I missed something, somewhere.
To-Add:
- Troubleshooting section
- Improve proxy headers (Current ones are what I found to be functional thus far)
- Add some follow-along pictures for each step
Quick how-to:
- Register Domain
- Configure DNS to point to desired IP
- Get an SSL certificate for the domain/sub-domain
- Setup reverse-proxy using nginx
- Redirect web traffic from reverse-proxy to Umbrel device
I’d like to mention a few things prior to going ahead with this guide.
-
You can follow this guide even if you run a single raspberry pi.
-
Even though this guide is catered towards LNbits, a reverse-proxy is exceptionally useful for a multitude of other things.
-
If you intend on having custody of people’s wallets and giving them Internet Access to it, you should have some technical expertise(or the drive to) in order to SECURE people’s data.
I’m sure one can take this guide and make it super user-friendly, but I don’t want to encourage non-technical people to manage funds. -
For administrative purposes, I strongly encourage all users to keep remote access of their node on the Tor network. This goes for Umbrel’s dashboard, as well as any administrative components(This is outside the scope of the guide, but worth a mention).
-
The scope of this guide extends solely to making LNbits available via the public Internet, and making it functional.
-
Throughout this guide I’ll be using my own setup as a base, however this can be followed by most users for whichever hardware they have Umbrel running on.
I’ll attempt to make it as universal as possible since we’re dealing with Linux anyway, but you may need to make adjustments throughout. -
Since you operate a node I’ll take on certain assumptions:
- You have no problem with doing some research
- You have the ability to log onto your device(s)
If you require further detail or help on something specific, simply ask.
-
I do not use a raspberry Pi but I understand a lot of people do. I’ll be covering Arch distribution commands(which will work on Arch, Manjaro, etc) and for Raspberry Pi users I’ll be including Debian distribution commands.
-
For those familiar with the LetEncrypt cert bot thinking about calling me out on utilising a DNS challenge as opposed to the “simple” HTTP challenge, don’t.
I thought about this and purposefully went with the DNS challenge to ensure that any user attempting this guide with hopes of success HAS A DOMAIN.
This is important because technically one can run this connecting by IP with no SSL Cert, but it means that their Wallet URL will be easily open to a MITM attack, and that’ll not only be an easy game-over, but also a fair game. -
I recommend having a dedicated front-end gateway device to redirect requests to your Umbrel node(wherever it may be), but you can do all this on a single device(although if you already have an up and running node, do so at your own risk, or at least take the necessary precautions).
If using two devices, I also recommend that the connectivity between the two be hardwired, NO WI-FI.For anyone wondering about my setup:
I have two servers running.
A front-end gateway that handles traffic, and offers a suite of self-hosted services akin to the Google Suite, and a second server running Proxmox with a multitude of VMs.
My Umbrel node runs on an Arch Linux VM on Proxmox with a 1TB SSD.# -
Feel free to open a channel, I’ll reciprocate asap:
UbiquityRonin.net
Overview and why
@DarthCoin pushed me to do it. Special thanks to him/her.
I’ve had the majority of the setup below for a few years, but recently I started coding a Telegram bot that lets users make lightning payments from a Telegram chat, but obviously there would be 2 issues:
- Getting LNbits accessible over the Internet without Tor
- Making it functional (ex. the Export to Phone QR code would respond with a .onion or private IP address even though the Wallet was going over the internet, which would defeat the purpose.)
These two points will be covered and your users will be able to access their LNbits wallets over the Internet.
Requisites
-
You will NEED a domain(shared or private, free or paid, preferably a subdomain for your LNbits service) I recommend dishing out a few $ for one.
While I won’t cover how to set this up, I’ll be making remarks on the things required for the domain to be responsive. -
You will NEED an SSL certificate for your domain. I’ll be covering this in this guide. As mentioned in the preface notes, since LNbits attaches your wallet-string to the URL, the last thing you want is that URL to be visible on the web.
Expected traffic flow:
[Internet] - [Home Router/Firewall] - [Front-End Gateway] - [Umbrel]
Overview of steps:
- Install components, this includes Nginx & the LetsEncrypt CertBot.
I am aware there is the certbot-nginx plugin, but I setup both components individually - This will make it easier for me to help users troubleshoot if they come across any issues.
Further, for the users attempting this guide, having an understanding of both of these components individually pays off in the future if they wish to expand their infrastructure. - Get an SSL Certificate
- Configure components
- Test
Henceforth I’ll refer to our domain as domain.com, and for our LNbits subdomain I’ll refer to it as lightning.domain.com
-
Installing components
SSH onto your device and use your package manager to install the necessary packages.
Arch:
sudo pacman -Sy nginx certbot
Debian:
sudo add-apt-repository ppa:certbot/certbot <-- This adds the certbot repository sudo apt update sudo apt install nginx certbot
-
DNS configuration
Before we move on, using the DNS manager from where you bought your domain(or wherever if you delegated your domain), you’ll want to setup an A record.
-
Create an A record pointing lightning.domain.com to your home IP. If you’re not behind a VPN, ifconfig.me will show you your IP.
-
For longevity’s sake, it’s also recommended you setup a DNS updater, so that your A record automatically updates to your latest IP in case your ISP changes it.
Some providers have dedicated applications for this. Others utilise a single unique string URL that when hit, is updated with hitter’s IP. If you use a provider that employs this method(or delegated your domain to one who does), feel free to use the following python script:
https://gitlab.com/Fragments-form-function/multi-scripts/-/blob/master/DNS-Script.pyDownload/copy it, place it on your server and create a system service for it.
-
-
Port-Forwarding
On your home router, port-forward port 443 and point it to the device you install nginx + certbot on.
If your ISP does not allow you to port-forward a standard port such as 443, you may choose another port and change the nginx configuration accordingly. -
SSL Certificate
On the device you installed certbot on, run:
sudo certbot certonly --manual --preferred-challenges dns
Certbot will ask you for the domain, and will also ask you to place a TXT record for _acme-challenge.lightning.domain.com with a string it gives as the value.
Give it the lowest TTL you can(5 mins is fine), as you’ll remove this TXT record once validated.
Once the TXT record is in place, using another SSH session run
dig -t txt _acme-challenge.lightning.domain.com
every few minutes until the string appears. This can take 15-30 minutes. Your challenge won’t timeout.
Once the record is successfully retrieved by dig, hit Enter on certbot, and you should receive your certificate. If it didn’t work, retry, give it more time. It can take a while for DNS to propagate.
Your new certificate should be under /etc/letsencrypt/live/lightning.domain.com/ Remember this path as we’ll need it shortly.
-
Configuring nginx reverse-proxy
Navigate to /etc/nginx/sites-available/ and you should have a reverse-proxy.conf here.
Open it using a text editor such as nano,
nano reverse-proxy.conf
Once inside, you’ll want setup a new server block dedicated to LNbits. This is where the magic happens.
server {
listen 443 ssl; # Here, you'll tell nginx to listen on port 443 for SSL connections
server_name lightning.domain.com; # Here you'll tell nginx the expected domain for requests
access_log /var/log/nginx/reverse-access.log; # Your first go-to for troubleshooting
error_log /var/log/nginx/reverse-error.log; # Same as above
location / {
proxy_pass http://10.13.37.5:3007 # Change this to point to your umbrel node's private IP and LNbits port. You can try to use umbrel.local, but I recommend using the device's actual IP. To find this IP run "ping umbrel.local", and it should return the IP.
proxy_set_header Upgrade $http_upgrade
proxy_set_header Connection 'upgrade';
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $host;
proxy_http_version 1.1; # These are the headers I've found to both give access to LNbits, AND ensure that replies back are re-written with the lightning.domain.com URL as opposed to the private IP or .onion.
}
ssl on; # This is important and declares connections should be secured with SSL.
ssl_certificate /etc/letsencrypt/live/lightning.domain.com/fullchain.pem; # Point to the fullchain.pem
ssl_certificate_key /etc/letsencrypt/live/lightning.domain.com/privkey.pem; # Point to the private key.
-
Restart services and test
Run
sudo systemctl restart nginx
On a browser, head over to https:// lightning.domain.com.
Access your wallet via https:// lightning.domain.com/wallet?usr={YourUserString}