Pi Server
The project is divided in sections/chapters. Please click on the buttons inside the tabbed menu to navegate betweeen chapters:
My Own Server At Home
About This Website
When you visit my website, you are connecting directly to my self-hosted home server: a Raspberry Pi 4. All the files needed to make the website work are stored on it using docker containers.
For those who does not know, a Raspberry Pi is a single-board computers of the size of a credit-card. It is a low cost device developed in the UK.
How Is It Built?
Visit my GitHub repository to see all the source code for this project.
The structure and documentation is saved on an HTML file, the design on a CSS file and the user's interface on a Javascript file.
All files are served through NGINX, which runs in a wonderful docker container that is used as a reverse proxy with other private access services that are also runinng on the Raspberry: ( Nextcloud, Portainer, Homer, Pi-hole, qBittorrent, Jackett…).
Why?
The idea of this project is:
- To learn the magic behind self-hosting.
- To learn how to use the command line in Linux and move around my server as a pro.
- To learn Docker and Docker Compose.
- To deploy containers and learn how to use Portainer and many other self-hosted apps.
- To force myself to document all the projects I develop, and more importantly, finish them.
- To build my first blog/website from scratch with usefull information about the process and be able to go back in time and recreate the project if needed it.
- To Develope frontEnd and BackEnd skills
- To sufil my needs of having to store private information. a centralize storage unit.
References
I have to get credit to multiple youtubers and other sources that contribute in some form to this project. With that been said, I will be adding the links for those videos if you want to have a more visual idea.
TITLE HEADING
Title description, Sep 2, 2017
Some text..
Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.
Chapter One
In this Chapter we will install the OS and setup the Raspberry Pi to boot from USB. Then, we will install Docker, install Portainer, and install Shell In A Box.
-
- Pi 4
- SD → To config Usb bootloader
- SSD or USB or HDD
- HDMI cord
Step by step:
-
- Make sure to format the SD and the SSD before.
- Go to Rpi website to download and Install the "Pi Imager"
-
Once it is installed, connect the SD card and flash Raspberry
Desktop OS.
I suggest to flash the Pi with the RPi Desktop version instead of the Lite version (as suggested in the video) Other than that, I follow steps in minute 2:18.
- Access the Advance options for the OS setup
- Remember to use the Ctrl + Shift + x to see the Advance options.
- Disable overscan
- Set hostname: rpi-srv
- Enable SSH
- Set Password
- Set Configure WIFI & country
- Set Local & Keyboard Layout
- Skip first-run Wizard.
- Disable Telemetry.
Flash RPi OS
— Flash RPi Desktop(not lite as in video) OS ( Ctrl + Shift + x → Advance options)
-
Note: The Raspberry Pi needs to Boot from USB. Which means that we need to Update EEPROM on.
Personal Note: I had some issues following this particular video since the video skip the step where you need to config the USB bootloader. Instead, in the video, they flash the OS on the HDD instead of doing it on a SD and then copy everything from the SD to the SSD from the pi.
Watch video: How to Boot Raspberry Pi 4/400 From a USB SSD
- Connect to Raspberry Pi over SSH
- Update OS and firmware
- Reboot Raspberry Pi
-
How to Update EEPROM on Raspberry Pi 4 For USB Boot...
Install latest bootloader - Launch this tool for final configurations
- Reboot Raspberry Pi
- Copy SD to USB or SSD
- Connect to Pi using HDMI or VNC
- Go to Menu > accessories > SD card copy.
- From SD (dev/mmcblk) to SSD
-
Once it Finish, Turn off the pi
Remove the SD and boot from SSD
ssh pi@YOUR_RPI_IP Default username is pi & password is: raspberry
sudo apt update && sudo apt full-upgrade sudo rpi-update sudo reboot sudo rpi-eeprom-update -d -a sudo raspi-config advance options > boot order > USB advance options > bootloader Version > E1 - last version ROM display options > Resolution > MODE 82 - 16:9 sudo reboot Enable VNC in the Pi
Interface menu > VNC > enable. Using the code below:
sudo raspi-config sudo reboot sudo poweroff -
To setup a Static IP address
Go to the Router and assign an IP.
-
- 5:46 — Docker Explained
- 6:32 — Install Docker
- Install git
- Run Script
Sudo apt install git 1. cd Downloads 2. git clone https://github.com/novaspirit/pi-hosted 3. cd pi-hosted 4. ls 5. ./install_docker.sh #install docker 6. exit #logout 7. login 8. groups #to check if docker is in the group -
Run Script
1. cd Downloads/pi-hosted 2. ./install_portainer.sh #install portainer 3. cat install_portainer.sh # to check what is in the script 9:11 — Portainer Settings
Go to Endpoints or environments > local > change the public IP address with the actual IP from my Pi: 192.168.1.250
Portainer App templet link
10:51 — App Templates
- In Portainer add the link below
- Portainer > settings > url (link below) > save settings
https://raw.githubusercontent.com/SelfhostedPro/selfhosted_templates/master/Template/portainer-v2.json https://raw.githubusercontent.com/novaspirit/pi-hosted/master/pi-hosted_template/template/portainer-v2.json for more info go to github
-
11:51 — Shell In A Box Install
cd # to go to root. sudo apt install shellinabox -
Chapter Two
In this Chapter we will learn how to Install Homer, a Dashboard that allow us to view all the apps in out server.
Step by step:
-
I installed it from Portainer.
- apt templets > homer > deploy the container
-
-
I can SSH or user Shell in a box (https://192.168.1.250:4200/)
cd /portainer/Files/AppData/Config/Homer ls cd assets ls sudo nano config.yml //modify to change style -
Modify Homer page:
- Change title and sub-title
- To change page color use a color generator web
- comment the optional message with #
-
Go to services
- modify the apps and add more...
-
Change images
- Find a nice png & copy the url
- Go to the terminal and downloaded
- cd // to root
- wget ( url link — from the image)
- ls // to check if it download
- mv imgName.png newImgName.png // To rename img
- ls
- sudo mv newImgName.png /portainer/Files/AppData/Config/Homer/assets/tools/ //move img to another location
- cd /portainer/Files/AppData/Config/Homer/assets
- sudo nano config.yml
-
I can SSH or user Shell in a box (https://192.168.1.250:4200/)
-
Chapter Three
In this Chapter we will learn how to manually install an app on the Pi if the app is not listed in the app template on Portainer.
Step by step:
-
Go to Docker hub and download Guacamole
- Make sure to use one that support X64 & ARM
-
docker run \ -p 8080:8080 \ -v =[/path/to/config]:/config \ -e"EXTENSIONS=auth-ldap,auth-duo" oznu/guacamole -
Note: Basado en el template de arriba es q se configura la info de abajo:
- Containers > Add Container
- Name: Guacamole
- Image: oznu/guacamole:armhf
- Manual network port publishing: Click on publish a new network port
- Host: 9100 /avoid using port 8080 on host. it is really common.
- Container: 8080
-
Volume Tab
- Volume mapping: Click on map additional volume
- Container: /config
- Click on bind
- host: /portainer/Files/AppData/Config/guacamole
-
Restart Policy tab
- Set to Unless Stopped
- Deploy the container.
-
- Go to 192.168.1.250:9100
-
Login
- Default user/passw: guacadmin
- Settings > preference > change password
- Setting > add new configuration > pero no tengo servers
-
Chapter Four
In this Chapter we will install two apps. A downloader manager and a file browser GUI on our Pi.
Step by step:
-
Go to Docker hub and download JDownloader
- Make sure to use one that support X64 & ARM
- Name:
- Docker Hub
-
services: jdownloader: image: jaymoulin/jdownloader container_name: jdownloader restart: always user: 1001:100 volumes: - [/path/to/appdata/config]:/opt/JDownloader/cfg - [/path/to/downloads]:/opt/JDownloader/Downloads - [/path/to/appdata/logs]:/opt/JDownloader/logs #optional - /etc/localtime:/etc/localtime:ro #optional environment: MYJD_USER: email@email.com #optional (see [Identify](https://github.com/jaymoulin/docker-jdownloader#identify)) MYJD_PASSWORD: bar #optional (see [Identify](https://github.com/jaymoulin/docker-jdownloader#identify)) MYJD_DEVICE_NAME: goofy #optional XDG_DOWNLOAD_DIR: /opt/JDownloader/Downloads #optional ports: - 3129:3129 -
Note: Basado en el Docker Compose de arriba es q se configura la info de abajo:
- Containers > Add Container
- Name: JDownloader
- Image: jaymoulin/jdownloader:1.4.3-armhf
- Manual network port publishing: Click on publish a new network port
- Host: 3129
- Container: 3129
-
Volume Tab
- Volume mapping: Click on map additional volume X2
- Click on bind for both
- Container: /opt/JDownloader/cfg
- Host: /portainer/Files/AppData/Config/JDownloader
- Container: /opt/JDownloader/Downloads
- Host: /portainer/Downloads
-
Environment tab
- Click 3 times on Add environment variable.
-
Names:
- MYJD_USER
- MYJD_PASSWORD
- MYJD_DEVICE_NAME
-
Values:
- my usuario@tutanota.com
- my clave de jdownloader
- RaspberryPi
- Restart Policy tab
- Deploy the container.
-
- Go to 192.168.1.250:3129
- no me deja connectar
-
Go to the website and login
- my.jdownloader.org/login
-
Go to Docker hub and download File Browser
- Make sure to use one that support X64 & ARM
- Name: filebrowser/filebrowser
- Docker Hub
- File Browser website
-
docker run \ -v /path/to/root:/srv \ -v /path/filebrowser.db:/database.db \ -v /path/.filebrowser.json:/.filebrowser.json \ --user $(id -u):$(id -g) -p 80:80 \ filebrowser/filebrowser -
Note: Basado en el Docker Compose de arriba es q se configura la info de abajo:
- Containers > Add Container
- Name: FileBrowser
- Image: filebrowser/filebrowser
- Manual network port publishing: Click on publish a new network port
- Host: 8123
- Container: 80
-
Volume Tab
- Volume mapping: Click on map additional volume X2
- Click on bind
- Container: /srv
- Host: /portainer/Downloads
-
Restart Policy tab
- Set to never
- Deploy the container.
-
- Go to 192.168.1.250:8123
- Default login: admin & admin
-
Chapter Five
In this Chapter we will install "Transmission". It is a downloader that works with your VPN. In other words, It is a Downloader tool that use VPN.
Step by step:
-
Lo unico que hice fue agregar el APP template link en portainer.
lo inclui en la guia de la parte 1. -
Chapter Six
In this Chapter we will learn how to ...
install the OS and setup the Raspberry Pi to boot from USB. Then, we
will install Docker, install Portainer, and install Shell In A Box.
Step by step:
-
-
Take the image and re-Created
- Go to Portainer > container > Portainer image
- Stop the container
- Delete the image
- Re-download the image with the same setting as before.
This method wont delete anything.
-
Use the Script as presented in the video
cd /Downloads/pi-hosted .update_portainer.sh exit -
- Go to Portainer
- Open the container I want to update
- Stop container
- Recreate > Pull latest Image > Done
- Start
-
App Templates > search WatchTower
No need to setup -
Chapter Seven
In this Chapter we will learn how to install RPI Monitor. A monitoring solution for Docker hosts and containers with Prometheus, Grafana, cAdvisor, NodeExporter.
Step by step:
-
- Login to SSH
-
Find the script folder
1. cd pi-hosted/ 2. ls 3. git pull //to update repo 4. ls 5. ./rpi_docker_monitor.sh //run command 6. exit
-
- Go to the Portainer
- App templates
- Search the rpi-Monitor app
- Deploy the Stack
- No setup needed.
-
- Go to Portainer
- Stack tab
- click on the "raspberrypi-docker-monitor"
-
-
Go to Rpi-Monitor page and setup Dashboard.
- 192.168.1.250:3000
- login
- configure icone > Add data sources > prometheus > select
-
Under HTTP, add the URL
- To find the IP address, go to portainer
- Stack tab > click on the"raspberrypi-docker-monitor"
- scroll down and copy the IP for"monitoring-prometheus".
- in my case, it is 172.18.0.4
- add port 9090
- For the URL will be http://172.18.0.4:9090
- Save & Test
- Add dashboard
- clicking the + tab > import
-
Go to the github
- URL
- pi-hosted/pi-hosted_template/configs/dashboard_by_oijkn.json
- Copy dashboard_by_oijkn.json file
- Add copy file on under Import via json box
- Load > import
-
Go to Rpi-Monitor page and setup Dashboard.
-
Chapter Eight
In this Chapter we will learn how to Install NextCloud_Pi on the Raspberry Pi using Docker and Portainer.
Step by step:
-
This version of NextCloud is made for raspberry pi and its called
NextCloudPi
- Login to Portainer
- App templates >search for NextCloudPi
- Deploy the Container.
- Click here to learn more about the NextCloudPi project
-
- Go to the URL: https://192.168.1.250:8443
- Save the admin and user password displaying on the screen.
- Open a new tab and go to https://192.168.1.250:8443
-
Login using the admin credentials you previously saved.
- Username: ncp
- password: (adminPassword)
- Next Cloud first run > run
- Under external access > No
- Finish > Go back to NextCloudPi web panel
-
- Under configurations
- Click on nc-trusted-domains
-
Add the Raspberry Pi IP address
- 192.168.1.250
- Add the domain if you have one.
- Apply.
-
- Go to the URL: https://192.168.1.250:8443
- The error is gone.
-
Login with the second password previously stored.
- Username: ncp
- password: second password.
Enjoy NextCloud. Make sure to change the password
-
Blog Name
TITLE HEADING
Title description, Dec 7, 2017
Some text..
Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.
TITLE HEADING
Title description, Sep 2, 2017
Some text..
Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.
About Me
Some text about me in culpa qui officia deserunt mollit anim..
Popular Post
Follow Me
Some text..
Errors & Bugs
This section explain some of the errors you might get into during the project and how to troubleshoot them. Good luck!
SSH error:
-
"Nasty error" while trying to SSH into the Pi
Once I change some things in the pi, I was not able to SSH again and got an error that looks like this:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
5c:9b:16:56:a6:cd:11:10:3a:cd:1b:a2:91:cd:e5:1c.
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending key in /home/user/.ssh/known_hosts:1
RSA host key for ras.mydomain.com has changed and you have requested strict checking.
Host key verification failed. -
I fix it by getting rid of an individual known hosts
c:\users\juand\.ssh\known_hosts In my case, I have to delete the IP or the raspberry instance that was not letting me in.
For more details click here.
issue:
How do I fix a"cannot open display" error when opening an X program after ssh'ing with X11 forwarding enabled?
-
".xauthority" does not exist on raspberry pi 4 -
This video help me resolved the issue. I had to install putty and Xmings to X11 apss on windows.
-
This package provides a miscellaneous assortment of X applications that ship with the X Window System, including:
- atobm, bitmap, and bmtoa, tools for manipulating bitmap images;
- ico, a demo program animating polyhedrons;
- oclock and xclock, graphical clocks;
- rendercheck, a program to test render extension implementations;
- transset, a tool to set opacity property on a window;
- xbiff, a tool which tells you when you have new email;
- xcalc, a scientific calculator desktop accessory;
- xclipboard, a tool to manage cut-and-pasted text selections;
- xconsole, which monitors system console messages;
- xcursorgen, a tool for creating X cursor files from PNGs;
- xditview, a viewer for ditroff output;
- xedit, a simple text editor for X;
- xeyes, a demo program in which a pair of eyes track the pointer;
- xgc, a graphics demo;
- xload, a monitor for the system load average;
- xlogo, a demo program that displays the X logo;
- xmag, which magnifies parts of the X screen;
- xman, a manual page browser;
- xmore, a text pager;
- xwd, a utility for taking window dumps ("screenshots") of the X session;
- xwud, a viewer for window dumps created by xwd;
- Xmark, x11perf, and x11perfcomp, tools for benchmarking graphical
operations under the X Window System;
-
- Make sure to format the SD and the SSD before.
- Make sure to install the Visual OS and NOT the LITE OS. This is to setup the boot loader order. Which enable USB boot.
- Yo segui el video y No encontre la forma de copiar al SSD usando solo lite OS.
-
Follow video until minute 9.
- After that is the SSH version, using only the command which I already tried but got stuck at the end since I was able to run the piclone in the terminal.
-
Accessing the pi over the network and launching the clone utility via ssh:
from a linux terminal:
ssh -X -Y pi[at]raspberrypi
(you can also launch this from Windows if you have xming + putty installed)
sudo apt install x11-apps
xclock
xeyes
xauth list
sudo bash
Then as root:
touch .Xauthority
xauth add raspberrypi/unix:10 MIT-MAGIC-COOKIE-1 bc6d1590cbf9f933c08cbfeb63b41
Then as pi:
sudo xeyes
sudo piclone
sudo dbus-launch piclone
sudo fdisk -l
sudo shutdown -h now