Skip to content

Commit 04fc5b5

Browse files
Merge branch 'develop' into main
2 parents 073e29b + 14dfe10 commit 04fc5b5

File tree

9 files changed

+110
-85
lines changed

9 files changed

+110
-85
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/.DS_Store

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ COPY /resources/scripts/start.sh start.sh
4545

4646
VOLUME ["/opt/log"]
4747
EXPOSE 7880
48-
CMD ["sh", "/goan/start.sh"]
48+
CMD ["bash", "/goan/start.sh"]

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The docker image scans and includes files matching the following criteria:
1818

1919
**Dependencies:**
2020
- GoAccess version: 1.5.5
21-
- GeoLite2-City.mmdb (2022-04-26)
21+
- GeoLite2-City.mmdb (2022-05-27)
2222

2323
---
2424

@@ -51,7 +51,8 @@ goaccess:
5151
- DEBUG=False #optional
5252
- BASIC_AUTH=False #optional
5353
- BASIC_AUTH_USERNAME=user #optional
54-
- BASIC_AUTH_PASSWORD=pass #optional
54+
- BASIC_AUTH_PASSWORD=pass #optional
55+
- EXCLUDE_IPS=127.0.0.1 #comma delimited list
5556
ports:
5657
- '7880:7880'
5758
volumes:
@@ -75,7 +76,8 @@ goaccess:
7576
- DEBUG=False #optional
7677
- BASIC_AUTH=False #optional
7778
- BASIC_AUTH_USERNAME=user #optional
78-
- BASIC_AUTH_PASSWORD=pass #optional
79+
- BASIC_AUTH_PASSWORD=pass #optional
80+
- EXCLUDE_IPS=127.0.0.1 #comma delimited
7981
```
8082
8183
| Parameter | Function |
@@ -85,6 +87,7 @@ goaccess:
8587
| `-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. |
8688
| `-e BASIC_AUTH_USERNAME=user` | (Optional) Requires BASIC_AUTH to bet set to True. Username for basic authentication. |
8789
| `-e BASIC_AUTH_PASSWORD=pass` | (Optional) Requires BASIC_AUTH to bet set to True. Password for basic authentication. |
90+
| `-e EXCLUDE_IPS=` | (Optional) IP Addresses or range of IPs delimited by comma refer to https://goaccess.io/man. For example: 192.168.0.1-192.168.0.100 or 127.0.0.1,192.168.0.1-192.168.0.100 |
8891

8992
Thanks to https://github.com/GregYankovoy for the inspiration, and for their nginx.conf :)
9093

2.47 MB
Binary file not shown.

resources/scripts/funcs/debug.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
#Exclude IPs
4+
function exclude_ips() {
5+
if [[ -z "${EXCLUDE_IPS}" ]]
6+
then
7+
//no excluded ips
8+
else
9+
echo -e "\nExcluding IPs..."
10+
ips=""
11+
12+
echo $'\n' >> /goaccess-config/goaccess.conf
13+
echo "#GOAN_EXCLUDE_IPS" >> /goaccess-config/goaccess.conf
14+
IFS=','
15+
read -ra ADDR <<< "$EXCLUDE_IPS"
16+
for ip in "${ADDR[@]}"; do
17+
echo ${ip}
18+
echo "exclude-ip ${ip}" >> /goaccess-config/goaccess.conf
19+
done
20+
unset IFS
21+
fi
22+
}
23+
24+
#Set NGINX basic authentication
25+
function nginx_basic_auth() {
26+
if [[ "${BASIC_AUTH}" == "True" ]]
27+
then
28+
echo "Setting up basic auth in NGINX..."
29+
if [[ -z "$BASIC_AUTH_USERNAME" || -z "$BASIC_AUTH_PASSWORD" ]]
30+
then
31+
echo "Username or password is blank or not set."
32+
else
33+
nginx_auth_basic_s="#goan_authbasic"
34+
nginx_auth_basic_r="auth_basic \"GoAccess WebUI\";\n auth_basic_user_file \/opt\/auth\/.htpasswd; \n"
35+
sed -i "s/$nginx_auth_basic_s/$nginx_auth_basic_r/" /etc/nginx/nginx.conf
36+
37+
htpasswd -b /opt/auth/.htpasswd $BASIC_AUTH_USERNAME $BASIC_AUTH_PASSWORD
38+
fi
39+
fi
40+
}
41+
42+
#ADD DEBUGGING
43+
function debug() {
44+
if [[ "${DEBUG}" == "True" ]]
45+
then
46+
echo -e "\nDEBUG - ON"
47+
cp /goan/debug/goaccess_conf.html /var/www/html/goaccess_conf.html
48+
49+
src="#goan_version"
50+
rpl=${goan_version}
51+
sed -i "s/$src/$rpl/" /var/www/html/goaccess_conf.html
52+
53+
sed -i -e '/#GOAN_INPUT/r /goaccess-config/goaccess.conf' /var/www/html/goaccess_conf.html
54+
sed -i -e 's/#GOAN_INPUT//' /var/www/html/goaccess_conf.html
55+
else
56+
echo "DEBUG - OFF"
57+
fi
58+
}
59+
60+
#Find active logs and check for read access
61+
function logs_load_archive() {
62+
touch ${goan_container_archive_log}
63+
64+
if [[ "${SKIP_ARCHIVED_LOGS}" == "True" ]]
65+
then
66+
echo "Skipping archived logs as requested..."
67+
else
68+
if [[ -d "${1}" && -x "${1}" ]];
69+
then
70+
count=`ls -1 ${1}/proxy-host-*_access.log*.gz | wc -l`
71+
if [ $count != 0 ]
72+
then
73+
echo "Loading (${count}) archived logs from ${1}..."
74+
zcat -f ${1}/proxy-host-*_access.log*.gz > ${goan_container_archive_log}
75+
echo "log-file ${goan_container_archive_log}" >> ${goan_container_proxy_logs}
76+
else
77+
echo "No archived logs found at ${1}..."
78+
fi
79+
goan_proxy_archive_log_count=$((count))
80+
else
81+
echo "Problem loading directory (check directory or permissions)... ${1}"
82+
fi
83+
fi
84+
}
Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
#!/bin/bash
22

3-
#Find active logs and check for read access
3+
function nginx_image_version() {
4+
src="#goan_version"
5+
rpl=${goan_version}
6+
sed -i "s/$src/$rpl/" /var/www/html/index.html
7+
}
8+
9+
function nginx_processing_count() {
10+
src="#goan_processing_count"
11+
rpl=$((goan_proxy_log_count+goan_proxy_archive_log_count))
12+
sed -i "s/$src/$rpl/" /var/www/html/index.html
13+
}
14+
415
function logs_load_active() {
516
echo "Checking active logs..."
617
if [[ -d "${1}" && -x "${1}" ]];
@@ -37,30 +48,4 @@ function logs_load_active() {
3748
touch ${goan_container_active_log}
3849
echo "log-file ${goan_container_active_log}" >> ${goan_container_proxy_logs}
3950
fi
40-
}
41-
42-
#Find active logs and check for read access
43-
function logs_load_archive() {
44-
touch ${goan_container_archive_log}
45-
46-
if [[ "${SKIP_ARCHIVED_LOGS}" == "True" ]]
47-
then
48-
echo "Skipping archived logs as requested..."
49-
else
50-
if [[ -d "${1}" && -x "${1}" ]];
51-
then
52-
count=`ls -1 ${1}/proxy-host-*_access.log*.gz | wc -l`
53-
if [ $count != 0 ]
54-
then
55-
echo "Loading (${count}) archived logs from ${1}..."
56-
zcat -f ${1}/proxy-host-*_access.log*.gz > ${goan_container_archive_log}
57-
echo "log-file ${goan_container_archive_log}" >> ${goan_container_proxy_logs}
58-
else
59-
echo "No archived logs found at ${1}..."
60-
fi
61-
goan_proxy_archive_log_count=$((count))
62-
else
63-
echo "Problem loading directory (check directory or permissions)... ${1}"
64-
fi
65-
fi
6651
}

resources/scripts/funcs/nginx.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

resources/scripts/start.sh

100644100755
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22
source $(dirname "$0")/funcs/nginx.sh
3-
source $(dirname "$0")/funcs/logs.sh
4-
source $(dirname "$0")/funcs/debug.sh
3+
source $(dirname "$0")/funcs/internal.sh
4+
source $(dirname "$0")/funcs/environment.sh
55

6-
goan_version="GOAN v1.0.7"
6+
goan_version="GOAN v1.0.8"
77
goan_log_path="/opt/log"
88
goan_dir_valid=0 #false
99
goan_container_archive_log="/goaccess-config/access_archive.log"
@@ -28,7 +28,6 @@ if [[ -f "/goaccess-config/goaccess.conf" ]]; then
2828
cp /goaccess-config/goaccess.conf.bak /goaccess-config/goaccess.conf
2929
fi
3030

31-
3231
#Set NGINX basic authentication
3332
nginx_basic_auth
3433

@@ -38,6 +37,9 @@ logs_load_archive ${goan_log_path}
3837
#Find active logs and check for read access
3938
logs_load_active ${goan_log_path}
4039

40+
#Exclude IPs
41+
exclude_ips
42+
4143
#Mods to index.html
4244
nginx_image_version
4345
nginx_processing_count

0 commit comments

Comments
 (0)