Miniflux

With setting up nextcloud I have prepared most of the building blocks and am ready to start migrating simpler services back to my local network. First thing I migrated was Miniflux. I have chosen this one since it is in essence very simple service. What I needed was:

  • PostgreSQL database
  • Miniflux

And Miniflux itself is single GO binary. In this case packaged up as an container image. My full compose.yml file for the docker-compose ended up looking quite simple:

services:
  miniflux:
    image: miniflux/miniflux:latest
    healthcheck:
      test: ["CMD", "/usr/bin/miniflux", "-healthcheck", "auto"]
    ports:
      - "10001:8080"
    depends_on:
      db:
        condition: service_healthy
    environment:
      - DATABASE_URL=postgres://SOMEUSER:SOMEPASSWORD@db/SOMEDB?sslmode=disable
      - WORKER_POOL_SIZE=4
      - POLLING_FREQUENCY=5
      - BATCH_SIZE=200
      - BASE_URL=https://someurl
      - CLEANUP_FREQUENCY_HOURS=72
      - RUN_MIGRATIONS=1
  db:
    image: postgres:15
    environment:
      - POSTGRES_USER=SOMEUSER
      - POSTGRES_PASSWORD=SOMEPASSWORD
      - POSTGRES_DB=SOMEDB
    volumes:
      - miniflux-db:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "miniflux"]
      interval: 10s
      start_period: 30s
volumes:
  miniflux-db:

DB migration

I couldn’t just start from scratch though as I already had Miniflux hosted on one of my VPS servers, so I had to migrate the data first. Process was also quite simple.

First I had to dump database on the server side. Postgres is directly installed on the host there, from the PGDG repository, so it is also up-to-date.

sudo -u postgres pg_dump -d miniflux > miniflux.sql

Then I downloaded the SQL dump locally to the NUC. Now, I can’t just import the database because it is running in a container. Well, nothing to it. I have installed postgresql-client package from the official Debian repository, and forwarded port for the database to some local port temporarily eg.:

    ports:
      - "5432:5432"

And then restored the database:

psql -U SOMEUSER -d SOMEDATABASE -h localhost < miniflux.sql

Cleaned up port-forwarding from the compose.yml and voila, that’s it. Quite simple and painless.

HAProxy

HAProxy got simple ACL and backend section to match requests in the frontend section

frontend main
	bind *:80
	bind *:443 ssl crt /etc/haproxy/certs/

	http-request redirect scheme https unless { ssl_fc }

	# https://access.redhat.com/solutions/3986281
	http-request set-header X-Forwarded-Proto http if !{ ssl_fc }
	http-request set-header X-Forwarded-Proto https if { ssl_fc }

	http-response set-header Strict-Transport-Security "max-age=16000000; includeSubDomains; preload;"

	acl local_network src LOCALSUBNET/MASK
 	acl is_nextcloud hdr(host) -i SOMEOTHERURL
 	acl is_miniflux hdr(host) -i SOMEURL
	acl url_discovery path /.well-known/caldav /.well-known/carddav

	http-request redirect location /remote.php/dav/ code 301 if url_discovery is_nextcloud

	use_backend nextcloud if is_nextcloud local_network
	use_backend miniflux if is_miniflux local_network
	default_backend non_existent

and then the backend section:

backend miniflux
	mode http
	option httpchk
	http-check send meth GET uri /
	server local-docker-miniflux localhost:SOMEPORT check

Conclusion

This whole process was quite simple and painless. Nothing innovative here, goal is just to move services locally, shut down servers that are somewhere else, and then rework setup once again to make it redundant, modern and cool. Until then I can hopefully uncover some pain-points and resolve them.