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
git
Linux
docker
portainer
ShellInABox
Homer
Guacamole
JDownloader
filebrowser
Transmission
Rpi - Monitor
NextCloud
Pi-Hole
nginx proxy manager
qbittorrent

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.

Search by Apps

git
Linux
docker
portainer
ShellInABox
Homer
Guacamole
JDownloader
filebrowser
Transmission
Rpi - Monitor
NextCloud
Pi-Hole
nginx proxy manager
qbittorrent

Click on the app image to get more information

LAN + Pi

Logo

Some text about me in culpa qui officia deserunt mollit anim..

Popular Post

Image

Image

Image

Follow Me

Some text..

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.

Step by step:

    1. Make sure to format the SD and the SSD before.
    2. Go to Rpi website to download and Install the "Pi Imager"
    3. 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.

      1. Access the Advance options for the OS setup
      2. Remember to use the Ctrl + Shift + x to see the Advance options.
      3. Disable overscan
      4. Set hostname: rpi-srv
      5. Enable SSH
      6. Set Password
      7. Set Configure WIFI & country
      8. Set Local & Keyboard Layout
      9. Skip first-run Wizard.
      10. Disable Telemetry.

    Flash RPi OS

    — Flash RPi Desktop(not lite as in video) OS ( Ctrl + Shift + x → Advance options)
    1. 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

      1. Connect to Raspberry Pi over SSH
      2. ssh pi@YOUR_RPI_IP

        Default username is pi & password is: raspberry

      3. Update OS and firmware
      4. sudo apt update && sudo apt full-upgrade sudo rpi-update
      5. Reboot Raspberry Pi
      6. sudo reboot
      7. How to Update EEPROM on Raspberry Pi 4 For USB Boot...
        Install latest bootloader
      8. sudo rpi-eeprom-update -d -a
      9. Launch this tool for final configurations
      10. sudo raspi-config advance options > boot order > USB advance options > bootloader Version > E1 - last version ROM display options > Resolution > MODE 82 - 16:9
      11. Reboot Raspberry Pi
      12. sudo reboot
      13. Copy SD to USB or SSD
        1. Connect to Pi using HDMI or VNC
        2. Enable VNC in the Pi

          Interface menu > VNC > enable. Using the code below:

          sudo raspi-config
        3. Go to Menu > accessories > SD card copy.
        4. From SD (dev/mmcblk) to SSD
        5. sudo reboot
      14. Once it Finish, Turn off the pi
        Remove the SD and boot from SSD
      15. sudo poweroff
    2. To setup a Static IP address

      Go to the Router and assign an IP.

    3. docker + pi
      Docker on Raspberry Pi
      1. 5:46 — Docker Explained
      2. 6:32 — Install Docker
      3. Install git
      4. Sudo apt install git
      5. Run Script
      6. 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
    4. portainer
      Portainer

      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

      1. In Portainer add the link below
      2. Portainer > settings > url (link below) > save settings
      3. 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

    5. shellinabox
      Shell In A Box

      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:

    • Homer
      Homer
      I installed it from Portainer.
      • apt templets > homer > deploy the container
      1. 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

      2. Modify Homer page:
        1. Change title and sub-title
        2. To change page color use a color generator web
        3. comment the optional message with #
        4. Go to services
          1. modify the apps and add more...
        5. Change images
          1. Find a nice png & copy the url
          2. Go to the terminal and downloaded
          3. cd // to root
          4. wget ( url link — from the image)
          5. ls // to check if it download
          6. mv imgName.png newImgName.png // To rename img
          7. ls
          8. sudo mv newImgName.png /portainer/Files/AppData/Config/Homer/assets/tools/ //move img to another location
          9. cd /portainer/Files/AppData/Config/Homer/assets
          10. sudo nano config.yml

    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:

    • Guacamole
      Guacamole
      Go to Docker hub and download Guacamole
    • 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:

      1. Containers > Add Container
      2. Name: Guacamole
      3. Image: oznu/guacamole:armhf
      4. Manual network port publishing: Click on publish a new network port
      5. Host: 9100 /avoid using port 8080 on host. it is really common.
      6. Container: 8080
      7. Volume Tab
        1. Volume mapping: Click on map additional volume
        2. Container: /config
        3. Click on bind
        4. host: /portainer/Files/AppData/Config/guacamole
      8. Restart Policy tab
        • Set to Unless Stopped
      9. Deploy the container.
      1. Go to 192.168.1.250:9100
      2. Login
        • Default user/passw: guacadmin
      3. Settings > preference > change password
      4. 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:

    • JDownloader
      JDownloader

      Go to Docker hub and download JDownloader

      1. Make sure to use one that support X64 & ARM
      2. Name:
      3. 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:

      1. Containers > Add Container
      2. Name: JDownloader
      3. Image: jaymoulin/jdownloader:1.4.3-armhf
      4. Manual network port publishing: Click on publish a new network port
      5. Host: 3129
      6. Container: 3129
      7. Volume Tab
        1. Volume mapping: Click on map additional volume X2
        2. Click on bind for both
        3. Container: /opt/JDownloader/cfg
        4. Host: /portainer/Files/AppData/Config/JDownloader
        5. Container: /opt/JDownloader/Downloads
        6. Host: /portainer/Downloads
      8. Environment tab
        1. Click 3 times on Add environment variable.
        2. Names:
          1. MYJD_USER
          2. MYJD_PASSWORD
          3. MYJD_DEVICE_NAME
        3. Values:
          1. my usuario@tutanota.com
          2. my clave de jdownloader
          3. RaspberryPi
      9. Restart Policy tab
      10. Deploy the container.
      1. Go to 192.168.1.250:3129
      2. no me deja connectar
      3. Go to the website and login
        • my.jdownloader.org/login
    • File Browser
      File Browser

      Go to Docker hub and download File Browser

      1. Make sure to use one that support X64 & ARM
      2. Name: filebrowser/filebrowser
      3. Docker Hub
      4. 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

      -More details-

    • Note: Basado en el Docker Compose de arriba es q se configura la info de abajo:

      1. Containers > Add Container
      2. Name: FileBrowser
      3. Image: filebrowser/filebrowser
      4. Manual network port publishing: Click on publish a new network port
      5. Host: 8123
      6. Container: 80
      7. Volume Tab
        1. Volume mapping: Click on map additional volume X2
        2. Click on bind
        3. Container: /srv
        4. Host: /portainer/Downloads
      8. Restart Policy tab
        • Set to never
      9. Deploy the container.
      1. Go to 192.168.1.250:8123
      2. Default login: admin & admin

    Chapter Five

    Transmission
    Transmission

    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:

      1. Take the image and re-Created
      2. Go to Portainer > container > Portainer image
      3. Stop the container
      4. Delete the image
      5. 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
      1. Go to Portainer
      2. Open the container I want to update
      3. Stop container
      4. Recreate > Pull latest Image > Done
      5. 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.

    -more info-

    -more info-

    RPI Monitor

    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

      1. Go to the Portainer
      2. App templates
      3. Search the rpi-Monitor app
      4. Deploy the Stack
      5. No setup needed.
      1. Go to Portainer
      2. Stack tab
      3. click on the "raspberrypi-docker-monitor"
    • NextCloud Pi
      Dashboard example
      1. Go to Rpi-Monitor page and setup Dashboard.
        • 192.168.1.250:3000
      2. login
      3. configure icone > Add data sources > prometheus > select
      4. Under HTTP, add the URL
        1. To find the IP address, go to portainer
        2. Stack tab > click on the"raspberrypi-docker-monitor"
        3. scroll down and copy the IP for"monitoring-prometheus".
        4. in my case, it is 172.18.0.4
        5. add port 9090
        6. For the URL will be http://172.18.0.4:9090
        7. Save & Test
      5. Add dashboard
      6. clicking the + tab > import
      7. Go to the github
        • URL
        • pi-hosted/pi-hosted_template/configs/dashboard_by_oijkn.json
      8. Copy dashboard_by_oijkn.json file
      9. Add copy file on under Import via json box
      10. Load > import
    NextCloud Pi
    NextCloud Pi

    Chapter Eight

    In this Chapter we will learn how to Install NextCloud_Pi on the Raspberry Pi using Docker and Portainer.

    Step by step:

    • NextCloud Pi
      NextCloud Pi
      This version of NextCloud is made for raspberry pi and its called NextCloudPi
      1. Login to Portainer
      2. App templates >search for NextCloudPi
      3. Deploy the Container.
      4. Click here to learn more about the NextCloudPi project
      1. Go to the URL: https://192.168.1.250:8443
      2. Save the admin and user password displaying on the screen.
      3. Open a new tab and go to https://192.168.1.250:8443
      4. Login using the admin credentials you previously saved.
        1. Username: ncp
        2. password: (adminPassword)
      5. Next Cloud first run > run
      6. Under external access > No
      7. Finish > Go back to NextCloudPi web panel
      1. Under configurations
      2. Click on nc-trusted-domains
      3. Add the Raspberry Pi IP address
        • 192.168.1.250
      4. Add the domain if you have one.
      5. Apply.
      1. Go to the URL: https://192.168.1.250:8443
      2. The error is gone.
      3. Login with the second password previously stored.
        • Username: ncp
        • password: second password.
      4. Enjoy NextCloud. Make sure to change the password

    Blog Name

    TITLE HEADING

    Title description, Dec 7, 2017
    Image

    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
    Image

    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

    Image

    Some text about me in culpa qui officia deserunt mollit anim..

    Popular Post

    Image

    Image

    Image

    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; <br /> - ico, a demo program animating polyhedrons;<br /> - oclock and xclock, graphical clocks;<br /> - rendercheck, a program to test render extension implementations;<br /> - transset, a tool to set opacity property on a window;<br /> - xbiff, a tool which tells you when you have new email;<br /> - xcalc, a scientific calculator desktop accessory;<br /> - xclipboard, a tool to manage cut-and-pasted text selections;<br /> - xconsole, which monitors system console messages;<br /> - xcursorgen, a tool for creating X cursor files from PNGs;<br /> - xditview, a viewer for ditroff output;<br /> - xedit, a simple text editor for X;<br /> - xeyes, a demo program in which a pair of eyes track the pointer;<br /> - xgc, a graphics demo;<br /> - xload, a monitor for the system load average;<br /> - xlogo, a demo program that displays the X logo;<br /> - xmag, which magnifies parts of the X screen;<br /> - xman, a manual page browser;<br /> - xmore, a text pager;<br /> - xwd, a utility for taking window dumps ("screenshots") of the X session;<br /> - xwud, a viewer for window dumps created by xwd;<br /> - Xmark, x11perf, and x11perfcomp, tools for benchmarking graphical<br /> operations under the X Window System;
      x11
      Example of X11 apps

      more info

      • 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: <br /> from a linux terminal:<br /> ssh -X -Y pi[at]raspberrypi<br /> (you can also launch this from Windows if you have xming + putty installed)<br /> sudo apt install x11-apps<br /> xclock<br /> xeyes<br /> xauth list<br /> sudo bash<br /><br /> Then as root:<br /> touch .Xauthority<br /> xauth add raspberrypi/unix:10 MIT-MAGIC-COOKIE-1 bc6d1590cbf9f933c08cbfeb63b41<br /><br /> Then as pi:<br /> sudo xeyes<br /> sudo piclone<br /> sudo dbus-launch piclone<br /> sudo fdisk -l<br /> sudo shutdown -h now