Trim README and move details to docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Opus 5.5 committed 2026-11-15 12:50:10 +01:00
1 parent 552abffd29
commit 2a639a6b59
7 files changed
+434 -334

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
# Configuration
## Data volume
The container runs as a non-root user (UID 1654) and keeps everything under `/data`: the SQLite
database, the Data Protection keys for logins and the GeoIP databases. A named volume gets
the right owner automatically; for a bind mount, `chown 1654:1654` the host folder first (or
start the container as root once, as the [Unraid template](unraid.md) does).
## Environment variables
All optional. Read at startup; list entries need an index (`__0`, `__1`, ...).
| Variable | Purpose | Default |
|---|---|---|
| `Flypaper__Admin__Password` | Fixes the dashboard password and disables the first-visit setup and the password change | set on first visit |
| `Flypaper__Http__TrustedProxies__0` | IP or CIDR of the reverse proxy allowed to set `X-Real-IP` / `X-Forwarded-For`; replaces the default | private networks |
| `Flypaper__Http__KnownHosts__0` | Hosts that are caught only on trap paths (`*.example.com` allowed), see [reverse proxy](reverse-proxy.md#what-to-send-to-flypaper) | none |
| `Flypaper__Ports__Trap` / `Flypaper__Ports__Dashboard` | Container ports | `8080` / `8081` |
| `ConnectionStrings__Flypaper` | SQLite database | `Data Source=/data/flypaper.db` |
| `Flypaper__DataProtection__KeysPath` | Keys for login cookies and forms | `/data/keys` |
| `Flypaper__GeoIp__Directory` | Folder for the DB-IP databases; empty disables GeoIP | `/data/geoip` |
| `Flypaper__Drip__MinDelay` / `MaxDelay` | Pause between chunks | `00:00:00.05` / `00:00:01` |
| `Flypaper__Drip__MinChunkSize` / `MaxChunkSize` | Bytes per chunk | `1` / `64` |
| `TZ` | Time zone for the dashboard | UTC |
The defaults of the runtime settings below can also be set this way, e.g.
`Flypaper__MaxConnections`. Values saved on the settings page override them.
## Runtime settings
Changed on the dashboard's settings page, stored in the database, effective immediately. The
reset button removes all saved values.
| Setting | Default |
|---|---|
| Trap paths (exact, or prefix with a trailing `*`) | `/.env`, `/.env.*`, `/.git/*`, `/.aws/*`, `/.DS_Store`, `/wp-login.php`, `/wp-admin/*`, `/xmlrpc.php`, `/phpmyadmin/*`, `/vendor/phpunit/*`, `/server-status`, `/actuator/*`, `/cgi-bin/*`, `/boaform/*` |
| Extra known hosts (merged with `KnownHosts`) | none |
| Maximum hold time per catch | `01:00:00` |
| Maximum connections overall | `1000` |
| Maximum connections per IP | `10` |
| Keep catches (days, `0` = forever) | `90` |
| Don't store catches from private networks | on |
## Security and privacy
- **Keep the dashboard internal.** Publish port `8081` only to your LAN or to localhost and
never forward it from your public proxy.
- **Finish the setup before the dashboard is reachable by anyone else.** Until a password is
set, whoever opens the dashboard first can set it. The setup page disappears once a password
exists.
- **Use a strong admin password** (at least 12 characters). Only a salted hash is stored. The
login runs over plain HTTP unless you put the dashboard behind TLS yourself.
- **The limits protect you, not the bots.** Every catch holds a socket in Flypaper and in your
proxy for up to the maximum hold time. Keep `MaxConnections` well below what your proxy can
handle (nginx: `worker_connections`), and keep the per-IP limit low so a single scanner
can't fill all slots.
- **An HTTPS catch-all is rarely worth it**, see [reverse proxy](reverse-proxy.md#what-to-send-to-flypaper).
- **Privacy.** Flypaper stores IP addresses, requested URLs and user agents. Keep retention
short if that matters in your jurisdiction.
+27
View File
@@ -0,0 +1,27 @@
# Development
Requires the .NET 10 SDK.
```bash
dotnet build
dotnet test
dotnet run --project src/Flypaper.Web
```
`dotnet run` starts in the Development environment: the dashboard is at
<http://localhost:5248> (password `dev`), the trap at <http://localhost:5247>, the database is
`src/Flypaper.Web/flypaper.db`, and GeoIP is off unless `Flypaper__GeoIp__Directory` is set.
`docker build -t flypaper .` builds the image.
| Project | Contents |
|---|---|
| `Flypaper.Core` | Protocol-independent core: sessions, governor, strategies, settings |
| `Flypaper.Http` | ASP.NET Core middleware, trap matching, forwarded headers |
| `Flypaper.GeoIp` | DB-IP download and lookups |
| `Flypaper.Storage` | EF Core with SQLite, event writer, retention, dashboard queries |
| `Flypaper.Web` | Host, dashboard and settings (Blazor static SSR) |
| `Flypaper.Tests` | xUnit, NSubstitute, Shouldly |
The files in [`deploy/unraid/`](../deploy/unraid) and `.gitea/workflows/` are the author's
personal deployment (Gitea Actions to Unraid) and release pipeline. They are an example only and
not needed to run Flypaper.
+66
View File
@@ -0,0 +1,66 @@
# How Flypaper works
Every server on the internet gets a steady stream of bots probing for `/.env`, `/.git/config`,
`/wp-login.php` and friends, usually sent to the bare IP address or to host names that don't
exist. Blocklists play whack-a-mole with addresses that change daily. Flypaper takes the
opposite approach: it lets the bot in and then answers very, very slowly. While a scanner waits
for an endless HTML page that trickles in a few bytes at a time, it isn't scanning someone
else, and every catch is logged with its origin for you to look at.
```mermaid
flowchart LR
bot["Scanner bot"] -->|"GET /.env<br/>Host: 203.0.113.7"| proxy["Reverse proxy"]
proxy -->|"known site"| apps["Your apps"]
proxy -->|"unknown host or trap path<br/>+ X-Real-IP"| flypaper["Flypaper"]
flypaper -.->|"endless HTML,<br/>a few bytes at a time"| bot
flypaper --> db[("SQLite:<br/>catches, settings")]
you["You (LAN)"] -->|"dashboard, port 8081"| flypaper
```
1. Your reverse proxy keeps serving your real sites. Everything it has no site for (the
default/catch-all server) goes to Flypaper, optionally also a few bait paths on your real
domains.
2. Flypaper listens on two ports. Port `8080` is the trap: everything that arrives there is
caught. Port `8081` serves the dashboard and never traps; keep it inside your LAN.
3. A caught request gets `200 OK` and an endless, plausible-looking HTML page: random chunks
of 1 to 64 bytes with random pauses of 50 ms to 1 s in between.
4. A connection governor caps the number of catches overall and per IP and ends every catch
after a maximum hold time. If there is no free slot, the request gets a quick `404`.
5. When a catch ends, Flypaper logs one line and stores the event in SQLite, enriched with
country, city and network provider (ASN) from the free DB-IP databases.
## Features
- **Traps** for unknown hosts (catch-all) and for configurable trap paths such as `/.env`,
`/.git/*` or `/wp-login.php`
- **Slow delivery** of endless generated HTML with irregular timing
- **Limits**: maximum connections overall and per IP, maximum hold time per catch
- **Dashboard**: totals, a world map, top countries, providers, IPs and paths, the latest
catches with expandable details; login with an admin password
- **GeoIP**: country, city and ASN per catch from DB-IP Lite, downloaded and refreshed
monthly; existing catches are filled in once the databases are available
- **Settings page**: trap paths, extra known hosts, limits and retention, changed at runtime
without a restart
- **Retention**: old catches are deleted daily (90 days by default); catches from private
networks are not stored by default; buttons to delete private or all catches
- **One log line per catch**, so `docker logs` alone shows whether the trap works
- **Health endpoint** `/health` for container health checks (on the trap port it answers only
to private addresses)
- **No configuration needed to start**: one volume, two ports, the admin password is set on
first visit
## Trying the trap locally
```bash
curl -N http://localhost:8080/
```
This catch comes from a private address and is therefore not stored; the log line ends with
`(not stored)`.
## Attribution
Origins come from [IP Geolocation by DB-IP](https://db-ip.com), licensed under
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); the dashboard shows this attribution
in its footer. The world map is generated from [Natural Earth](https://www.naturalearthdata.com)
data (public domain).
+40
View File
@@ -0,0 +1,40 @@
# Versions, images and updates
Flypaper follows [Semantic Versioning](https://semver.org); every release is listed in
[CHANGELOG.md](../CHANGELOG.md) and on the
[releases page](https://gitea.anticarnist.de/Tom/Flypaper/releases). The running version is
shown in the dashboard footer and in the first log line.
All images live at `gitea.anticarnist.de/tom/flypaper`
([package page](https://gitea.anticarnist.de/Tom/-/packages/container/flypaper/latest)); no
login is needed to pull.
| Image tag | Meaning | Platforms |
|---|---|---|
| `:latest` | The newest release. The right choice for most setups. | amd64, arm64 |
| `:X.Y.Z` | A fixed release, e.g. `:0.1.0`. Pin it if you update deliberately. | amd64, arm64 |
| `:X.Y`, `:X` | The newest release of that minor or major line, e.g. `:0.1`, `:0`. | amd64, arm64 |
| `:main` | Development build of the latest commit on `main`. May break. | amd64 |
| `:<sha>` | Development build of one commit (short SHA), e.g. for a rollback. | amd64 |
arm64 covers e.g. a Raspberry Pi 4/5 with a 64-bit OS.
Pull a fixed version with `docker pull gitea.anticarnist.de/tom/flypaper:0.1.0`. To build a
specific release from source instead:
```bash
git checkout v0.1.0
docker build --build-arg VERSION=0.1.0 -t flypaper:0.1.0 .
```
You can always build the current source yourself: clone the repository and replace the
`image:` line in your compose file with `build: .`, or run `docker build -t flypaper .`.
## Updating
Pull or rebuild the image and recreate the container
(`docker compose pull && docker compose up -d`). The database is migrated automatically on
start; back up the `/data` volume first. Before 1.0, a minor version may contain breaking
changes, so read the changelog.
How releases are cut is described in [`deploy/unraid/README.md`](../deploy/unraid/README.md#releases).
+153
View File
@@ -0,0 +1,153 @@
# Behind a reverse proxy
Flypaper is meant to sit behind the reverse proxy that already owns ports 80/443. The proxy
forwards to the trap port `8080`; the dashboard port `8081` is never forwarded. Two rules
apply to every proxy:
- **Set `X-Real-IP`** (and `X-Forwarded-For`) to the client address.
- **Flypaper must trust the proxy.** By default it trusts every private network (`10/8`,
`172.16/12`, `192.168/16`, loopback, `fc00::/7`), which covers a proxy in a Docker network
or on the LAN. Headers from public addresses are ignored, so bots can't fake their address.
To narrow it down, set `Flypaper__Http__TrustedProxies__0` to the proxy's IP or subnet, e.g.
the Docker network's subnet:
```bash
docker network inspect <network> -f '{{(index .IPAM.Config 0).Subnet}}'
```
Also turn off response buffering for Flypaper, otherwise the proxy collects the drip and the
bot never sees it. Flypaper sends `X-Accel-Buffering: no`, which nginx honors.
## What to send to Flypaper
- **The catch-all server.** Requests for hosts you don't serve (mostly the bare IP) go to
Flypaper. This is where almost all scanners end up.
- **Optionally, trap paths on your real domains.** Forward only the bait paths, e.g. `/.env`
or `/wp-login.php`, from your real sites to Flypaper. Every request on the trap port is
caught, so nothing else is needed.
*Known hosts* (optional) change this for hosts you list: on the trap port, a known host is
caught only on the configured trap paths, and its other paths get a plain `404` without being
logged. That is useful if your proxy forwards more than the bait paths of a real domain, for
example a whole location. Unknown hosts are always caught. The dashboard is never reachable
on the trap port.
**An HTTPS catch-all is rarely worth it.** Scanners of unknown hosts mostly speak plain HTTP to
the bare IP, and an HTTPS catch-all would need a certificate for names you don't own. Let the
proxy reject unknown TLS handshakes instead (nginx: `ssl_reject_handshake on;`).
## Nginx Proxy Manager
Put Flypaper into the same Docker network as NPM (the examples use the container name
`flypaper`).
1. **Settings → Default Site → Congratulations Page.** With this setting NPM writes no
default server of its own. Any other choice (404, redirect, HTML) creates one, and nginx
refuses to start with two default servers.
2. Create `/data/nginx/custom/http.conf` in the NPM container (on the host: inside NPM's
data volume):
```nginx
# Catch-all: every HTTP request whose Host matches no proxy host goes to Flypaper.
server {
listen 80 default_server; # the HTTP port NPM listens on inside its container
listen [::]:80 default_server;
server_name _;
location / {
# A variable makes nginx resolve the name per request, so NPM still starts
# (and serves your sites) while the Flypaper container is down.
resolver 127.0.0.11 valid=30s;
set $flypaper http://flypaper:8080;
proxy_pass $flypaper;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_read_timeout 1h;
}
}
```
3. Test and reload: `docker exec <npm-container> nginx -t`, then
`docker exec <npm-container> nginx -s reload`.
4. Optional trap paths on a real domain: in the proxy host's **Advanced** tab add
```nginx
location ~* ^/(\.env|\.git/|wp-login\.php|xmlrpc\.php) {
resolver 127.0.0.11 valid=30s;
set $flypaper http://flypaper:8080;
proxy_pass $flypaper;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
}
```
To undo the catch-all, delete `custom/http.conf` and reload.
## Plain nginx
Remove any existing `default_server` (on Debian/Ubuntu often `sites-enabled/default`) and add
```nginx
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
location / {
proxy_pass http://127.0.0.1:8080; # or a variable + resolver for a Docker name, see NPM
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
proxy_read_timeout 1h;
}
}
```
With Flypaper on the same host, nothing else is needed: loopback is trusted by default.
## Caddy
```caddyfile
# Catch-all for every host on port 80 without its own site block
:80 {
reverse_proxy flypaper:8080 {
header_up X-Real-IP {remote_host}
flush_interval -1
}
}
# Optional trap paths on a real site
example.com {
@trap path /.env /.git/* /wp-login.php /xmlrpc.php
reverse_proxy @trap flypaper:8080 {
header_up X-Real-IP {remote_host}
flush_interval -1
}
reverse_proxy your-app:8080
}
```
## Traefik
Traefik sets `X-Real-Ip` and `X-Forwarded-For` by default. Labels on the Flypaper container
(Traefik v3):
```yaml
labels:
traefik.enable: "true"
# Lowest priority: matches only hosts no other router claims
traefik.http.routers.flypaper-catchall.rule: "HostRegexp(`.+`)"
traefik.http.routers.flypaper-catchall.entrypoints: web
traefik.http.routers.flypaper-catchall.priority: "1"
# Optional trap paths on a real site
traefik.http.routers.flypaper-bait.rule: "Host(`example.com`) && (Path(`/.env`) || PathPrefix(`/.git/`) || Path(`/wp-login.php`))"
traefik.http.routers.flypaper-bait.priority: "1000"
traefik.http.services.flypaper.loadbalancer.server.port: "8080"
```
+35
View File
@@ -0,0 +1,35 @@
# 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](reverse-proxy.md#nginx-proxy-manager). 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://<unraid-ip>:<trap-port>` 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.