DurinDoor
Deployment

Reverse proxy and static assets

Loopback proxy trust for X-Forwarded-For, static asset checks, nginx and Caddy.

Use this guide after DurinDoor responds on loopback. You need a working build, a public HTTPS origin, and nginx or Caddy on the same host.

Configure the public origin

Set BASE_URL and NEXT_PUBLIC_BASE_URL to the public HTTPS origin. Set AUTH_COOKIE_SECURE=true, restart the app, and verify login through that origin.

Configure forwarding headers

DurinDoor trusts the rightmost X-Forwarded-For value only when the TCP peer is loopback. Leftmost x-forwarded-for and x-real-ip are ignored because a client can send them. The wrapper then deletes x-forwarded-for, x-forwarded-host, and x-forwarded-proto before Next sees the request. Set BASE_URL and NEXT_PUBLIC_BASE_URL to the public HTTPS origin; the proto/host headers are not a substitute.

A proxy that is not on loopback relative to DurinDoor (host nginx to a Docker bridge IP, or Caddy in another Compose service) does not qualify for forwarding-header trust. DurinDoor then uses the socket peer address and ignores X-Forwarded-For. Keep DurinDoor on 127.0.0.1 and proxy to that port on the same host.

Overwrite X-Forwarded-For. Do not append.

nginx

location / {
  proxy_pass http://127.0.0.1:20128;
  proxy_http_version 1.1;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-Proto $scheme;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  proxy_read_timeout  600s;
  proxy_send_timeout  600s;
}

$remote_addr replaces any client-supplied chain. Long timeouts cover model streams.

Caddy

durindoor.example.com {
  reverse_proxy 127.0.0.1:20128 {
    header_up Host {host}
    header_up X-Forwarded-Proto {scheme}
    header_up X-Forwarded-For {remote_host}
    flush_interval -1
    transport http {
      read_timeout 600s
      write_timeout 600s
    }
  }
}

header_up X-Forwarded-For {remote_host} overwrites the header with the client DurinDoor should see. Caddy still terminates TLS; set AUTH_COOKIE_SECURE=true and the BASE_URL pair to this HTTPS origin.

TRUST_PROXY=true is a separate login-limiter switch. Only turn it on when this wrapper is in the path and the proxy overwrites forwarding headers. Details: Security.

Static assets

Next standalone tracing does not copy everything this repo needs at boot. npm run build copies custom-server.js, open-sse/, MITM sources, public/, and .next/static/ into .next/standalone/. Previous public/ and .next/static/ copies are removed first so an old hashed chunk cannot be served.

The Docker image does the same copy: public/ and .next/static/ land next to standalone. A custom image that drops those COPY lines 404s /_next/static/... and leaves the dashboard blank.

npm run verify:static

After npm run build:

npm run verify:static

The check starts .next/standalone/custom-server.js on a free 127.0.0.1 port, with a throwaway DATA_DIR and dummy JWT_SECRET / API_KEY_SECRET. It GETs /dashboard, parses local .js, .css, .woff2, .svg, .ico, .webmanifest, and .png URLs, and requires HTTP 200 and a nonempty, non-HTML body for each. JS/CSS must also have the matching content type. Missing assets print and the process exits non-zero. No JS/CSS in the HTML is also a failure.

A zero exit code confirms those assets are reachable in the checked build. It does not run browser interactions. If the check fails, rebuild before restarting, and inspect missing files in the packaged build. Run the check before deploying. Install choices: Laptop. Docker copies: Docker. VPS unit: VPS and cloud.

npm run verify:installed

After building standalone output or installing the npm package, pass the actual bundled server executable:

npm run verify:installed -- /absolute/standalone/custom-server.js
npm run verify:installed -- /absolute/npm-prefix/lib/node_modules/durindoor/app/custom-server.js

The second form checks the installed npm server payload, not the interactive CLI launcher or its installer. Supply a self-contained artifact: the harness never copies dependencies from the checkout, an npm sibling directory, or the user's runtime cache. A missing packaged dependency is a failure, not permission to install it. It rejects external/absolute symlinks, copies the artifact to a temporary directory, and runs that copy with isolated HOME, DATA_DIR, cache directories, generated test secrets, and a loopback-only port. It does not inherit credentials, proxy settings, NODE_PATH, or NODE_OPTIONS.

The check requires JSON health success, wrong-password rejection, correct-password session issuance, authenticated provider discovery with no saved connections, and dashboard static assets using the same verifier as verify:static. Redirects and HTML masquerading as an asset fail. Any failure exits nonzero; the child and temporary directory are cleaned up.

Before launching the server, the harness checks the shipped PostgreSQL worker at src/lib/db/adapters/pgSyncWorker.cjs, resolves pg and pg-query-stream, and sends the real worker a close operation without connecting to PostgreSQL. It dynamically imports playwright from the packaged browser-pool boundary without launching or downloading a browser. These advertised optional runtimes must resolve even though this smoke uses SQLite and makes no provider inference calls. This is not PostgreSQL query or browser-session proof. No unrelated upstream worker is assumed.

npm run verify:packed

Takes the .tgz from npm pack ./cli (not npm --prefix cli pack, which packs the repository root) (after npm --prefix cli run build), installs it with --ignore-scripts into a clean temporary prefix and HOME, then runs the installed-artifact check above on node_modules/durindoor/app/custom-server.js. It publishes nothing. The manual Artifact Smoke workflow and the Release workflow (before the publish step) run both the standalone and packed checks; pull requests do not, to save Actions minutes.

The harness does not build, install, publish, enable browser auto-install, or use live provider credentials. Build/install and exercise it separately for each release artifact. Docker verification remains pending on this host: Docker is unavailable; a host artifact smoke does not prove the Docker image.

On this page

Edit on GitHub