Deployment-Härtung + Podman-Container

- http.Server mit Timeouts (Slowloris) und Graceful Shutdown (SIGTERM)
- Adresse und DB-Pfad per Env (KVER_ADDR, KVER_DB)
- Security-Header global: nosniff, X-Frame-Options, Referrer-Policy, CSP
- Upload-Requests hart auf 17 MB gedeckelt (MaxBytesReader statt nur
  Multipart-Speichergrenze)
- Indizes für Feed-, Thread- und Vote-Queries
- middleware.RealIP für Logging/Rate-Limit hinter dem Reverse-Proxy
- Containerfile (Multi-Stage, Alpine, non-root) + Deploy-Doku in notes/

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 07:00:09 +02:00
parent 925b00edf5
commit 50be342899
7 changed files with 248 additions and 18 deletions
+13 -5
View File
@@ -189,6 +189,10 @@ func handleThread(w http.ResponseWriter, r *http.Request) {
func handleCreateEntry(w http.ResponseWriter, r *http.Request) {
uid := uidFromContext(r.Context())
// MaxBytesReader kappt den gesamten Request hart: ParseMultipartForm
// begrenzt nur den Speicher, alles darüber liefe sonst unbegrenzt in
// Temp-Dateien auf die Platte.
r.Body = http.MaxBytesReader(w, r.Body, maxUploadBytes)
if err := r.ParseMultipartForm(16 << 20); err != nil && err != http.ErrNotMultipart {
writeError(w, http.StatusBadRequest, "Ungültige Anfrage")
return
@@ -426,11 +430,15 @@ func handleVote(w http.ResponseWriter, r *http.Request) {
}
const (
maxImageSize = 1024 // Zielkante beim Skalieren
maxImagePixels = 50_000_000 // pro Frame: Schutz vor Decompression-Bomb
maxGIFBytes = 16 << 20 // Obergrenze für durchgereichte GIFs
maxGIFFrames = 1000 // animiertes GIF: Frame-Budget
maxGIFPixels = 100_000_000 // animiertes GIF: Summe aller Frame-Pixel
maxImageSize = 1024 // Zielkante beim Skalieren
maxImagePixels = 50_000_000 // pro Frame: Schutz vor Decompression-Bomb
maxGIFBytes = 16 << 20 // Obergrenze für durchgereichte GIFs
maxGIFFrames = 1000 // animiertes GIF: Frame-Budget
maxGIFPixels = 100_000_000 // animiertes GIF: Summe aller Frame-Pixel
// Hartes Limit für Upload-Requests insgesamt (Bild + Formularfelder +
// Multipart-Overhead), via http.MaxBytesReader.
maxUploadBytes = 17 << 20
)
// storeImage speichert ein hochgeladenes Bild unter static/media.