38 lines
751 B
Bash
Executable File
38 lines
751 B
Bash
Executable File
#!/bin/sh
|
|
|
|
if [ ${DISABLE_STATS} -eq 1 ] ; then
|
|
exit 0
|
|
fi
|
|
|
|
echo "# Configuring stats"
|
|
|
|
# make sure paths exists
|
|
mkdir -p "${PATH_AUTH}" "${PATH_STATS}" "${PATH_STATSDB}"
|
|
touch "${PATH_AUTH}/stats"
|
|
chown -R "${USERNAME}:${GROUPNAME}" "${PATH_AUTH}" "${PATH_STATS}" "${PATH_STATSDB}"
|
|
|
|
# stats endpoint
|
|
cat > /etc/nginx/http.d/stats.conf <<EOF
|
|
server {
|
|
listen ${STATS_PORT} default_server;
|
|
listen [::]:${STATS_PORT} default_server;
|
|
root ${PATH_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 ${PATH_AUTH}/stats;
|
|
}
|
|
EOF
|