~lanlyd Docs

Nginx Reverse Proxy On Raspberry Pi 4

Access Your Ship Remotely with NginX & Raspberry Pi 4 8gb
If you're not hosted in the cloud and are instead running on a computer inside your local network, then this guide will help you access your Urbit ship remotely. There are many ways to access your locally running ship remotely. This is just one of them. It's not the easiest way, to do it, either. If this way is too complex, take a look at this alternative over at https://urbit.org/using/os/basics#dns-setup.

Installing Docker + Portainer

1. Install Raspberry Pi OS Lite using the Raspberry Pi Imager tool.
- Pres Ctrl+Shift+X to open the Advanced setup
- Enable SSH
- Set Password
- Set hostname
- Set Timezone
2. Launch PuTTY to SSH into the Pi with the username "pi" and the password you setup previously
3. Run an update
sudo apt update
sudo apt upgrade
4. Reboot the Pi to enable the updates
sudo reboot
5. Login again via SSH
6. Install git
sudo apt install git
7. Make a folder for the Docker download
mkdir Downloads
8. Change Directory into that new folder
cd Downloads
9. Download the GitHub Docker
git clone https://github.com/novaspirit/pi-hosted
10. Change directory into the new "pi-hosted" folder
cd pi-hosted
11. Install the "install_docker.sh" script
12. Log off the pi to create the new Docker group
13. Log back into the Pi via SSH
14. Check to make sure the "pi" user has been included in the new Docker group
> If you see the word "docker" in the list then the user "pi" was added successfully
15. Change directory back into the "pi-hosted" folder
cd Downloads/pi-hosted
16. Install the "install_portainer.sh" script
17. Exit PuTTY
18. You should be able to access the Portainer UI via the browser on port 9000
19. Create a user login for Portainer using the web UI
### Installing Docker Compose + Nginx
1. Back to PuTTY for more SSH
2. We need to use docker compose to create the Nginx Proxy Manager container. This requires us to install a few dependencies – run the installation commands below in order.
sudo apt-get install -y libffi-dev libssl-dev
sudo apt-get install -y python3 python3-pip
sudo pip3 -v install docker-compose
3. After the commands finish installing, we need to create a folder where our config and docker-compose files will exist. We will then navigate to that folder and create a file named config.json.
mkdir nginx
cd nginx
nano config.json
4. Paste these contents into the config file.
"database": {
"engine": "mysql",
"host": "db",
"name": "npm",
"user": "npm",
"password": "npm",
"port": 3306
Save the file and exit it.
ctrl+s to save and ctrl+x to exit the document
5. Create a new file named docker-compose.yml
nano docker-compose.yml
6. Paste the contents below into the docker-compose file.
version: '3'
image: 'jc21/nginx-proxy-manager:latest'
- '80:80'
- '81:81'
- '443:443'
- ./config.json:/app/config/production.json
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
image: 'yobasystems/alpine-mariadb:latest'
- ./data/mysql:/var/lib/mysql
Save the file and exit it.
ctrl+s to save and ctrl+x to exit the document
7. You should have two files that exist in the nginx folder. Run the command below to start the docker container.
sudo docker-compose up -d
8. The container will download and install all the necessary files.
9. We will now adjust both of the containers that Nginx Proxy Manager uses to automatically start when your Raspberry Pi is rebooted.
sudo docker update --restart always nginx_app_1
sudo docker update --restart always nginx_db_1
10. Restart your Raspberry Pi – very important!
sudo reboot now
11. After the reboot is complete, the container will take a few minutes to fully install. You can run the command below to check on the status of the container. When it reports “healthy”, you will be able to navigate to the Nginx Proxy Manager website. Alternatively, if you set up Portainer, you can open Portainer and check on the status of the container there.
sudo docker ps
12. Log into the Portainer web UI and check the local containers. Wait until both nginx_app_1 and nginx_db_1 are showing a status of healthy in green.
13. Create a new user login for Nginx using the web UI on port 81
the Default login is:
Password: changeme
Setup and new username and password after login.
14. At this point, Nginx Proxy Manager is fully installed. You will need to open ports 80/443 on your router to point to your Raspberry Pi. From there, you will have to configure Nginx Proxy Manager.
14. Make sure that your DDNS hostname is set on your router, and you should be all set.

Congratulations. You now are up and running with Nginx on a Raspberry Pi 4

Connecting a Cloudflare Domain Name

More coming soon.