A Node.js wrapper API for Toxiproxy that provides a comprehensive RESTful interface to control Toxiproxy functionality with a terminal-style web UI.
- π Easy-to-use RESTful API wrapper for Toxiproxy
- π₯οΈ Web-based terminal UI for managing proxies and toxics
- π Automatic server management with auto-start capabilities
- π‘ Real-time proxy and toxic management
- π― Simplified toxic injection with helper endpoints
- π§ CLI command execution through API endpoints
- π CORS-enabled for easy integration
- π¦ Standalone executable support
Access the web interface at: https://toxihub.videsk.io
- Node.js (v14 or later)
- Toxiproxy installed on your system
toxiproxy-serverbinary should be available in your PATHtoxiproxy-clibinary should be available in your PATH
npm install @videsk/toxihubgit clone https://github.com/videsk/toxihub.git
cd toxihub
npm install
npm startDownload the pre-built binary for your platform from the releases page.
Configure Toxihub using environment variables or a .env file:
| Variable | Default | Description |
|---|---|---|
| PORT | 7072 | Port for the wrapper API server |
| TOXIPROXY_HOST | localhost | Host where Toxiproxy server runs |
| TOXIPROXY_PORT | 8474 | Port for the Toxiproxy server |
| TOXIPROXY_CLI | toxiproxy-cli | Path to the toxiproxy-cli executable |
| TOXIPROXY_SERVER | toxiproxy-server | Path to the toxiproxy-server executable |
| AUTO_START_SERVER | true | Whether to auto-start the Toxiproxy server if not running |
| LOG_LEVEL | info | Logging level (debug, info, warn, error) |
Example .env file:
PORT=7072
TOXIPROXY_HOST=localhost
TOXIPROXY_PORT=8474
AUTO_START_SERVER=true
LOG_LEVEL=info| Method | Endpoint | Description |
|---|---|---|
| GET | /status |
Check if Toxiproxy server is running |
| POST | /status |
Start the Toxiproxy server |
| DELETE | /status |
Stop the Toxiproxy server |
| PUT | /status |
Reset all proxies and toxics |
| Method | Endpoint | Description |
|---|---|---|
| GET | /proxies |
List all proxies |
| POST | /proxies |
Create a new proxy |
| GET | /proxies/:name |
Get details of a specific proxy |
| PATCH | /proxies/:name/toggle |
Toggle a proxy enabled/disabled |
| DELETE | /proxies/:name |
Delete a proxy |
| Method | Endpoint | Description |
|---|---|---|
| GET | /proxies/:name/toxics |
List all toxics for a proxy |
| POST | /proxies/:name/toxics |
Add a new toxic to a proxy |
| POST | /proxies/:name/toxics/:toxicName |
Update a toxic |
| DELETE | /proxies/:name/toxics/:toxicName |
Remove a toxic from a proxy |
These endpoints provide simplified interfaces for common network conditions:
| Method | Endpoint | Description |
|---|---|---|
| POST | /proxies/:name/latency |
Add latency toxic (simplified) |
| POST | /proxies/:name/bandwidth |
Add bandwidth limitation toxic (simplified) |
| POST | /proxies/:name/timeout |
Add timeout toxic (simplified) |
| Method | Endpoint | Description |
|---|---|---|
| POST | /cli |
Execute a custom toxiproxy-cli command |
Access the built-in web interface by navigating to http://localhost:7072 (or your configured port). The terminal-style UI provides:
- Real-time server status monitoring
- Visual proxy management
- Interactive toxic configuration
- Live API response display
- One-click proxy toggling and deletion
Toxihub includes a JavaScript client for programmatic interaction:
import ToxiproxyClient from '@videsk/toxihub/client';
const client = new ToxiproxyClient({
hostname: 'http://localhost:7072'
});
// Check server status
const status = await client.status();
// Create a proxy
await client.createProxy('redis_proxy', '127.0.0.1:26379', '127.0.0.1:6379');
// Add latency
await client.addLatencyToxic('redis_proxy', 500, 50);
// Toggle proxy
await client.toggleProxy('redis_proxy');curl -X POST http://localhost:7072/proxies \
-H "Content-Type: application/json" \
-d '{
"name": "redis_proxy",
"listen": "127.0.0.1:26379",
"upstream": "127.0.0.1:6379"
}'curl -X POST http://localhost:7072/proxies/redis_proxy/latency \
-H "Content-Type: application/json" \
-d '{
"latency": 500,
"jitter": 50
}'curl -X POST http://localhost:7072/proxies/redis_proxy/togglecurl -X DELETE http://localhost:7072/proxies/redis_proxy/toxics/latency_downstreamToxiproxy supports the following toxic types:
latency: Add delay to all databandwidth: Limit bandwidthslow_close: Delay the TCP socket from closingtimeout: Stop all data and close the connection after a timeoutreset_peer: Simulate TCP resetslicer: Slice TCP data into smaller bitslimit_data: Close connection after sending a certain number of bytes
Each toxic can be configured with specific attributes like latency amount, bandwidth rate, timeout duration, etc.
For development with auto-restart on code changes:
npm run devBuild for all platforms:
npm run buildPlatform-specific builds:
npm run build:linux
npm run build:win
npm run build:macFROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --production
COPY . .
EXPOSE 7072
CMD ["npm", "start"]- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Create an issue for bug reports or feature requests
- Visit https://toxihub.videsk.io for the live demo
- Documentation available at project homepage
