How tencent/nohost works
Purpose and entry points
Nohost is a Node.js, Whistle-based shared proxy/debugging platform: it hosts multi-user environments, applies per-environment Whistle rules, captures traffic, and exposes management/API surfaces. Package startup flows through index.js and lib/index.js; operational CLI commands are implemented in bin/nohost.js and bin/plugin.js.
Process bootstrap and orchestration
The core server initializes runtime configuration, ports, and the primary Whistle instance, then manages worker processes and restarts. lib/config.js holds service configuration; lib/main/index.js is the main-process entry; lib/main/worker.js and lib/main/whistleMgr.js coordinate workers and Whistle lifecycle. This is a server-side Node runtime, intended for a shared host rather than a standalone browser application.
Main management service
The main service provides system/admin operations such as login, settings, domain assignment, status, and restart. Routing and CGI handlers form the boundary between administrative clients and server control: lib/main/router.js, lib/main/cgi/login.js, and lib/main/cgi/restart.js. Persistent configuration/account-related state is mediated by lib/main/storage.js, rather than exposed directly to proxy plugins.
Per-user proxy and environment isolation
The bundled whistle.nohost plugin is the core traffic-routing layer. It determines accounts/environments, builds rules, and routes requests/tunnels into the appropriate Whistle context: lib/plugins/whistle.nohost/index.js, lib/plugins/whistle.nohost/lib/accountMgr.js, and lib/plugins/whistle.nohost/lib/rulesServer.js. Its tunnel-specific path is separated in lib/plugins/whistle.nohost/lib/tunnelRulesServer.js. Requests first reach the shared Whistle proxy, then plugin rules decide whether to forward, inject the environment selector, or bypass Nohost.
Plugin-facing UI and external API
The Nohost Whistle plugin serves an embedded UI/API for environment selection, generated rules, network data, redirects, and account actions. Its HTTP boundary is organized through lib/plugins/whistle.nohost/lib/uiServer/index.js, lib/plugins/whistle.nohost/lib/uiServer/router.js, and lib/plugins/whistle.nohost/lib/uiServer/openAPI.js. A separate service import/export surface supports automation by CI or release systems: lib/service/index.js, lib/service/router.js, and lib/service/cgi/import.js.
Administration and browser clients
The administrative SPA manages accounts, certificates, global configuration, and settings; source entry points are src/admin/index.js, src/admin/accounts/index.js, and src/admin/certs/index.js. A separate injected/selectable environment UI is rooted in src/button/index.js and src/select/index.js. Webpack configurations in src/config/webpack.common.js and production/dev variants build these browser assets.
Deployment boundaries and integrations
Nohost depends materially on Whistle as the proxy/rule engine and supports Whistle plugins, including packaged gateway/SNI extensions under packages/gateway/lib/whistle.gateway/index.js and packages/gateway/lib/whistle.snicallback/index.js. Clients connect by configuring HTTP proxy settings or remote Whistle rules; HTTPS inspection/routing depends on uploaded .crt/.key certificates. Deployment may sit behind an external Nginx reverse proxy, while DNS and TLS certificate ownership remain infrastructure responsibilities outside this repository.
Components 20
Node runtime
Shared-host server and process control.
- Startup entry
index.js - Server bootstrap
lib/index.js - Runtime config
lib/config.js - Main process · Initializes the primary Whistle instance and service control.
lib/main/index.js - Workers
lib/main/worker.js - Whistle lifecycle
lib/main/whistleMgr.js - Persistent state · Stores configuration and account-related state.
lib/main/storage.js
Proxy routing
Whistle plugin isolates environments and traffic.
- Shared Whistle proxy
- Nohost plugin · Selects account/environment and builds routing rules.
lib/plugins/whistle.nohost/index.js - Account environments
lib/plugins/whistle.nohost/lib/accountMgr.js - HTTP rules server · Forwards, injects environment selection, or bypasses Nohost.
lib/plugins/whistle.nohost/lib/rulesServer.js - Tunnel rules
lib/plugins/whistle.nohost/lib/tunnelRulesServer.js - Gateway and SNI plugins
packages/gateway/lib/whistle.gateway/index.js
Management surfaces
Administrative, plugin, and automation APIs.
- Admin routing · Login, settings, domain, status, and restart operations.
lib/main/router.js - Plugin UI and API · Environment selection, generated rules, network data, and account actions.
lib/plugins/whistle.nohost/lib/uiServer/index.js - Service import API · Import/export surface for CI and release systems.
lib/service/index.js
Browser clients
Webpack-built administrative and environment UIs.
- Admin SPA
src/admin/index.js - Environment UI
src/button/index.js
Other components
- Proxy clients · Connect through HTTP proxy settings or remote Whistle rules.
- Administrators
Connections 20
- Startup entry → Server bootstrap: boots
- Server bootstrap → Runtime config: loads
- Server bootstrap → Main process: starts
- Main process → Workers: manages
- Main process → Whistle lifecycle: controls
- Whistle lifecycle → Shared Whistle proxy: starts and restarts
- Main process → Admin routing: serves
- Admin routing → Persistent state: reads and writes
- Shared Whistle proxy → Nohost plugin: dispatches traffic
- Nohost plugin → Account environments: resolves environment
- Nohost plugin → HTTP rules server: applies HTTP rules
- Nohost plugin → Tunnel rules: applies tunnel rules
- Account environments → Persistent state: uses account state
- Nohost plugin → Plugin UI and API: serves
- Service import API → Persistent state: imports and exports
- Administrators → Admin SPA: uses
- Admin SPA → Admin routing: manages system
- Environment UI → Plugin UI and API: selects environment
- Proxy clients → Shared Whistle proxy: proxy traffic
- Shared Whistle proxy → Gateway and SNI plugins: loads extension