From 7f4f9261a08017481dfcae6044c72f764677897d Mon Sep 17 00:00:00 2001 From: quietsy Date: Fri, 14 Jan 2022 16:13:32 +0200 Subject: [PATCH 1/3] Allow the subdomain conf to show non php files --- root/dashboard/dashboard.subdomain.conf.sample | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/root/dashboard/dashboard.subdomain.conf.sample b/root/dashboard/dashboard.subdomain.conf.sample index 3f3e57b..ad7730c 100644 --- a/root/dashboard/dashboard.subdomain.conf.sample +++ b/root/dashboard/dashboard.subdomain.conf.sample @@ -1,4 +1,4 @@ -## Version 2022/01/12 +## Version 2022/01/14 # Make sure that your dns has a cname set for dashboard server { @@ -37,6 +37,14 @@ server { allow 192.168.0.0/16; deny all; + try_files $uri $uri/ /index.php?$args =404; + } + location ~ \.php$ { + allow 10.0.0.0/8; + allow 172.16.0.0/12; + allow 192.168.0.0/16; + deny all; + fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; From 98e966b8e97b89fc06d928c7934580ed914b49fd Mon Sep 17 00:00:00 2001 From: quietsy Date: Fri, 14 Jan 2022 20:15:14 +0200 Subject: [PATCH 2/3] Build goaccess from source --- Dockerfile | 27 ++++++++++++++++++++++++ root/dashboard/www/index.php | 2 +- root/etc/cont-init.d/98-dashboard-config | 9 ++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index ae5c3e5..a0bf705 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,33 @@ +FROM ghcr.io/linuxserver/baseimage-alpine:3.15 as build-stage + +RUN \ + echo "**** install packages ****" && \ + apk add -U --update --no-cache --virtual=build-dependencies \ + autoconf \ + automake \ + build-base \ + git \ + glib-dev \ + libmaxminddb-dev \ + ncurses-dev && \ + mkdir -p /build && \ + mkdir -p /goaccess && \ + echo "**** build goaccess ****" && \ + git clone --shallow-submodules --recurse-submodules https://github.com/allinurl/goaccess.git /goaccess && cd /goaccess && \ + autoreconf -fiv && \ + ./configure --enable-utf8 --enable-geoip=mmdb && \ + make DESTDIR="/build" install && \ + echo "**** cleanup ****" && \ + apk del --purge \ + build-dependencies && \ + rm -rf \ + /goaccess/* \ + /tmp/* + FROM scratch LABEL maintainer="quietsy" # copy local files COPY root/ / +COPY --from=build-stage /build/ / diff --git a/root/dashboard/www/index.php b/root/dashboard/www/index.php index 19d2cb1..777ffda 100644 --- a/root/dashboard/www/index.php +++ b/root/dashboard/www/index.php @@ -174,7 +174,7 @@ } $geodb = file_exists('/config/geoip2db/GeoLite2-City.mmdb') ? '--geoip-database=/config/geoip2db/GeoLite2-City.mmdb' : ''; - $goaccess = shell_exec("goaccess -a -o html --config-file=/dashboard/goaccess.conf ".$geodb); + $goaccess = shell_exec("/usr/local/bin/goaccess -a -o html --config-file=/dashboard/goaccess.conf ".$geodb); $status = GetHeader() . GetProxies() . GetF2B() . GetAnnouncements() . GetLinks() . '
'; $page = str_replace("
", $status, $goaccess); $page = str_replace("Server Statistics", "<title>SWAG Dashboard", $page); diff --git a/root/etc/cont-init.d/98-dashboard-config b/root/etc/cont-init.d/98-dashboard-config index 8e54401..30aeafb 100644 --- a/root/etc/cont-init.d/98-dashboard-config +++ b/root/etc/cont-init.d/98-dashboard-config @@ -2,12 +2,17 @@ echo "Applying the SWAG dashboard mod..." -apk add --no-cache --upgrade goaccess - +apk add libmaxminddb +cp -f /dashboard/dashboard.subdomain.conf.sample /config/nginx/proxy-confs/dashboard.subdomain.conf.sample if [ ! -f /config/nginx/proxy-confs/dashboard.subdomain.conf ]; then cp /dashboard/dashboard.subdomain.conf.sample /config/nginx/proxy-confs/dashboard.subdomain.conf fi +if [ "$(sed -nE 's|## Version ([0-9]{4}\/[0-9]{2}\/[0-9]{2}).*|\1|p' /dashboard/dashboard.subdomain.conf.sample)" != "$(sed -nE 's|## Version ([0-9]{4}\/[0-9]{2}\/[0-9]{2}).*|\1|p' /config/nginx/proxy-confs/dashboard.subdomain.conf)" ]; then + echo "**** The swag-dashboard conf has been updated ****" + echo "**** Compare the changes using the sample file: /config/nginx/proxy-confs/dashboard.subdomain.conf.sample" +fi + # permissions chown -R abc:abc \ /dashboard \ From 43249bd443c875a25d6929fbb827b2d54ca957dc Mon Sep 17 00:00:00 2001 From: aptalca <aptalca@users.noreply.github.com> Date: Fri, 14 Jan 2022 14:55:42 -0500 Subject: [PATCH 3/3] compile goaccess with qemu --- .github/workflows/BuildImage.yml | 4 ++ Dockerfile | 64 ++++++++++++++++++++++-- root/etc/cont-init.d/98-dashboard-config | 11 +++- 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/.github/workflows/BuildImage.yml b/.github/workflows/BuildImage.yml index 21c8db5..7b4271e 100644 --- a/.github/workflows/BuildImage.yml +++ b/.github/workflows/BuildImage.yml @@ -13,6 +13,10 @@ jobs: steps: - uses: actions/checkout@v2.3.3 + - name: Set up qemu + run: | + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + - name: Build image run: | docker build --no-cache -t ${{ github.sha }} . diff --git a/Dockerfile b/Dockerfile index a0bf705..69f0e31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine:3.15 as build-stage +FROM ghcr.io/linuxserver/baseimage-alpine:amd64-3.15 as build-stage-amd64 RUN \ echo "**** install packages ****" && \ @@ -24,10 +24,68 @@ RUN \ /goaccess/* \ /tmp/* +FROM ghcr.io/linuxserver/baseimage-alpine:arm32v7-3.15 as build-stage-arm32v7 + +RUN \ + echo "**** install packages ****" && \ + apk add -U --update --no-cache --virtual=build-dependencies \ + autoconf \ + automake \ + build-base \ + git \ + glib-dev \ + libmaxminddb-dev \ + ncurses-dev && \ + mkdir -p /build && \ + mkdir -p /goaccess && \ + echo "**** build goaccess ****" && \ + git clone --shallow-submodules --recurse-submodules https://github.com/allinurl/goaccess.git /goaccess && cd /goaccess && \ + autoreconf -fiv && \ + ./configure --enable-utf8 --enable-geoip=mmdb && \ + make DESTDIR="/build" install && \ + echo "**** cleanup ****" && \ + apk del --purge \ + build-dependencies && \ + rm -rf \ + /goaccess/* \ + /tmp/* + +FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.15 as build-stage-arm64v8 + +RUN \ + echo "**** install packages ****" && \ + apk add -U --update --no-cache --virtual=build-dependencies \ + autoconf \ + automake \ + build-base \ + git \ + glib-dev \ + libmaxminddb-dev \ + ncurses-dev && \ + mkdir -p /build && \ + mkdir -p /goaccess && \ + echo "**** build goaccess ****" && \ + git clone --shallow-submodules --recurse-submodules https://github.com/allinurl/goaccess.git /goaccess && cd /goaccess && \ + autoreconf -fiv && \ + ./configure --enable-utf8 --enable-geoip=mmdb && \ + make DESTDIR="/build" install && \ + echo "**** cleanup ****" && \ + apk del --purge \ + build-dependencies && \ + rm -rf \ + /goaccess/* \ + /tmp/* + +FROM scratch as build-stage-consolidate + +COPY --from=build-stage-amd64 /build/ /goaccess/x86_64/ +COPY --from=build-stage-arm32v7 /build/ /goaccess/armv7l/ +COPY --from=build-stage-arm64v8 /build/ /goaccess/aarch64/ +COPY root/ / + FROM scratch LABEL maintainer="quietsy" # copy local files -COPY root/ / -COPY --from=build-stage /build/ / +COPY --from=build-stage-consolidate / / diff --git a/root/etc/cont-init.d/98-dashboard-config b/root/etc/cont-init.d/98-dashboard-config index 30aeafb..ac11c0e 100644 --- a/root/etc/cont-init.d/98-dashboard-config +++ b/root/etc/cont-init.d/98-dashboard-config @@ -2,7 +2,16 @@ echo "Applying the SWAG dashboard mod..." -apk add libmaxminddb +ARCH=$(uname -m) +if [ -d "/goaccess/${ARCH}" ]; then + echo "**** Installing/updating goaccess ****" + cp -a /goaccess/${ARCH}/* / + rm -rf /goaccess +else + echo "**** Goaccess already installed and up to date ****" +fi + +apk add --no-cache libmaxminddb cp -f /dashboard/dashboard.subdomain.conf.sample /config/nginx/proxy-confs/dashboard.subdomain.conf.sample if [ ! -f /config/nginx/proxy-confs/dashboard.subdomain.conf ]; then cp /dashboard/dashboard.subdomain.conf.sample /config/nginx/proxy-confs/dashboard.subdomain.conf