added stats
All checks were successful
All checks were successful
This commit is contained in:
@@ -2,7 +2,7 @@ FROM alpine:3.21
|
|||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
apk --no-cache upgrade && \
|
apk --no-cache upgrade && \
|
||||||
apk --no-cache add tini nginx curl logrotate openssh-server nginx-mod-http-dav-ext \
|
apk --no-cache add tini nginx curl logrotate openssh-server nginx-mod-http-dav-ext goaccess \
|
||||||
php84 php84-fpm php84-mbstring php84-curl php84-ctype php84-dom php84-gd php84-json php84-openssl php84-session php84-simplexml php84-xml php84-zip \
|
php84 php84-fpm php84-mbstring php84-curl php84-ctype php84-dom php84-gd php84-json php84-openssl php84-session php84-simplexml php84-xml php84-zip \
|
||||||
php84-apcu php84-opcache php84-pecl-yaml php84-sqlite3 php84-mysqli \
|
php84-apcu php84-opcache php84-pecl-yaml php84-sqlite3 php84-mysqli \
|
||||||
php83 php83-fpm php83-mbstring php83-curl php83-ctype php83-dom php83-gd php83-json php83-openssl php83-session php83-simplexml php83-xml php83-zip \
|
php83 php83-fpm php83-mbstring php83-curl php83-ctype php83-dom php83-gd php83-json php83-openssl php83-session php83-simplexml php83-xml php83-zip \
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ services:
|
|||||||
web:
|
web:
|
||||||
image: docker.asperti.com/paspo/webserver-nginx
|
image: docker.asperti.com/paspo/webserver-nginx
|
||||||
ports:
|
ports:
|
||||||
- 8888:80
|
- 8888:80 # web server
|
||||||
- 2222:22
|
- 8889:8081 # stats page
|
||||||
|
- 8890:8080 # webdav access
|
||||||
|
- 2222:22 # sftp access
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/data
|
- ./data:/data
|
||||||
- ./ssh:/ssh # add authorized_keys file here
|
- ./ssh:/ssh # add authorized_keys file here
|
||||||
@@ -21,6 +23,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
LOG_DAYS: 14 # default 7
|
LOG_DAYS: 14 # default 7
|
||||||
WEBDAV_PORT: 8080 # default: 8080
|
WEBDAV_PORT: 8080 # default: 8080
|
||||||
|
STATS_PORT: 8081 # default: 8081
|
||||||
PHP: php84 # none (default), php82, php83, php84
|
PHP: php84 # none (default), php82, php83, php84
|
||||||
POSTSIZE: 256M # default: 256M
|
POSTSIZE: 256M # default: 256M
|
||||||
PUID: 1000 # default: 1000
|
PUID: 1000 # default: 1000
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
WEBROOT=/data/www
|
WEBROOT=/data/www
|
||||||
WEBDAV_PORT=${WEBDAV_PORT:-8080}
|
WEBDAV_PORT=${WEBDAV_PORT:-8080}
|
||||||
|
STATS_PORT=${STATS_PORT:-8081}
|
||||||
PHP=${PHP:-none}
|
PHP=${PHP:-none}
|
||||||
POSTSIZE=${POSTSIZE:-256M}
|
POSTSIZE=${POSTSIZE:-256M}
|
||||||
USERNAME=${USERNAME:-theuser}
|
USERNAME=${USERNAME:-theuser}
|
||||||
@@ -125,8 +126,8 @@ EOF
|
|||||||
touch /app/htpasswd
|
touch /app/htpasswd
|
||||||
|
|
||||||
# make sure nginx can log
|
# make sure nginx can log
|
||||||
mkdir -p /data/logs
|
mkdir -p /data/logs /data/stats /data/stats.db
|
||||||
chown -R "${USERNAME}" /data/logs
|
chown -R "${USERNAME}:${GROUPNAME}" /data/logs /data/stats /data/stats.db
|
||||||
|
|
||||||
# configure logrotate
|
# configure logrotate
|
||||||
LOG_DAYS=${LOG_DAYS:-7}
|
LOG_DAYS=${LOG_DAYS:-7}
|
||||||
@@ -141,11 +142,37 @@ cat >/etc/logrotate.d/nginx <<EOF
|
|||||||
su ${USERNAME} ${GROUPNAME}
|
su ${USERNAME} ${GROUPNAME}
|
||||||
postrotate
|
postrotate
|
||||||
/usr/sbin/nginx -s reopen
|
/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
|
endscript
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
crond -b
|
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
|
# start nginx
|
||||||
echo starting nginx
|
echo starting nginx
|
||||||
nginx
|
nginx
|
||||||
|
|||||||
Reference in New Issue
Block a user