Personal finances with Firefly on Synology NAS via Docker
Introduction to Firefly
Firefly III is an open-source personal finances manager. It was built by James Cole, and you can support the development on the platform here.
James is also upkeeping a really good documentation which you can (should) explore.
Creating a database for Firefly
First and foremost, Firefly needs to be connected to a database in order to work. I use MariaDB and you can find some quick tips on how to create the database here.
Take note of the database name, database username and password because they will be needed in the next step.
Creating a Firefly container
Create the Firefly III container where you usually keep your containers. In this example we will use /volume1/docker/firefly/.
Access your NAS via SSH, and then create the docker container with the following setup:
docker run -d \
--name=firefly \
-v /volume1/docker/firefly/export:/var/www/firefly-iii/storage/export \
-v /volume1/docker/firefly/upload:/var/www/firefly-iii/storage/upload \
-p 10080:80 \
-e APP_KEY=32charactersstring\
-e DB_HOST=nasip \
-e DB_CONNECTION=mysql \
-e DB_PORT=5432 \
-e DB_DATABASE=dbname\
-e DB_USERNAME=dbusername\
-e DB_PASSWORD=dbpsw\
-e APP_URL=https://firefly.mydomain.com \
-e TRUSTED_PROXIES=** \
jc5x/firefly-iii:latest
Redirecting subdomain to Synology NAS
Make a CNAME record pointing from a subdomain (i.e. firefly.mydomain.com) to the NAS via DDNS. It should look something like firefly.mydomain.com -> mydomain.ddns.net
Setting up reverse proxy on Let's Encrypt
Go to the folder where you set your proxy configurations in your Let's Enctypt container (i.e. volume1/docker/letsencrypt/config/nginx/proxy-confs/) and put the following block of code in a file names firefly.subdomain.conf.
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name firefly.*;
include /config/nginx/ssl.conf;
client_max_body_size 128M;
location / {
include /config/nginx/proxy.conf;
proxy_cache_bypass $http_upgrade;
proxy_pass http://192.168.1.200:10080;
}
}
Make sure you change MYIP with your NAS IP address, and PORT with the port you have set up for reverse proxy in your docker creation command (in this case 9080).
Once this is done and the file is saved, restart the Let's Encrypt container with the command docker restart letsencrypt.