Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
xavier-hernandez committed Apr 27, 2022
2 parents 138c4fc + 93ac8e5 commit 61eb215
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 41 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ RUN apk add --no-cache \
rm /etc/nginx/nginx.conf

COPY --from=builder /goaccess /goaccess
COPY /resources/goaccess/goaccess.conf /goaccess-config/goaccess.conf.bak
COPY /resources/goaccess/goaccess.conf /goaccess-config/goaccess.conf
COPY /resources/goaccess/GeoLite2-City.mmdb /goaccess-config/GeoLite2-City.mmdb

Expand All @@ -39,6 +40,7 @@ ADD /resources/nginx/.htpasswd /opt/auth/.htpasswd

WORKDIR /goan
ADD /resources/scripts/funcs funcs
ADD /resources/scripts/debug debug
COPY /resources/scripts/start.sh start.sh

VOLUME ["/opt/log"]
Expand Down
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,31 @@ The docker image scans and includes files matching the following criteria:
* proxy-host-*_access.log.gz
* proxy-host-*_access.log
* proxy-host-*.log
* proxy_host-*.log

Currently using GoAccess version: 1.5.5

<br>
**Dependencies:**
- GoAccess version: 1.5.5
- GeoLite2-City.mmdb (2022-04-05)

---
## Choose your version

**stable:** xavierh/goaccess-for-nginxproxymanager:latest
## **Docker**
- Image: https://hub.docker.com/r/xavierh/goaccess-for-nginxproxymanager
- OS/ARCH
- linux/amd64
- linux/arm/v7
- linux/arm64/v8
- ARM also available from Just5KY - [justsky/goaccess-for-nginxproxymanager](https://hub.docker.com/r/justsky/goaccess-for-nginxproxymanager)
- Tags: https://hub.docker.com/r/xavierh/goaccess-for-nginxproxymanager/tags
- stable - xavierh/goaccess-for-nginxproxymanager:latest
- latest stable development - xavierh/goaccess-for-nginxproxymanager:develop

**latest stable development:** xavierh/goaccess-for-nginxproxymanager:develop

Thanks to Just5KY you can find the arm version here: [justsky/goaccess-for-nginxproxymanager](https://hub.docker.com/r/justsky/goaccess-for-nginxproxymanager)
## **Github Repo**
- https://github.com/xavier-hernandez/goaccess-for-nginxproxymanager

---

Docker image: https://hub.docker.com/r/xavierh/goaccess-for-nginxproxymanager

Docker tags: https://hub.docker.com/r/xavierh/goaccess-for-nginxproxymanager/tags

Github Repo: https://github.com/xavier-hernandez/goaccess-for-nginxproxymanager

---



<br>

```yml
goaccess:
Expand All @@ -49,7 +47,8 @@ goaccess:
restart: always
environment:
- TZ=America/New_York
- SKIP_ARCHIVED_LOGS=False #optional
- SKIP_ARCHIVED_LOGS=False #optional
- DEBUG=False #optional
- BASIC_AUTH=False #optional
- BASIC_AUTH_USERNAME=user #optional
- BASIC_AUTH_PASSWORD=pass #optional
Expand All @@ -73,6 +72,7 @@ goaccess:
- PGID=0
- TZ=America/New_York
- SKIP_ARCHIVED_LOGS=False #optional
- DEBUG=False #optional
- BASIC_AUTH=False #optional
- BASIC_AUTH_USERNAME=user #optional
- BASIC_AUTH_PASSWORD=pass #optional
Expand All @@ -81,6 +81,7 @@ goaccess:
| Parameter | Function |
|-----------|----------|
| `-e SKIP_ARCHIVED_LOGS=True/False` | (Optional) Defaults to False. Set to True to skip archived logs, i.e. proxy-host*.gz |
| `-e DEBUG=True/False` | (Optional) HTML version of the running goaccess.conf wihtin the container |
| `-e BASIC_AUTH=True/False` | (Optional) Defaults to False. Set to True to enable nginx basic authentication. Docker container needs to stopped or restarted each time this flag is modified. This allows for the .htpasswd file to be changed accordingly. |
| `-e BASIC_AUTH_USERNAME=user` | (Optional) Requires BASIC_AUTH to bet set to True. Username for basic authentication. |
| `-e BASIC_AUTH_PASSWORD=pass` | (Optional) Requires BASIC_AUTH to bet set to True. Password for basic authentication. |
Expand Down
Binary file modified resources/goaccess/GeoLite2-City.mmdb
Binary file not shown.
2 changes: 1 addition & 1 deletion resources/goaccess/goaccess.conf
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ real-time-html true
# Specify the path to the input log file. If set, it will take
# priority over -f from the command line.
#
#log-file /opt/log/proxy.log
#GOAN_PROXY_FILES

# Send all debug messages to the specified file.
#
Expand Down
19 changes: 19 additions & 0 deletions resources/scripts/debug/goaccess_conf.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<title>GoAccess for Nginx Proxy Manager Logs - (#goan_version)</title>
<style>
body {
font-family: Arial, sans-serif;
}
code {
white-space: pre-wrap;
}
</style>
</head>
<body>
<code>
#GOAN_INPUT
</code>
</body>
</html>
18 changes: 18 additions & 0 deletions resources/scripts/funcs/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ADD DEBUGGING

function debug() {
if [[ "${DEBUG}" == "True" ]]
then
echo "DEBUG - ON"
cp /goan/debug/goaccess_conf.html /var/www/html/goaccess_conf.html

src="#goan_version"
rpl=${goan_version}
sed -i "s/$src/$rpl/" /var/www/html/goaccess_conf.html

sed -i -e '/#GOAN_INPUT/r /goaccess-config/goaccess.conf' /var/www/html/goaccess_conf.html
sed -i -e 's/#GOAN_INPUT//' /var/www/html/goaccess_conf.html
else
echo "DEBUG - OFF"
fi
}
25 changes: 10 additions & 15 deletions resources/scripts/funcs/logs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@ function logs_load_active() {
if [[ -d "${1}" && -x "${1}" ]];
then
IFS=$'\n'
for file in $(find "${1}" -name 'proxy-host-*.log' ! -name "*_error.log");
for file in $(find "${1}" -name 'proxy*host-*.log' ! -name "*_error.log");
do
if [ -f $file ]
then
if [ -r $file ] && R="Read = yes" || R="Read = No"
then
if [ -z "$goan_proxy_host" ]
then
goan_proxy_host="${goan_proxy_host}${file}"
echo "log-file ${file}" >> ${goan_container_proxy_logs}
goan_proxy_log_count=$((goan_proxy_log_count+1))
else
goan_proxy_host="${goan_proxy_host} ${file}"
goan_proxy_log_count=$((goan_proxy_log_count+1))
fi
echo -ne ' \t '
echo "Filename: $file | $R"
else
Expand All @@ -36,32 +30,33 @@ function logs_load_active() {
echo "Problem loading directory (check directory or permissions)... ${1}"
fi

if [ -z "$goan_proxy_host" ]
if [ $goan_proxy_log_count != 0 ]
then
touch ${goan_container_active_log}
goan_proxy_host=${goan_container_active_log}
else
echo "Found (${goan_proxy_log_count}) proxy logs...."
else
touch ${goan_container_active_log}
echo "log-file ${goan_container_active_log}" >> ${goan_container_proxy_logs}
fi
}

#Find active logs and check for read access
function logs_load_archive() {
touch ${goan_container_archive_log}

if [[ "${SKIP_ARCHIVED_LOGS}" == "True" ]]
then
echo "Skipping archived logs as requested..."
touch ${goan_container_archive_log}
else
if [[ -d "${1}" && -x "${1}" ]];
then
count=`ls -1 ${1}/proxy-host-*_access.log*.gz 2>/dev/null | wc -l`
count=`ls -1 ${1}/proxy-host-*_access.log*.gz | wc -l`
if [ $count != 0 ]
then
echo "Loading (${count}) archived logs from ${1}..."
zcat -f ${1}/proxy-host-*_access.log*.gz > ${goan_container_archive_log}
echo "log-file ${goan_container_archive_log}" >> ${goan_container_proxy_logs}
else
echo "No archived logs found at ${1}..."
touch ${goan_container_archive_log}
fi
goan_proxy_archive_log_count=$((count))
else
Expand Down
2 changes: 1 addition & 1 deletion resources/scripts/funcs/nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ function nginx_processing_count() {
src="#goan_processing_count"
rpl=$((goan_proxy_log_count+goan_proxy_archive_log_count))
sed -i "s/$src/$rpl/" /var/www/html/index.html
}
}
32 changes: 27 additions & 5 deletions resources/scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
#!/bin/bash
source $(dirname "$0")/funcs/nginx.sh
source $(dirname "$0")/funcs/logs.sh
source $(dirname "$0")/funcs/debug.sh

goan_version="GOAN v1.0.4"
goan_version="GOAN v1.0.6"
goan_log_path="/opt/log"
goan_dir_valid=0 #false
goan_proxy_host=""
goan_container_archive_log="/goaccess/access_archive.log"
goan_container_active_log="/goaccess/access.log"
goan_container_archive_log="/goaccess-config/access_archive.log"
goan_container_active_log="/goaccess-config/access.log"
goan_container_proxy_logs="/goaccess-config/proxy_logs"
goan_proxy_log_count=0
goan_proxy_archive_log_count=0

echo -e "\n${goan_version}\n"

#clean up
if [[ -f "$goan_container_proxy_logs" ]]; then
rm ${goan_container_proxy_logs}
fi
if [[ -f "$goan_container_archive_log" ]]; then
rm ${goan_container_archive_log}
fi
if [[ -f "$goan_container_active_log" ]]; then
rm ${goan_container_active_log}
fi
if [[ -f "/goaccess-config/goaccess.conf" ]]; then
cp /goaccess-config/goaccess.conf.bak /goaccess-config/goaccess.conf
fi


#Set NGINX basic authentication
nginx_basic_auth

Expand All @@ -29,6 +45,12 @@ nginx_processing_count
#RUN NGINX
tini -s -- nginx

#APPEND LOG FILE NAMES TO GOACCESS CONFIG
sed -i -e '/#GOAN_PROXY_FILES/r /goaccess-config/proxy_logs' /goaccess-config/goaccess.conf

#DEBUG
debug

#RUN GOACCESS
echo -e "\nProcessing ($((goan_proxy_log_count+goan_proxy_archive_log_count))) total log(s)...\n"
tini -s -- /goaccess/goaccess ${goan_container_archive_log} ${goan_proxy_host} --no-global-config --config-file=/goaccess-config/goaccess.conf
tini -s -- /goaccess/goaccess --no-global-config --config-file=/goaccess-config/goaccess.conf

0 comments on commit 61eb215

Please sign in to comment.