Separate dashboard port, first-run password setup and default trusted proxies

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Opus 5.5 committed 2026-11-14 17:21:49 +01:00
1 parent a34ff96490
commit c22d452720
25 files changed
+654 -109

No files matched your search

+48 -40
View File
@@ -18,14 +18,14 @@ flowchart LR
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 host"| flypaper
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 looks at the `Host` header. A request for a host it doesn't know, or for a trap path,
is caught. Requests for a known host (the dashboard's) pass through to the dashboard.
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
@@ -48,19 +48,26 @@ flowchart LR
- **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 (answers only to private
addresses)
- **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
## Quick start
There is no public image; build it from source.
There is no public image yet; build it from source. No environment variable is required.
```bash
git clone <repository-url> flypaper
cd flypaper
docker build -t flypaper .
docker run -d --name flypaper --restart unless-stopped \
-p 8080:8080 -p 127.0.0.1:8081:8081 \
-v flypaper-data:/data \
flypaper
```
Create a `compose.yaml` next to the `Dockerfile`:
Or with Compose, in a `compose.yaml` next to the `Dockerfile`:
```yaml
services:
@@ -70,14 +77,8 @@ services:
container_name: flypaper
restart: unless-stopped
ports:
- "8080:8080"
environment:
TZ: Europe/Berlin
# Host names that reach the dashboard. Every other Host header is trapped.
Flypaper__Http__KnownHosts__0: localhost
# The reverse proxy that sets X-Real-IP (IP or CIDR), see below.
Flypaper__Http__TrustedProxies__0: 172.16.0.0/12
Flypaper__Admin__Password: ${FLYPAPER_ADMIN_PASSWORD:?set FLYPAPER_ADMIN_PASSWORD}
- "8080:8080" # trap: point your reverse proxy here
- "127.0.0.1:8081:8081" # dashboard: LAN or localhost only
volumes:
- flypaper-data:/data
@@ -85,15 +86,12 @@ volumes:
flypaper-data:
```
```bash
FLYPAPER_ADMIN_PASSWORD='a-long-random-password' docker compose up -d --build
```
- Dashboard: <http://localhost:8080>, log in with the password.
- See the trap in action (any unknown host works):
- Dashboard: <http://localhost:8081>. On the first visit Flypaper asks you to set the admin
password; afterwards you log in with it and can change it on the settings page.
- See the trap in action:
```bash
curl -N -H "Host: example.invalid" http://localhost:8080/
curl -N http://localhost:8080/
```
This catch comes from a private address and is therefore not stored; the log line ends with
@@ -109,13 +107,16 @@ needed to run Flypaper.
## Behind a reverse proxy
Flypaper is meant to sit behind the reverse proxy that already owns ports 80/443. Two rules
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.
- **Trust the proxy in Flypaper**: `Flypaper__Http__TrustedProxies__0` must contain the
proxy's IP or subnet. Headers from anyone else are ignored, so bots can't fake their
address. For a Docker network:
- **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}}'
@@ -129,11 +130,14 @@ bot never sees it. Flypaper sends `X-Accel-Buffering: no`, which nginx honors.
- **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. Your domains are unknown to Flypaper,
so these requests are caught as well.
or `/wp-login.php`, from your real sites to Flypaper. Every request on the trap port is
caught, so nothing else is needed.
Never forward a whole domain that is listed as a known host: its other paths would show the
dashboard login.
*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.
### Nginx Proxy Manager
@@ -210,7 +214,7 @@ server {
}
```
With Flypaper on the same host, `TrustedProxies` can stay empty: loopback is trusted by default.
With Flypaper on the same host, nothing else is needed: loopback is trusted by default.
### Caddy
@@ -256,13 +260,14 @@ labels:
### Environment variables
Read at startup. List entries need an index (`__0`, `__1`, ...).
All optional. Read at startup; list entries need an index (`__0`, `__1`, ...).
| Variable | Purpose | Default |
|---|---|---|
| `Flypaper__Http__KnownHosts__0` | Host names that reach the dashboard (`*.example.com` allowed). Every other host is trapped. | none |
| `Flypaper__Http__TrustedProxies__0` | IP or CIDR of the reverse proxy allowed to set `X-Real-IP` / `X-Forwarded-For` | loopback only |
| `Flypaper__Admin__Password` | Dashboard password. Without it the dashboard stays locked. | none |
| `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 above | 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` |
@@ -290,10 +295,13 @@ reset button removes all saved values.
## Security notes
- **Keep the dashboard internal.** Only list internal names or LAN addresses as known hosts
and never route a known host through your public proxy.
- **Use a strong admin password.** The login runs over plain HTTP unless you put the
dashboard behind TLS yourself.
- **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
@@ -315,7 +323,7 @@ dotnet run --project src/Flypaper.Web
```
`dotnet run` starts in the Development environment: the dashboard is at
<http://localhost:5248> (known host `localhost`, password `dev`), the database is
<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.