Skip to content

Commit bd70f29

Browse files
Merge branch 'develop' into main
2 parents d7df4bf + e2aecf3 commit bd70f29

File tree

14 files changed

+301
-43
lines changed

14 files changed

+301
-43
lines changed

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.17 AS builder
1+
FROM alpine:3.18 AS builder
22

33
RUN apk add --no-cache \
44
build-base \
@@ -23,13 +23,13 @@ RUN make install
2323
WORKDIR /goaccess
2424
RUN cp /goaccess-temp/goaccess.tar.gz .
2525
RUN tar --strip-components=1 -xzvf goaccess.tar.gz
26-
RUN sed -i "s/GWSocket<\/a>/GWSocket<\/a> ( <a href='https:\/\/tiny.one\/xgoan'>GOAN<\/a> <span>v1.1.15<\/span> )/" /goaccess/resources/tpls.html
26+
RUN sed -i "s/GWSocket<\/a>/GWSocket<\/a> ( <a href='https:\/\/tiny.one\/xgoan'>GOAN<\/a> <span>v1.1.22<\/span> )/" /goaccess/resources/tpls.html
2727
RUN sed -i "s/bottom: 190px/bottom: 260px/" /goaccess/resources/css/app.css
2828
RUN ./configure --enable-utf8 --enable-geoip=mmdb --with-getline
2929
RUN make
3030
RUN make install
3131

32-
FROM alpine:3.17
32+
FROM alpine:3.18
3333
RUN apk add --no-cache \
3434
bash \
3535
nginx \
@@ -67,6 +67,9 @@ ADD /resources/scripts/logs logs
6767
COPY /resources/scripts/start.sh start.sh
6868
RUN chmod +x start.sh
6969

70+
# store archives
71+
RUN mkdir -p /goaccess-logs/archives
72+
7073
VOLUME ["/opt/log"]
7174
VOLUME ["/opt/custom"]
7275
EXPOSE 7880

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Xavier
3+
Copyright (c) 2023 Xavier
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Still in development... You might need to wait a bit if you have a large amount
1515

1616
**Dependencies:**
1717
- GoAccess version: 1.7.2
18-
- GeoLite2-City.mmdb (2023-04-30)
19-
- GeoLite2-Country.mmdb (2023-04-30)
20-
- GeoLite2-ASN.mmdb (2023-04-30)
18+
- GeoLite2-City.mmdb (2023-10-08)
19+
- GeoLite2-Country.mmdb (2023-10-08)
20+
- GeoLite2-ASN.mmdb (2023-10-08)
2121

2222
---
2323

@@ -57,6 +57,8 @@ services:
5757
- BASIC_AUTH_PASSWORD=pass #optional
5858
- EXCLUDE_IPS=127.0.0.1 #optional - comma delimited
5959
- LOG_TYPE=NPM #optional - more information below
60+
- ENABLE_BROWSERS_LIST=True #optional - more information below
61+
- CUSTOM_BROWSERS=Kuma:Uptime,TestBrowser:Crawler #optional - comma delimited, more information below
6062
volumes:
6163
- /path/to/host/nginx/logs:/opt/log
6264
- /path/to/host/custom:/opt/custom #optional, required if using log_type = CUSTOM
@@ -82,6 +84,8 @@ services:
8284
- BASIC_AUTH_PASSWORD=pass #optional
8385
- EXCLUDE_IPS=127.0.0.1 #optional - comma delimited
8486
- LOG_TYPE=NPM #optional - more information below
87+
- ENABLE_BROWSERS_LIST=True #optional - more information below
88+
- CUSTOM_BROWSERS=Kuma:Uptime,TestBrowser:Crawler #optional - comma delimited, more information below
8589
volumes:
8690
- /path/to/host/nginx/logs:/opt/log
8791
- /path/to/host/custom:/opt/custom #optional, required if using log_type = CUSTOM
@@ -90,15 +94,17 @@ services:
9094
| Parameter | Function |
9195
|-----------|----------|
9296
| `-e SKIP_ARCHIVED_LOGS=True/False` | (Optional) Defaults to False. Set to True to skip archived logs, i.e. proxy-host*.gz |
93-
| `-e DEBUG=True/False` | (Optional) HTML version of the running goaccess.conf within the container |
97+
| `-e DEBUG=True/False` | (Optional) Displays more information in the docker logs. This mode also checks logs for parsing errors. |
9498
| `-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. |
9599
| `-e BASIC_AUTH_USERNAME=user` | (Optional) Requires BASIC_AUTH to bet set to True. Username for basic authentication. |
96100
| `-e BASIC_AUTH_PASSWORD=pass` | (Optional) Requires BASIC_AUTH to bet set to True. Password for basic authentication. |
97101
| `-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 |
98102
| `-e INCLUDE_PROXY_HOSTS=` | (Optional) Only consume the list of provided proxy hosts. This is a comma separated list containing the proxy host number for example "11,21". This would consume proxy-host-11_access.log* and proxy-host-21_access.log* . The host number can be found right clicking on the 3 dots on the proxy host line in the GUI. |
99103
| `-e LOG_TYPE=` | (Optional) By default the configuration will be set to read NPM logs. Options are: CUSTOM, NPM, NPM+R, TRAEFIK, NCSA_COMBINED. More information below.|
100-
| `-e LOG_TYPE_FILE_PATTERN=` | (Optional) Only to be used with LOG_TYPE=NCSA_COMBINED. This parameter will pass along the file type you are trying match. For example you can pass -e LOG_TYPE_FILE_PATTERN="*.log" or -e LOG_TYPE_FILE_PATTERN="access.log". The default is *.log. Please keep it simple as I have not tested this completely. Use at your own RISK! |
104+
| `-e LOG_TYPE_FILE_PATTERN=` | (Optional) Only to be used with LOG_TYPE=NCSA_COMBINED or TRAEFIK. This parameter will pass along the file type you are trying match. For example you can pass -e LOG_TYPE_FILE_PATTERN="*.log" or -e LOG_TYPE_FILE_PATTERN="access.log". The default is *.log. Please keep it simple as I have not tested this completely. Use at your own RISK! |
101105
| `-e LANG=zh_CN.UTF-8 -e LANGUAGE=zh_CN.UTF-8` | (Optional) Language localization added. GoAccess only has a few translations available. Please visit https://github.com/allinurl/goaccess/tree/master/po to see the translations available. <br/><br/>**Current Translations**<br/>de - German<br/>es - Spanish<br/>fr - French<br/>it - Italian<br/>ja - Japanese<br/>ko - Korean<br/>pt_BR - Portuguese (Brazil)<br/>ru - Russian<br/>sv - Swedish<br/>uk - English (United Kingdom)<br/>zh_CN - Chinese - Simplified|
106+
| `-e ENABLE_BROWSERS_LIST=True/False` | (Optional) Defaults to False. Set to true if you would like to enable the [goaccess browsers.list](https://github.com/allinurl/goaccess/blob/master/config/browsers.list) file. |
107+
| `-e CUSTOM_BROWSERS=` | - (Optional) Consumes the list of provided custom browsers. This is a comma separated list containing the custom browser(s) in the format `Browser:Browser_category`.<br/>- If your custom browser is already defined in the default `browsers.list` file, it will not be added. However, the `Browser_category` can be reused.<br/><br/> CUSTOM_BROWSERS list example: `Kuma:Crawlers,TestBrowser:Crawlers,Kuma:Uptime,Discordbot:Crawlers`<br/><br/>For the example above, only `Kuma:Crawlers` and `TestBrowser:Crawlers` will be appended to the `browsers.list` file. <br/><br/>`Kuma:Uptime` is ignored as the browser `Kuma` has already been defined in `Kuma:Crawlers`. `Discordbot:Crawlers` is ignored as the browser `Discordbot` is already defined in the [default browsers.list file](https://github.com/allinurl/goaccess/blob/master/config/browsers.list)<br/><br/>Note for users using CUSTOM LOG_TYPE:<br/><br/>If your `goaccess.conf` file references a browsers.list file other than the one located in the `/goaccess-config/ directory`, the CUSTOM_BROWSERS variable will be ignored. |
102108

103109

104110
# **Additional environment information**
@@ -147,6 +153,19 @@ services:
147153
- SKIP_ARCHIVED_LOGS
148154
- the following file(s) are read and parsed.
149155
- access.log
156+
- You can also set the following environment variables yourself to override the defaults
157+
- TIME_FORMAT
158+
- DATE_FORMAT
159+
- LOG_FORMAT
160+
161+
```
162+
FOR EXAMPLE
163+
---------------------------------
164+
TIME_FORMAT=%H:%M:%S
165+
DATE_FORMAT=%Y-%m-%d
166+
LOG_FORMAT='{"ClientHost": "%h", "ClientUsername": "%e", "DownstreamContentSize": "%b", "Duration": "%n", "DownstreamStatus": "%s", "RequestAddr": "%v", "RequestMethod": "%m", "RequestPath": "%U", "RequestProtocol": "%H", "StartUTC": "%dT%t.%^", "request_User-Agent": "%u"}'
167+
``````
168+
150169
- NCSA_COMBINED
151170
- environment parameters that will not work and will be ignored
152171
- SKIP_ARCHIVED_LOGS
@@ -183,6 +202,7 @@ date-format %d/%b/%Y
183202
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %Lm"
184203
```
185204
205+
186206
# **Possible/Known Issues**
187207
- A lot of CPU Usage and 10000 request every second in webUI
188208
- https://github.com/xavier-hernandez/goaccess-for-nginxproxymanager/issues/38

assests/maxmind/GeoLite2-ASN.mmdb

103 KB
Binary file not shown.

assests/maxmind/GeoLite2-City.mmdb

-2.81 MB
Binary file not shown.
18.1 KB
Binary file not shown.

resources/scripts/funcs/internal.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ function checkFile(){
44
if [ -z "$1" ]; then
55
return 1
66
else
7-
if [ -e "$file" ] && [ -r "$file" ]; then
8-
echo -e "\tFile $file exists and is readable"
7+
if [ -e "$1" ]; then
8+
echo -e "\tFile $1 exists"
99
return 0
10-
elif [ -e "$file_path" ]; then
11-
echo -e "\tFile $file exists but is not readable"
12-
return 1
1310
else
14-
echo -e "\tFile $file does not exist"
11+
echo -e "\tFile $1 does not exist"
1512
return 1
1613
fi
1714
fi

resources/scripts/logs/custom.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ function custom_init(){
2929
fi
3030
if [[ -r ${goan_config} ]]; then
3131
echo -e "goaccess.conf readable"
32+
if [[ "${ENABLE_BROWSERS_LIST}" == "True" || ${ENABLE_BROWSERS_LIST} == true ]]; then
33+
if grep -Fwq "browsers-file" ${goan_config}; then
34+
echo -e "\n\t\BROWSERS FILE ALREADY DEFINED IN CUSTOM GOACCESS.CONF. IGNORING CUSTOM_BROWSERS VARIABLE"
35+
else
36+
echo -e "\n\tENABLING CUSTOM INSTANCE GOACCESS BROWSERS LIST"
37+
browsers_file="/goaccess-config/browsers.list"
38+
echo "browsers-file ${browsers_file}" >> ${goan_config}
39+
fi
40+
fi
3241
else
3342
echo -e "goaccess.conf not readable"
3443
#exit
@@ -61,4 +70,4 @@ function custom(){
6170
/goaccess/goaccess --no-global-config --config-file=${goan_config} &
6271
fi
6372

64-
}
73+
}

resources/scripts/logs/ncsa_combined.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function ncsa_combined_init(){
2121
if [[ -f ${html_config} ]]; then
2222
rm ${html_config}
2323
fi
24-
24+
2525
echo -n "" > ${archive_log}
2626
echo -n "" > ${active_log}
2727
}
@@ -36,9 +36,14 @@ function ncsa_combined_goaccess_config(){
3636
echo "date-format %d/%b/%Y" >> ${goan_config}
3737
#echo "log-format [%d:%t %^] %^ %s %^ %^ %m %^ %v \"%U\" [%^ %h] [%^ %b] %^\"%u\" \"%R\"" >> ${goan_config}
3838
echo "log-format %h %^[%d:%t %^] \"%r\" %s %b \"%R\" \"%u\"" >> ${goan_config}
39-
echo "port 7890" >> ${goan_config}
39+
echo "port 7890" >> ${goan_config}
4040
echo "real-time-html true" >> ${goan_config}
4141
echo "output ${nginx_html}" >> ${goan_config}
42+
if [[ "${ENABLE_BROWSERS_LIST}" == "True" || ${ENABLE_BROWSERS_LIST} == true ]]; then
43+
echo -e "\n\tENABLING NCSA_COMBINED INSTANCE GOACCESS BROWSERS LIST"
44+
browsers_file="/goaccess-config/browsers.list"
45+
echo "browsers-file ${browsers_file}" >> ${goan_config}
46+
fi
4247
}
4348

4449
function ncsa_combined(){
@@ -58,7 +63,7 @@ function ncsa_combined(){
5863

5964
echo -e "\n#GOAN_NCSA_COMBINED_LOG_FILES" >> ${goan_config}
6065
if [[ -d "${goan_log_path}" ]]; then
61-
66+
6267
echo -e "\n\tAdding proxy logs..."
6368
IFS=$'\n'
6469

@@ -106,7 +111,7 @@ function ncsa_combined(){
106111
echo -e "\nSKIP ARCHIVED LOGS"
107112
echo "-------------------------------"
108113
echo "FEATURE NOT AVAILABLE FOR NCSA_COMBINED"
109-
114+
110115
#write out loading page
111116
echo "<!doctype html><html><head>" > ${nginx_html}
112117
echo "<title>GOAN - ${goan_version}</title>" >> ${nginx_html}

resources/scripts/logs/npm.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ function npm_goaccess_config(){
3838
echo "port 7890" >> ${goan_config}
3939
echo "real-time-html true" >> ${goan_config}
4040
echo "output ${nginx_html}" >> ${goan_config}
41+
if [[ "${ENABLE_BROWSERS_LIST}" == "True" || ${ENABLE_BROWSERS_LIST} == true ]]; then
42+
echo -e "\n\tENABLING NPM INSTANCE GOACCESS BROWSERS LIST"
43+
browsers_file="/goaccess-config/browsers.list"
44+
echo "browsers-file ${browsers_file}" >> ${goan_config}
45+
fi
4146
}
4247

4348
function npm(){
@@ -57,7 +62,7 @@ function npm(){
5762

5863
echo -e "\n#GOAN_NPM_PROXY_FILES" >> ${goan_config}
5964
if [[ -d "${goan_log_path}" ]]; then
60-
65+
6166
echo -e "\n\tAdding proxy logs..."
6267
IFS=$'\n'
6368
for file in $(find "${goan_log_path}" -name 'proxy*host-*_access.log' ! -name "*_error.log");
@@ -91,7 +96,7 @@ function npm(){
9196
echo -e "\tFound (${goan_log_count}) proxy logs..."
9297
echo -e "\n\tSKIP ARCHIVED LOGS"
9398
echo -e "\t-------------------------------"
94-
if [[ "${SKIP_ARCHIVED_LOGS}" == "True" ]]
99+
if [[ "${SKIP_ARCHIVED_LOGS}" == "True" || ${SKIP_ARCHIVED_LOGS} == true ]]
95100
then
96101
echo -e "\tTRUE"
97102
else
@@ -100,7 +105,7 @@ function npm(){
100105
goan_archive_detail_log_count=0
101106

102107
if [ $goan_archive_log_count != 0 ]
103-
then
108+
then
104109
echo -e "\n\tAdding proxy archive logs..."
105110

106111
IFS=$'\n'
@@ -125,15 +130,20 @@ function npm(){
125130
if [[ $pressOn == 1 ]]; then
126131
checkFile "$file"
127132
if [ $? -eq 0 ]; then
128-
zcat -f ${file} >> ${archive_log}
133+
cleanFileName="${file//.gz/}"
134+
cleanFileName="${cleanFileName//\/opt\/log/}"
135+
cleanFileName="/goaccess-logs/archives${cleanFileName}"
136+
137+
zcat -f ${file} > ${cleanFileName}
138+
echo "log-file ${cleanFileName}" >> ${goan_config}
129139
((goan_archive_detail_log_count++))
130140
fi
131141
fi
132142
done
133143
unset IFS
134144

135145
echo -e "\n\tAdded (${goan_archive_detail_log_count}) proxy archived logs from ${goan_log_path}..."
136-
146+
137147
else
138148
echo -e "\n\tNo archived logs found at ${goan_log_path}..."
139149
fi
@@ -161,6 +171,6 @@ function npm(){
161171
if [[ "${DEBUG}" == "True" ]]; then
162172
/goaccess-debug/goaccess --debug-file=${goaccess_debug_file} --invalid-requests=${goaccess_invalid_file} --no-global-config --config-file=${goan_config} &
163173
else
164-
/goaccess/goaccess --no-global-config --config-file=${goan_config} &
174+
/goaccess/goaccess --num-tests=0 --no-global-config --config-file=${goan_config} &
165175
fi
166-
}
176+
}

0 commit comments

Comments
 (0)