Node.js Process-Based HTTP Proxy

0.2.4 · abandoned · verified Wed Apr 22

This package, `node-http-proxy` by 'wddqing', provides an HTTP(S) proxy server for Node.js, distinguished by its support for both single and multi-process modes, configurable via a command-line interface (`nproxy`) or programmatic API. It was last published as version 0.2.4 over five years ago and requires a very old Node.js environment (>=0.10). The package is considered abandoned, lacks active maintenance, and is not compatible with modern Node.js versions or current web standards. It should not be confused with the widely-used and actively maintained `http-proxy` library from `http-party`, which offers a different API and feature set. Due to its age and lack of updates, using this specific `node-http-proxy` in contemporary projects poses significant compatibility and security risks.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to programmatically start a `node-http-proxy` server with a configurable port and number of worker instances.

const { proxyMaster: ProxyMaster } = require('node-http-proxy');

const port = process.env.PROXY_PORT ? parseInt(process.env.PROXY_PORT) : 8123;
const instances = process.env.PROXY_INSTANCES ? parseInt(process.env.PROXY_INSTANCES) : 1;

console.log(`Starting Node HTTP Proxy on port ${port} with ${instances} instance(s)...`);

const proxymaster = new ProxyMaster({
  instance: instances,
  port: port
});

proxymaster.start();

// Example of how to stop the server (optional, for demonstration)
// setTimeout(() => {
//   console.log('Stopping proxy master...');
//   // Note: The original package's stop mechanism is primarily CLI-driven.
//   // Programmatic stopping might require deeper inspection or process killing.
// }, 10000);

console.log('Proxy server initialized. Use `curl -x 127.0.0.1:' + port + ' http://www.google.com/` to test.');

view raw JSON →