Source code for different (mostly, monitoring) services running on https://terrty.net which is primarily my blog.
Contains Zabbix Server , Plausible, Remark42, Adminer, Newscope, Lighthouse CI, a small answers store for private pages, and Nginx serving https://terrty.net and https://ksinia.net, together with their databases (MySQL, PostgreSQL, ClickHouse).
For IPv6 work on Oracle Linux inside Oracle Cloud run:
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd --zone=public --add-port=443/udp --permanent
sudo firewall-cmd --reloadThe Zabbix server port 10051 stays out of the public zone: Docker publishes it past firewalld, so agent addresses are allow-listed in the DOCKER-USER chain with firewalld direct rules (sudo firewall-cmd --permanent --direct --get-all-rules).
The telegram-notifier service monitors Docker containers and sends Telegram alerts when they stop, restart, or become unhealthy. Currently configured to monitor zabbix-server, zabbix-web, and lhci containers.
Setup:
-
Create a Telegram bot:
- Message @BotFather on Telegram
- Send
/newbotand follow the instructions - Copy the bot token
-
Get your chat ID:
- Message @userinfobot on Telegram
- Copy your chat ID
-
Update
private/environment/telegram-notifier.env:- Set
TELEGRAM_NOTIFIER_BOT_TOKENto your bot token - Set
TELEGRAM_NOTIFIER_CHAT_IDto your chat ID
- Set
-
Start the monitoring service:
docker compose up -d telegram-notifier
To monitor additional containers: Add the label telegram-notifier.monitor: true to any service in docker-compose.yml.
config/cron/docker-prune.cron removes dangling images and week-old build cache every night. Install it after cloning, and again after editing it:
sudo install -o root -g root -m 0644 config/cron/docker-prune.cron /etc/cron.d/docker-prunerodnya-api (config/rodnya-api) stores what visitors select and write on the private static pages under /rodnya/<16 hex>/; nginx sends /rodnya/<page>/api/ to it. It accepts a page only if private/rodnya/<page>/index.html exists, keeps one append-only log per page in private/rodnya-data/<page>.jsonl, and shows all answers at /rodnya/<page>/api/admin/<ADMIN_KEY>/ with export.json and log.jsonl downloads there. Setup after cloning:
openssl rand -hex 16 | sed 's/^/ADMIN_KEY=/' > private/environment/rodnya-api.env
mkdir -p private/rodnya-data
docker run --rm -v "$PWD/private/rodnya-data:/d" alpine chown 65534:65534 /d
docker compose up -d --build rodnya-apiThe image is built on the server, so rerun the last command after changing its code.
Zabbix Agent setup for monitored hosts is in the separate file, docker-compose-zabbix-agent.yml.
The server accepts only PSK-encrypted connections, from agents and from zabbix_sender alike, and each host has its own key. To add a host:
- Allow-list its public address for port 10051 (see the firewall note above):
for m in "" --permanent; do sudo firewall-cmd $m --direct --add-rule ipv4 filter DOCKER-USER 0 -i <public-interface> -p tcp --dport 10051 -s <host-ip> -j RETURN; done
- On the monitored host, next to
docker-compose-zabbix-agent.yml, create the key readable by root only:An agent that runs as its own user (uid 1997) instead of root needs(umask 077; openssl rand -hex 32 > zabbix-agent.psk)
chown 1997:1997 zabbix-agent.psk. - In Zabbix, create the host with
ZBX_HOSTNAMEas its name. On its Encryption tab set "Connections to host" to PSK, tick only PSK under "Connections from host", and enterZBX_TLSPSKIDENTITYand the key. An identity can carry only one key across the whole server, so give every host its own. - Start the agent:
docker compose -f docker-compose-zabbix-agent.yml up -d. Within two minutes the host shows the agent as available, and the server log has noconnection of type "unencrypted" is not allowedlines for it.
zabbix_sender on such a host runs inside the agent container with the same key, so its values land on that host:
docker exec zabbix-agent sh -c 'exec zabbix_sender -z "$ZBX_SERVER_HOST" -s "$ZBX_HOSTNAME" --tls-connect psk --tls-psk-identity "$ZBX_TLSPSKIDENTITY" --tls-psk-file "$ZBX_TLSPSKFILE" "$@"' zabbix_sender -k <key> -o <value>The agent on this server itself (host "Zabbix server") reads its key from private/environment/zabbix-agent.psk, created the same way; compose refuses to start the agent without it.