Changeset f99bbe8 in Klonkt for scripts


Ignore:
Timestamp:
06/23/2026 10:00:00 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
5eef817
Parents:
09ee2bd
Message:

security: bind to 127.0.0.1 by default behind a reverse proxy

New HOST env (default 0.0.0.0 for Docker/back-compat). The VPS installer now
writes HOST=127.0.0.1 and Docker maps the host port to loopback (127.0.0.1:3000:3000)
+ overrides HOST=0.0.0.0 inside the container — so the app is never reachable
directly on its port from the internet, only via the proxy. .env.example defaults
to 127.0.0.1 (manual installs); docs explain it. Existing installs hardened on
re-run of install.sh.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • scripts/install.sh

    r09ee2bd rf99bbe8  
    160160    echo "NODE_ENV=production"
    161161    echo "PORT=${KLONKT_PORT}"
     162    # Bind to loopback only: Caddy (this host) reaches it; the internet cannot
     163    # hit the app directly on its port, bypassing HTTPS.
     164    echo "HOST=127.0.0.1"
    162165    echo "SESSION_SECRET=${SECRET}"
    163166    echo "DATABASE_PATH=./storage/database.sqlite"
     
    168171  } > "$ENV"
    169172  chown "$KLONKT_USER:$KLONKT_USER" "$ENV"; chmod 600 "$ENV"
    170   ok "new .env (random SESSION_SECRET)"
     173  ok "new .env (random SESSION_SECRET, app bound to 127.0.0.1)"
    171174else
    172175  # sync the port in an existing .env with the chosen port
    173176  if grep -q '^PORT=' "$ENV"; then sed -i "s/^PORT=.*/PORT=${KLONKT_PORT}/" "$ENV"; fi
    174   ok "kept existing .env (port synced)"
     177  # harden older installs: bind to loopback if not already configured
     178  grep -q '^HOST=' "$ENV" || echo "HOST=127.0.0.1" >> "$ENV"
     179  ok "kept existing .env (port synced, bound to 127.0.0.1)"
    175180fi
    176181
Note: See TracChangeset for help on using the changeset viewer.