Skip to content

Commit 61eb215

Browse files
Merge branch 'develop' into main
2 parents 138c4fc + 93ac8e5 commit 61eb215

File tree

9 files changed

+98
-41
lines changed

9 files changed

+98
-41
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ RUN apk add --no-cache \
2929
rm /etc/nginx/nginx.conf
3030

3131
COPY --from=builder /goaccess /goaccess
32+
COPY /resources/goaccess/goaccess.conf /goaccess-config/goaccess.conf.bak
3233
COPY /resources/goaccess/goaccess.conf /goaccess-config/goaccess.conf
3334
COPY /resources/goaccess/GeoLite2-City.mmdb /goaccess-config/GeoLite2-City.mmdb
3435

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

4041
WORKDIR /goan
4142
ADD /resources/scripts/funcs funcs
43+
ADD /resources/scripts/debug debug
4244
COPY /resources/scripts/start.sh start.sh
4345

4446
VOLUME ["/opt/log"]

README.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,31 @@ The docker image scans and includes files matching the following criteria:
1414
* proxy-host-*_access.log.gz
1515
* proxy-host-*_access.log
1616
* proxy-host-*.log
17+
* proxy_host-*.log
1718

18-
Currently using GoAccess version: 1.5.5
19-
20-
<br>
19+
**Dependencies:**
20+
- GoAccess version: 1.5.5
21+
- GeoLite2-City.mmdb (2022-04-05)
2122

2223
---
23-
## Choose your version
2424

25-
**stable:** xavierh/goaccess-for-nginxproxymanager:latest
25+
## **Docker**
26+
- Image: https://hub.docker.com/r/xavierh/goaccess-for-nginxproxymanager
27+
- OS/ARCH
28+
- linux/amd64
29+
- linux/arm/v7
30+
- linux/arm64/v8
31+
- ARM also available from Just5KY - [justsky/goaccess-for-nginxproxymanager](https://hub.docker.com/r/justsky/goaccess-for-nginxproxymanager)
32+
- Tags: https://hub.docker.com/r/xavierh/goaccess-for-nginxproxymanager/tags
33+
- stable - xavierh/goaccess-for-nginxproxymanager:latest
34+
- latest stable development - xavierh/goaccess-for-nginxproxymanager:develop
2635

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

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

3140
---
3241

33-
Docker image: https://hub.docker.com/r/xavierh/goaccess-for-nginxproxymanager
34-
35-
Docker tags: https://hub.docker.com/r/xavierh/goaccess-for-nginxproxymanager/tags
36-
37-
Github Repo: https://github.com/xavier-hernandez/goaccess-for-nginxproxymanager
38-
39-
---
40-
41-
42-
43-
<br>
4442

4543
```yml
4644
goaccess:
@@ -49,7 +47,8 @@ goaccess:
4947
restart: always
5048
environment:
5149
- TZ=America/New_York
52-
- SKIP_ARCHIVED_LOGS=False #optional
50+
- SKIP_ARCHIVED_LOGS=False #optional
51+
- DEBUG=False #optional
5352
- BASIC_AUTH=False #optional
5453
- BASIC_AUTH_USERNAME=user #optional
5554
- BASIC_AUTH_PASSWORD=pass #optional
@@ -73,6 +72,7 @@ goaccess:
7372
- PGID=0
7473
- TZ=America/New_York
7574
- SKIP_ARCHIVED_LOGS=False #optional
75+
- DEBUG=False #optional
7676
- BASIC_AUTH=False #optional
7777
- BASIC_AUTH_USERNAME=user #optional
7878
- BASIC_AUTH_PASSWORD=pass #optional
@@ -81,6 +81,7 @@ goaccess:
8181
| Parameter | Function |
8282
|-----------|----------|
8383
| `-e SKIP_ARCHIVED_LOGS=True/False` | (Optional) Defaults to False. Set to True to skip archived logs, i.e. proxy-host*.gz |
84+
| `-e DEBUG=True/False` | (Optional) HTML version of the running goaccess.conf wihtin the container |
8485
| `-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. |
8586
| `-e BASIC_AUTH_USERNAME=user` | (Optional) Requires BASIC_AUTH to bet set to True. Username for basic authentication. |
8687
| `-e BASIC_AUTH_PASSWORD=pass` | (Optional) Requires BASIC_AUTH to bet set to True. Password for basic authentication. |
-400 KB
Binary file not shown.

resources/goaccess/goaccess.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ real-time-html true
339339
# Specify the path to the input log file. If set, it will take
340340
# priority over -f from the command line.
341341
#
342-
#log-file /opt/log/proxy.log
342+
#GOAN_PROXY_FILES
343343

344344
# Send all debug messages to the specified file.
345345
#
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>GoAccess for Nginx Proxy Manager Logs - (#goan_version)</title>
5+
<style>
6+
body {
7+
font-family: Arial, sans-serif;
8+
}
9+
code {
10+
white-space: pre-wrap;
11+
}
12+
</style>
13+
</head>
14+
<body>
15+
<code>
16+
#GOAN_INPUT
17+
</code>
18+
</body>
19+
</html>

resources/scripts/funcs/debug.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ADD DEBUGGING
2+
3+
function debug() {
4+
if [[ "${DEBUG}" == "True" ]]
5+
then
6+
echo "DEBUG - ON"
7+
cp /goan/debug/goaccess_conf.html /var/www/html/goaccess_conf.html
8+
9+
src="#goan_version"
10+
rpl=${goan_version}
11+
sed -i "s/$src/$rpl/" /var/www/html/goaccess_conf.html
12+
13+
sed -i -e '/#GOAN_INPUT/r /goaccess-config/goaccess.conf' /var/www/html/goaccess_conf.html
14+
sed -i -e 's/#GOAN_INPUT//' /var/www/html/goaccess_conf.html
15+
else
16+
echo "DEBUG - OFF"
17+
fi
18+
}

resources/scripts/funcs/logs.sh

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,14 @@ function logs_load_active() {
66
if [[ -d "${1}" && -x "${1}" ]];
77
then
88
IFS=$'\n'
9-
for file in $(find "${1}" -name 'proxy-host-*.log' ! -name "*_error.log");
9+
for file in $(find "${1}" -name 'proxy*host-*.log' ! -name "*_error.log");
1010
do
1111
if [ -f $file ]
1212
then
1313
if [ -r $file ] && R="Read = yes" || R="Read = No"
1414
then
15-
if [ -z "$goan_proxy_host" ]
16-
then
17-
goan_proxy_host="${goan_proxy_host}${file}"
15+
echo "log-file ${file}" >> ${goan_container_proxy_logs}
1816
goan_proxy_log_count=$((goan_proxy_log_count+1))
19-
else
20-
goan_proxy_host="${goan_proxy_host} ${file}"
21-
goan_proxy_log_count=$((goan_proxy_log_count+1))
22-
fi
2317
echo -ne ' \t '
2418
echo "Filename: $file | $R"
2519
else
@@ -36,32 +30,33 @@ function logs_load_active() {
3630
echo "Problem loading directory (check directory or permissions)... ${1}"
3731
fi
3832

39-
if [ -z "$goan_proxy_host" ]
33+
if [ $goan_proxy_log_count != 0 ]
4034
then
41-
touch ${goan_container_active_log}
42-
goan_proxy_host=${goan_container_active_log}
43-
else
4435
echo "Found (${goan_proxy_log_count}) proxy logs...."
36+
else
37+
touch ${goan_container_active_log}
38+
echo "log-file ${goan_container_active_log}" >> ${goan_container_proxy_logs}
4539
fi
4640
}
4741

4842
#Find active logs and check for read access
4943
function logs_load_archive() {
44+
touch ${goan_container_archive_log}
45+
5046
if [[ "${SKIP_ARCHIVED_LOGS}" == "True" ]]
5147
then
5248
echo "Skipping archived logs as requested..."
53-
touch ${goan_container_archive_log}
5449
else
5550
if [[ -d "${1}" && -x "${1}" ]];
5651
then
57-
count=`ls -1 ${1}/proxy-host-*_access.log*.gz 2>/dev/null | wc -l`
52+
count=`ls -1 ${1}/proxy-host-*_access.log*.gz | wc -l`
5853
if [ $count != 0 ]
5954
then
6055
echo "Loading (${count}) archived logs from ${1}..."
6156
zcat -f ${1}/proxy-host-*_access.log*.gz > ${goan_container_archive_log}
57+
echo "log-file ${goan_container_archive_log}" >> ${goan_container_proxy_logs}
6258
else
6359
echo "No archived logs found at ${1}..."
64-
touch ${goan_container_archive_log}
6560
fi
6661
goan_proxy_archive_log_count=$((count))
6762
else

resources/scripts/funcs/nginx.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ function nginx_processing_count() {
2929
src="#goan_processing_count"
3030
rpl=$((goan_proxy_log_count+goan_proxy_archive_log_count))
3131
sed -i "s/$src/$rpl/" /var/www/html/index.html
32-
}
32+
}

resources/scripts/start.sh

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
11
#!/bin/bash
22
source $(dirname "$0")/funcs/nginx.sh
33
source $(dirname "$0")/funcs/logs.sh
4+
source $(dirname "$0")/funcs/debug.sh
45

5-
goan_version="GOAN v1.0.4"
6+
goan_version="GOAN v1.0.6"
67
goan_log_path="/opt/log"
78
goan_dir_valid=0 #false
8-
goan_proxy_host=""
9-
goan_container_archive_log="/goaccess/access_archive.log"
10-
goan_container_active_log="/goaccess/access.log"
9+
goan_container_archive_log="/goaccess-config/access_archive.log"
10+
goan_container_active_log="/goaccess-config/access.log"
11+
goan_container_proxy_logs="/goaccess-config/proxy_logs"
1112
goan_proxy_log_count=0
1213
goan_proxy_archive_log_count=0
1314

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

17+
#clean up
18+
if [[ -f "$goan_container_proxy_logs" ]]; then
19+
rm ${goan_container_proxy_logs}
20+
fi
21+
if [[ -f "$goan_container_archive_log" ]]; then
22+
rm ${goan_container_archive_log}
23+
fi
24+
if [[ -f "$goan_container_active_log" ]]; then
25+
rm ${goan_container_active_log}
26+
fi
27+
if [[ -f "/goaccess-config/goaccess.conf" ]]; then
28+
cp /goaccess-config/goaccess.conf.bak /goaccess-config/goaccess.conf
29+
fi
30+
31+
1632
#Set NGINX basic authentication
1733
nginx_basic_auth
1834

@@ -29,6 +45,12 @@ nginx_processing_count
2945
#RUN NGINX
3046
tini -s -- nginx
3147

48+
#APPEND LOG FILE NAMES TO GOACCESS CONFIG
49+
sed -i -e '/#GOAN_PROXY_FILES/r /goaccess-config/proxy_logs' /goaccess-config/goaccess.conf
50+
51+
#DEBUG
52+
debug
53+
3254
#RUN GOACCESS
3355
echo -e "\nProcessing ($((goan_proxy_log_count+goan_proxy_archive_log_count))) total log(s)...\n"
34-
tini -s -- /goaccess/goaccess ${goan_container_archive_log} ${goan_proxy_host} --no-global-config --config-file=/goaccess-config/goaccess.conf
56+
tini -s -- /goaccess/goaccess --no-global-config --config-file=/goaccess-config/goaccess.conf

0 commit comments

Comments
 (0)