`configurable-http-proxy` (CHP) is a robust HTTP proxy designed to dynamically manage routing tables via either a command-line interface or a REST API. Built as a wrapper around `node-http-proxy`, it extends the underlying library's capabilities to include WebSocket support, making it suitable for reverse proxies and load balancers. The package is a core component in JupyterHub deployments, enabling flexible routing for multi-user environments. The current stable version is 5.2.0, requiring Node.js 20 or newer. Releases typically align with JupyterHub's development cycle, focusing on stability, security, and integration within the Jupyter ecosystem. Its key differentiator is the on-the-fly reconfigurability of routes and its robust API for programmatic control, allowing for complex, dynamic proxying scenarios. It operates with distinct public-facing and inward-facing REST API servers, each with configurable IPs and ports.
npm install configurable-http-proxyVerified import paths — ran on the pinned version, not inferred.
This script demonstrates how to start `configurable-http-proxy` as a standalone service, setting up a default routing target and configuring both the public-facing and REST API interfaces with a security token.
Upgrade your Node.js environment to version 20 or newer. Consider using a Node Version Manager (nvm) for easy switching between versions.
Ensure the `CONFIGPROXY_AUTH_TOKEN` environment variable is set with a strong, secret token before starting the proxy. For API calls, include this token in the `Authorization` header as `token <YOUR_TOKEN>`.
Always bind the API to a restricted IP address (e.g., `127.0.0.1` or a private network interface) and ensure network firewalls restrict access to the API port. Only expose the public-facing proxy as needed.
Always specify a `--default-target` when starting the proxy, pointing to a fallback service (e.g., a JupyterHub instance or an error page server) to gracefully handle unrouted requests.
For project-specific deployments, consider installing `configurable-http-proxy` as a development dependency (`npm install --save-dev configurable-http-proxy`) and running it via `npx` or a script defined in `package.json` to ensure version isolation.
Choose an available port or terminate the process currently using the port. You can find processes using a port with `lsof -i :[port]` (Linux/macOS) or `netstat -ano | findstr :[port]` (Windows).
Ensure the `CONFIGPROXY_AUTH_TOKEN` environment variable is correctly set when starting the proxy. For API calls, include the `Authorization` header with the correct token: `curl -H "Authorization: token $CONFIGPROXY_AUTH_TOKEN" http://localhost:8001/api/routes`.
Upgrade your Node.js installation to version 20 or newer. Use a Node Version Manager like `nvm install 20 && nvm use 20` to manage versions.
Restart the proxy with a `--default-target` option, e.g., `configurable-http-proxy --default-target=http://localhost:8000 ...` to direct unrouted traffic to a fallback service.