Changeset f99bbe8 in Klonkt for src/server.js


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
  • src/server.js

    r09ee2bd rf99bbe8  
    8787const __dirname = path.dirname(fileURLToPath(import.meta.url));
    8888const PORT = process.env.PORT || 3000;
     89// Interface to bind. Default 0.0.0.0 (needed for Docker port-forwarding). Behind a
     90// reverse proxy on the same host, set HOST=127.0.0.1 so the app is NOT reachable
     91// directly from the internet (only via the proxy) — see README/install docs.
     92const HOST = process.env.HOST || '0.0.0.0';
    8993const isDev = process.env.NODE_ENV !== 'production';
    9094
     
    427431});
    428432
    429 server.listen(PORT, () => {
     433server.listen(PORT, HOST, () => {
    430434  console.log('');
    431435  console.log('🪶 Klonkt Beta');
Note: See TracChangeset for help on using the changeset viewer.