Install the UI
ndb-ui is one binary with the styles and scripts inside. It needs nothing from the daemon: it uses the same HTTP API as the SDKs.
Install
curl -fsSL https://ndb.clowk.in/install.sh | bash -s -- --uiThe script installs ndb-ui instead of the daemon (NDB_COMPONENT=ui does the same). NDB_VERSION=0.3.1 pins a version. Release files for Linux and macOS (amd64 and arm64) are at Releases, with ndb-ui-checksums.txt.
Run
ndb-ui # http://127.0.0.1:4321
PORT=8080 ndb-ui # another port
NDB_URL=unix:///run/ndb/ndb.sock ndb-ui # one fixed connection, no add formWith no config, the console offers unix:///run/ndb/ndb.sock. Add other daemons in the New connection drawer. A connection is unix:///path, tcp://host:port, or http(s)://host. For TCP, give the bearer token of the daemon (-token-file).
Environment
| Variable | Default | Meaning |
|---|---|---|
NDB_URL | One fixed connection. The add form is hidden and the config file is not used. | |
NDB_TOKEN | Bearer token for NDB_URL. | |
NDB_NAME | default | Name of the fixed connection. |
PORT | 4321 | Listen port. |
HOST | 127.0.0.1 | Listen address (0.0.0.0 in the image). |
NDB_UI_ALLOWED_HOSTS | Host names the console answers for, besides IP addresses and localhost. A comma list, such as ndb.example.com,*.internal (*.internal is every name under internal). |
Protection
The console has no login. It keeps other sites out of it in two ways:
- Host check (DNS rebinding). A request whose
Hostis not an IP address,localhost, or a name inNDB_UI_ALLOWED_HOSTSgets403. A page on another site cannot point its own name at127.0.0.1and read the console. Behind a proxy, or with a name such asndb.example.com, add that name toNDB_UI_ALLOWED_HOSTS./healthzanswers for any host. - Origin check (CSRF). A
POST,PUT,PATCH, orDELETEwhoseOriginis not the console page itself gets403, also a JSON request, and also a request that the browser marksSec-Fetch-Site: cross-site. The forms and the tab actions also need theOriginof the console page.
These checks do not replace a login. Put ndb-ui behind authentication (a VPN, an SSH tunnel, or a proxy with a login) when you expose it outside your machine. ndb-stack (the daemon and the console in one image) is for development only: never use it in production.
A daemon on another VM
Open the daemon socket over SSH, then add tcp://127.0.0.1:7070 with no token:
ssh -N -L 7070:/run/ndb/ndb.sock user@vmOr give the daemon a TCP address and a token (listen.tcp and -token-file, see Configuration), and add tcp://host:port with the token.