added stats
All checks were successful
Container Publish / on-success-skip (push) Has been skipped
Container Publish / build-image (amd64) (push) Successful in 1m11s
Container Publish / build-image (arm64) (push) Successful in 43s
Container Publish / update docker manifest (push) Successful in 14s

This commit is contained in:
2025-07-30 13:04:14 +02:00
parent 04fda43862
commit f91afcfb4f
3 changed files with 35 additions and 5 deletions

View File

@@ -2,6 +2,7 @@
WEBROOT=/data/www
WEBDAV_PORT=${WEBDAV_PORT:-8080}
STATS_PORT=${STATS_PORT:-8081}
PHP=${PHP:-none}
POSTSIZE=${POSTSIZE:-256M}
USERNAME=${USERNAME:-theuser}
@@ -125,8 +126,8 @@ EOF
touch /app/htpasswd
# make sure nginx can log
mkdir -p /data/logs
chown -R "${USERNAME}" /data/logs
mkdir -p /data/logs /data/stats /data/stats.db
chown -R "${USERNAME}:${GROUPNAME}" /data/logs /data/stats /data/stats.db
# configure logrotate
LOG_DAYS=${LOG_DAYS:-7}
@@ -141,11 +142,37 @@ cat >/etc/logrotate.d/nginx <<EOF
su ${USERNAME} ${GROUPNAME}
postrotate
/usr/sbin/nginx -s reopen
nice -n 19 /usr/bin/goaccess /data/logs/nginx-access.log.1 --agent-list --anonymize-ip --real-os --output /data/stats/index.html --log-format COMBINED --tz="${TZ}" --db-path=/data/stats.db --persist --restore
endscript
}
EOF
crond -b
# stats endpoint
cat > /etc/nginx/http.d/stats.conf <<EOF
server {
listen ${STATS_PORT} default_server;
listen [::]:${STATS_PORT} default_server;
root /data/stats;
location / {
index index.html;
try_files /index.html =404;
}
location /index.html {
try_files /index.html =404;
}
location / {
return 404;
}
auth_basic "Restricted area";
auth_basic_user_file /app/htpasswd;
}
EOF
# start nginx
echo starting nginx
nginx