diff --git a/.dockerignore b/.dockerignore index c72c465..34f8d4c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,3 +7,5 @@ .idea/ test/ .gitea/ +unraid/ +deploy/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 36361b0..a73f779 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ First release. - Daily retention cleanup (90 days by default), `/health` endpoint, Docker image running as non-root with all data under `/data`. - Public images for `linux/amd64` and `linux/arm64` in the Gitea registry. +- Unraid Docker template; when started as root, the container hands `/data` to its app user + and drops privileges. [Unreleased]: https://gitea.anticarnist.de/Tom/Flypaper/compare/v0.1.0...main [0.1.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.1.0 diff --git a/Dockerfile b/Dockerfile index 0c10a53..d1f9cf4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,9 +35,10 @@ ENV ASPNETCORE_HTTP_PORTS= \ COPY --from=build --chown=1654:1654 /data /data COPY --from=build /app . +COPY --chmod=755 docker-entrypoint.sh /usr/local/bin/flypaper-entrypoint USER $APP_UID EXPOSE 8080 8081 VOLUME /data -ENTRYPOINT ["dotnet", "Flypaper.Web.dll"] +ENTRYPOINT ["flypaper-entrypoint"] diff --git a/README.md b/README.md index 3104999..e8864cd 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,40 @@ The files in [`deploy/unraid/`](deploy/unraid) and `.gitea/workflows/deploy.yml` author's personal deployment (Gitea Actions to Unraid). They are an example only and not needed to run Flypaper. +## Unraid + +[`unraid/flypaper.xml`](unraid/flypaper.xml) is a Docker template for Unraid. It sets up both +ports, the appdata folder `/mnt/user/appdata/flypaper` and the optional variables (under +*Show more settings*). + +1. Copy the template to the flash drive, in the Unraid terminal: + + ```bash + wget -O /boot/config/plugins/dockerMan/templates-user/my-Flypaper.xml \ + https://gitea.anticarnist.de/Tom/Flypaper/raw/branch/main/unraid/flypaper.xml + ``` + +2. **Docker → Add Container**, pick *Flypaper* under the user templates, choose free host ports + (8080 is often taken on Unraid) and **Apply**. +3. Open the WebUI (the dashboard port) and set the admin password. + +Unraid can also read templates from a *template repository* (Docker tab, Advanced View), but +that feature is built around GitHub repositories and may not accept this Gitea URL; the manual +copy above always works. + +The template starts the container as root (`--user 0:0`) only so it can hand the appdata folder +to its app user; Flypaper then drops to UID 1654 for good. Without it, a freshly created appdata +folder belongs to root and the database cannot be created. + +**Connecting Nginx Proxy Manager:** follow the [NPM section](#nginx-proxy-manager) below. If NPM +runs in a user-defined Docker network (e.g. `proxynet`), put Flypaper into the same network +(*Network Type* in the template) and use `http://Flypaper:8080` as the target. If NPM can't +share a network with it, forward to `http://:` instead. Either way the +request comes from a private address, which Flypaper trusts by default. + +The template is not part of the official Community Applications yet; that needs a separate +submission. + ## Versions and updates Flypaper follows [Semantic Versioning](https://semver.org); every release is listed in diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..4a88fbf --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# Started as root (e.g. by the Unraid template): hand /data to the app user, which a +# freshly created host folder is not, then drop privileges for good. +if [ "$(id -u)" = "0" ]; then + chown -R "$APP_UID:$APP_UID" /data + exec setpriv --reuid="$APP_UID" --regid="$APP_UID" --clear-groups dotnet /app/Flypaper.Web.dll "$@" +fi + +exec dotnet /app/Flypaper.Web.dll "$@" diff --git a/unraid/flypaper.png b/unraid/flypaper.png new file mode 100644 index 0000000..26f999a Binary files /dev/null and b/unraid/flypaper.png differ diff --git a/unraid/flypaper.svg b/unraid/flypaper.svg new file mode 100644 index 0000000..b5b394c --- /dev/null +++ b/unraid/flypaper.svg @@ -0,0 +1,19 @@ + + Flypaper + + + + + + + + + + + + + + + + + diff --git a/unraid/flypaper.xml b/unraid/flypaper.xml new file mode 100644 index 0000000..1446c99 --- /dev/null +++ b/unraid/flypaper.xml @@ -0,0 +1,32 @@ + + + Flypaper + gitea.anticarnist.de/tom/flypaper:latest + https://gitea.anticarnist.de/Tom/-/packages/container/flypaper + bridge + + bash + false + https://gitea.anticarnist.de/Tom/Flypaper/issues + https://gitea.anticarnist.de/Tom/Flypaper + Self-hosted tarpit that traps and slows down scanning bots, with event logging and analysis. Instead of blocking bots, Flypaper answers them with an endless HTML page that trickles in a few bytes at a time, and logs every catch with its country and network provider.[br][br] +The trap port receives everything your reverse proxy has no site for (its catch-all / default server) and, optionally, bait paths such as /.env from your real domains. The dashboard has its own port: keep it inside your LAN. On first visit you set the admin password.[br][br] +The container starts as root only to hand the appdata folder to its app user (UID 1654), then drops privileges for good. + Security: Network:Proxy + http://[IP]:[PORT:8081]/ + https://gitea.anticarnist.de/Tom/Flypaper/raw/branch/main/unraid/flypaper.xml + https://gitea.anticarnist.de/Tom/Flypaper/raw/branch/main/unraid/flypaper.png + --user 0:0 + + + + + + + 8080 + 8081 + /mnt/user/appdata/flypaper + + + +