added stats
All checks were successful
All checks were successful
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user