http-mitm-proxy is a robust Node.js-based HTTP and HTTPS Man In The Middle (MITM) proxy designed for intercepting, inspecting, and modifying network traffic, including WebSocket communications. It provides granular control over requests and responses through its event-driven API, allowing developers to implement custom filters and handlers. A key feature is its automatic generation of SSL certificates using `node-forge`, which facilitates transparent interception of encrypted HTTPS connections, requiring users to trust a generated root CA certificate. The current stable version is 1.1.0, which was published approximately two years ago. While the library is still widely used and downloaded, its maintenance status is currently considered inactive, with no new releases in the past year and limited recent activity on its GitHub repository. Key differentiators include its pure Node.js implementation, bundled TypeScript definitions, and a modular API for extending functionality with various request and response filters.
npm install http-mitm-proxyVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes an HTTP MITM proxy on port 8081 and demonstrates how to intercept and modify responses, specifically replacing Google search result titles with 'Pwned!'. It also includes basic error handling. To intercept HTTPS, the generated CA certificate must be trusted by the client.
Ensure your Node.js environment is version 16 or newer. Update Node.js or use a version manager like `nvm` to switch to a compatible version (e.g., `nvm install 16 && nvm use 16`).
Locate the `ca.pem` file in your configured `sslCaDir` (default usually in a temporary directory) and manually import it into your system's or browser's trusted root certificate store. Specific steps vary by OS/browser.
Consider auditing the project's codebase for any security vulnerabilities if used in production. For long-term projects, explore more actively maintained alternatives or be prepared to fork and maintain the library internally.
Refer to the project's GitHub repository for detailed changelogs or release notes between 0.x and 1.x. Test your application thoroughly after upgrading and adapt your code to the new API if necessary.
Manually install the `ca.pem` certificate from the proxy's `sslCaDir` into your client's operating system or browser's trusted root certificate store.
Ensure your system's date and time are correct. If the issue persists, delete the contents of the `sslCaDir` directory to force the proxy to regenerate new CA and host certificates.
Ensure the `sslCaDir` is correctly set up and the CA is trusted. For specific or complex hostname scenarios, consider using the `proxy.onCertificateRequired` hook to provide custom certificates that exactly match the target host.