File tree Expand file tree Collapse file tree 5 files changed +31
-2
lines changed
Expand file tree Collapse file tree 5 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ RUN apk add --no-cache \
2121 tini \
2222 wget \
2323 curl \
24+ apache2-utils\
2425 libmaxminddb \
2526 ncurses && \
2627 rm -rf /var/lib/apt/lists/* && \
@@ -33,6 +34,7 @@ COPY /resources/goaccess/GeoLite2-City.mmdb /goaccess-config/GeoLite2-City.mmdb
3334# set up nginx
3435COPY /resources/nginx/index.html /var/www/html/index.html
3536COPY /resources/nginx/nginx.conf /etc/nginx/nginx.conf
37+ ADD /resources/nginx/.htpasswd /opt/auth/.htpasswd
3638
3739COPY /resources/scripts/start.sh /start.sh
3840VOLUME ["/opt/log" ]
Original file line number Diff line number Diff line change @@ -42,7 +42,10 @@ goaccess:
4242 restart : always
4343 environment :
4444 - TZ=America/New_York
45- - SKIP_ARCHIVED_LOGS=False # optional
45+ - SKIP_ARCHIVED_LOGS=False # optional
46+ - BASIC_AUTH=False # optional
47+ - BASIC_AUTH_USERNAME=user # optional
48+ - BASIC_AUTH_PASSWORD=pass # optional
4649 ports :
4750 - ' 7880:7880'
4851 volumes :
@@ -62,12 +65,18 @@ goaccess:
6265 - PUID=0
6366 - PGID=0
6467 - TZ=America/New_York
65- - SKIP_ARCHIVED_LOGS=False # optional
68+ - SKIP_ARCHIVED_LOGS=False # optional
69+ - BASIC_AUTH=False # optional
70+ - BASIC_AUTH_USERNAME=user # optional
71+ - BASIC_AUTH_PASSWORD=pass # optional
6672` ` `
6773
6874| Parameter | Function |
6975|-----------|----------|
7076| ` -e SKIP_ARCHIVED_LOGS=True/False` | (Optional) Defaults to False. Set to True to skip archived logs, i.e. proxy-host*.gz |
77+ | `-e BASIC_AUTH=True/False` | (Optional) Defaults to False. Set to True to enable nginx basic authentication. |
78+ | `-e BASIC_AUTH_USERNAME=user` | (Optional) Requires BASIC_AUTH to bet set to True. Username for basic authentication. |
79+ | `-e BASIC_AUTH_PASSWORD=pass` | (Optional) Requires BASIC_AUTH to bet set to True. Password for basic authentication. |
7180
7281Thanks to https://github.com/GregYankovoy for the inspiration, and for their nginx.conf :)
7382
Original file line number Diff line number Diff line change 2424 access_log off;
2525
2626 location / {
27+ #goan_authbasic
2728 try_files /nonexistent @$type ;
2829 }
2930
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3+ # BEGIN - Set NGINX basic authentication
4+ if [[ " ${BASIC_AUTH} " == " True" ]]
5+ then
6+ echo " Setting up basic auth in NGINX..."
7+ if [[ -z " $BASIC_AUTH_USERNAME " || -z " $BASIC_AUTH_PASSWORD " ]]
8+ then
9+ echo " Username or password is blank or not set."
10+ else
11+ nginx_auth_basic_s=" #goan_authbasic"
12+ nginx_auth_basic_r=" auth_basic \" GoAccess WebUI\" ;\n auth_basic_user_file \/opt\/auth\/.htpasswd; \n"
13+ sed -i " s/$nginx_auth_basic_s /$nginx_auth_basic_r /" /etc/nginx/nginx.conf
14+
15+ htpasswd -b /opt/auth/.htpasswd $BASIC_AUTH_USERNAME $BASIC_AUTH_PASSWORD
16+ fi
17+ fi
18+ # END - Set NGINX basic authentication
19+
320# BEGIN - Load archived logs
421if [[ " ${SKIP_ARCHIVED_LOGS} " == " True" ]]
522then
You can’t perform that action at this time.
0 commit comments