Immich Matomo integration

docker-compose.yml

`name: immich
services:
immich-server:
container_name: immich_server
image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
volumes:
- ${UPLOAD_LOCATION}:/usr/src/app/upload
- /etc/localtime:/etc/localtime:ro
env_file:
- .env
# Expose only to the internal network, not to host directly
expose:
- ‘2283’
depends_on:
- redis
- database
restart: always
healthcheck:
disable: false

nginx-proxy:
container_name: immich_nginx_proxy
image: nginx:alpine
ports:
- ‘2283:80’ # Expose on the same port Immich was using before
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
depends_on:
- immich-server
restart: always

immich-machine-learning:
container_name: immich_machine_learning
image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
volumes:
- model-cache:/cache
env_file:
- .env
restart: always
healthcheck:
disable: false
redis:
container_name: immich_redis
image: docker.io/redis:6.2-alpine@sha256:148bb5411c184abd288d9aaed139c98123eeb8824c5d3fce03cf721db58066d8
healthcheck:
test: redis-cli ping || exit 1
restart: always
database:
container_name: immich_postgres
image: docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:739cdd626151ff1f796dc95a6591b55a714f341c737e27f045019ceabf8e8c52
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_DB: ${DB_DATABASE_NAME}
POSTGRES_INITDB_ARGS: ‘–data-checksums’
volumes:
# Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
- ${DB_DATA_LOCATION}:/var/lib/postgresql/data
healthcheck:
test: >-
pg_isready --dbname=“$${POSTGRES_DB}” --username=“$${POSTGRES_USER}” || exit 1; Chksum=“$$(psql --dbname=”$${POSTGRES_DB}" --username=“$${POSTGRES_USER}” --tuples-only --no-align --command=‘SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database’)“; echo “checksum failure count is $$Chksum”; [ “$$Chksum” = ‘0’ ] || exit 1
interval: 5m
start_interval: 30s
start_period: 5m
command: >-
postgres -c shared_preload_libraries=vectors.so -c 'search_path=”$$user", public, vectors’ -c logging_collector=on -c max_wal_size=2GB -c shared_buffers=512MB -c wal_compression=on
restart: always
volumes:
model-cache:
`
########################################################

nginx.conf


server {
    listen 80;

    location / {
        sub_filter '</head>' '
        <!-- Matomo -->
        <script>
          var _paq = window._paq = window._paq || [];
          /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
          _paq.push([\'trackPageView\']);
          _paq.push([\'enableLinkTracking\']);
          (function() {
            var u="https://info.ynm.hu/";
            _paq.push([\'setTrackerUrl\', u+\'matomo.php\']);
            _paq.push([\'setSiteId\', \'9\']);
            var d=document, g=d.createElement(\'script\'), s=d.getElementsByTagName(\'script\')[0];
            g.async=true; g.src=u+\'matomo.js\'; s.parentNode.insertBefore(g,s);
          })();
        </script>
        <!-- End Matomo Code -->
        </head>';
        sub_filter_once on;

        proxy_pass http://immich-server:2283;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

root@ynm:/home/kepek/immich-app# ls
docker-compose.yml library nginx.conf postgres

Crontab To Log

5 * * * * /usr/bin/php8.4 /home/info/public_html/console core:archive --url=http://info.ynm.hu > /home/info/logs/info-arhivum.log

Crontab Dev/Null

5 * * * * /usr/bin/php8.4 /home/info/public_html/console core:archive --url=http://info.ynm.hu > /dev/null 2>&1