SimpNas server with docker - home assistant, radicale , jellyfin & esphome (tutorial) - Printable Version +- PINE64 (https://forum.pine64.org) +-- Forum: ROCKPRO64 (https://forum.pine64.org/forumdisplay.php?fid=98) +--- Forum: RockPro64 Projects, Ideas and Tutorials (https://forum.pine64.org/forumdisplay.php?fid=104) +--- Thread: SimpNas server with docker - home assistant, radicale , jellyfin & esphome (tutorial) (/showthread.php?tid=12806) |
SimpNas server with docker - home assistant, radicale , jellyfin & esphome (tutorial) - GreyLinux - 01-17-2021 Outdated Tutorial: Please use as a guide only Hi all, I've been meaning to write this tutorial since last year , now right out of the gate I will say I am far from an expert. This is how I set up my NAS Server and docker containers , but I will gladly accept any critique of my setup and advice to better secure or improve the overall setup. To start with I did try OpenMediaVault, I got everything how I wanted it, however I felt that OpenMediaVault was too bloated for my needs and a little complicated in some of its options. Whilst on the Armbian forum ,seeking advice for getting the fan to work properly for my server (yes I did try tuxd3v 's ATS fan configuration but this didn't work after using a later kernel to get my sata card to work (more on that later)). I discovered SimpNAS , I posted a thread on this forum for all who are interested . SimpNAS was exactly what I was looking for , simple, elegant and easy . So to begin I setup OpenMediaVault and long story short I had issues with the pine64 supplied Sata card , I wont go in to detail here as there are many threads that describe this issue, here is some slight insight So I bought a marvell 88SE9230 Sata card , which so far has been absolutely amazing , rock solid no matter what I throw at it, but to use said card I had to use a newer kernel which as described in the thread resulted in me not being able to use ATS to control the fan. Now down to business , I have a rockpro64 with NAS case , tall heatsink , case fan, a marvell 88SE9230 Sata card, 2 SSD drives and a very decent SD card , the software is Armbian , with SimpNAS and docker installed and 6 containers - Nginx, Portainer, Homeassistant , Radicale caldav server , Jellyfin media server and EspHome for my home automation gadgets. home assistant and radicale are exposed to internet so they are accessible from outside my local network . so here are my instructions :
Code: rmmod pwm-fan 10. add udev rule so drives will show up nano /etc/udev/rules.d/99-marvell.rules. Code: ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x1b4b", ATTR{device}=="0x9230", RUN+="/bin/bash -c 'echo %k > /sys/bus/pci/drivers/ahci/bind'" 11. reboot then type lsblk to see if drives are discovered 12. now install SimpNAS Code: wget https://simpnas.com/install.sh; bash install.sh 13. follow setup wizard on url shown in terminal at the end of install . 14. login into SimpNAS admin panel using username administrator and password set during wizard 15. in admin panel Add Volumes to add the drives in SimpNAS 16. add users in user section 17. add shares to drives 18. at this point you now have your NAS setup , you can upload all the files you need to via samba 19. now onto portainer run this to get portainer installed and running, Docker is installed when SimpNAS is. Code: docker volume create portainer_data 20. now pull the images for the other containers, you can do this via the portainer UI (hence why I installed it first or via command line ) I like to do this now as it can take some time to pull the images ,although they will be installed with docker-compose later, if you prefer doing it all at once and don't want to know how docker works . Code: docker pull homeassistant/home-assistant:stable tomsquest/docker-radicale esphome/esphome nginx:latest 21. now to install docker compose which will help later with renewing lets encrypt certificates via certbot . first we need a few packages Code: apt install python3 python3-pip python3-setuptools python3-dev libffi-dev 22. then using the newly installed pip3 install wheel and docker-compose Code: pip3 install wheel 23.now lets create a docker-compose.yml file to start our containers and provide all the info they need to get running. When docker compose is run it will create all the necessary directories and files based on this docker-compose file . Code: version: '3.7' Code: user www-data; Code: openssl dhparam -out /root/nginx/cert/dhparam.pem -dsaparam 2048 Code: [server] Code: apt install apache2-utils 28. now in order for radicale to work a radicale user and group needs to be created , more info can be gleamed from the provider of the Radicale docker container , here Code: addgroup --gid 2999 radicale 29. we are almost there now , just a few more steps and some optional ones at the end . Time to install fail2ban and certbot ( certbot obtains a lets encrypt certificate for us and will renew the cert via a cronjob specified later .) Code: apt install fail2ban certbot Code: cp jail.conf jail.local Code: # "ignoreip" can be a list of IP addresses, CIDR masks or DNS hosts. Fail2ban Code: nano /etc/fail2ban/jail.d/hass.conf Code: nano /etc/fail2ban/filter.d/hass.conf 32. A word of warning , if you are starting home assistant from new( as in no existing configuration file yet) I would disable fail2ban for now the reason is once restarted it will complain that there is no log located at /root/homeassistant/home-assistant.log . As stated in home assistants documentation linked above you need to have Code: logger: added to your configuration file for this to work. If you have an existing home assistant configuration you can copy this across now to a home assistant directory located in the root home directory . add the above logger to the config file and then use the touch command to create the home-assistant.log file . Fail2ban can then be restarted or started if disabled and it wont complain about a missing file and will work when the conatiner is started and begins logging to said file . Code: systemctl restart fail2ban.service now check to see if the jail is up and working Code: fail2ban-client status hass-iptables 33. Ok finally certbot , to get certbot to work port 80 and port 443 need to be open on your router and directed to the Rockpro64 IP address (I would also highly recommend that a static IP is set for the rockpro64 in your routers settings also ) lets begin by getting a lets encrypt certificate for the duckdns subdomains associated with our home assisatnt and radicale services. Code: certbot certonly --standalone -d yourRadicaleAddress.duckdns.org -d yourHomeassistantAddress.duckdns.org now certbot can renew this certificate for all associated subdomains when they have less than 30 days left until expiration this is done with a cronjob Code: crontab -e Code: @daily certbot renew --pre-hook "docker-compose -f /root/docker-compose.yml down" --post-hook "docker-compose -f /root/docker-compose.yml up -d" 34. and finally lets start the containers and run them in the background . Code: docker-compose up -d now you should be able to access the home assistant container at https://yourHomeassisantAddress.duckdns.org or locally at 192.168.1.120:8123(notice port 8123) you can access the Radicale container via https://yourRadicaleAddress.duckdns.org/radicale/ (notice the extension /radicale/ this was specified in the nginx.conf file earlier.) I would suggest closing the ports on teh router for the time being and accessing home assistant via its local IP address until you have a password and the setup complete then reopen the ports to access outside of you local network . this is of course not necessary if you have an existing configuration with home assistant and are transitioning to the Rockpro64 server . 36. the next few steps are optional , I installed Jellyfin as media server , I did this through the admin panel of SimpNAS under apps this creates a docker container for you and removes some of the steps to get it to access your media files correctly . of course you can install it manually like we did with the other containers and even use docker-compose by adding the container to the docker-compose.yml file , please note that when certbot renews the certificate it stops all the containers in this file before renewing the certs this is so port 80 and 443 are open for it to use and then it restarts the containers again. this will not happen to Jellyfin if installed manually or via the SimpNAS apps 37 . to top it all off, for those who want the firewall blocking ports on their local network to and from the rockpro64 , this is a little over kill as only port 80 and 443 are open to the outside world via the router, but I understand that some people like to add rules for local traffic to prevent spread locally of a virus or similar between machines on that network . I say this because it quite difficult to get a firewall working properly as docker provides it own set of rules to control the firewall and when you add rules of your own it might not work well with dockers rules if they work at all , so as suggested by a great article I found regarding this issue . here is a solution firstly create a iptables.conf file in /etc/ directory Code: *filter and add any rules you want after allow something, those above are just examples using the ports most of the services we have installed, use . next add these new rules from the file to the kernel to implement them Code: iptables-restore -n /etc/iptables.conf and then create a service that loads this file on startup . Code: nano /etc/systemd/system/iptables.service then add this Code: [Unit] Code: systemctl enable iptables.service I think I've covered most of the setup process for my install , of course you will need to configure the service to suit your individual needs and for that I turn you to there excellent documentation Jellyfin Radicale HomeAssistant Esphome Docker SimpNAS Duckdns if you have any questions or feedback for me I will help where I can and edit the tutorial based on giving accurate information . |