node-http-proxy is an HTTP programmable proxying library for Node.js with WebSocket support. It fits reverse proxies, load balancers, and custom proxy servers.
Overview
node-http-proxy lets you create a proxy by calling createProxyServer with an options object. Unless you call listen on the instance, it does not start a web server by itself.
The returned object exposes web, ws, listen, and close methods. The web method proxies HTTP(S) requests; ws proxies WebSocket traffic. You can attach event listeners or use callbacks for errors and lifecycle hooks.
Configuration covers targets, SSL, header rewriting, cookies, redirects, authentication, timeouts, and optional response self-handling. Examples in the docs cover stand-alone servers, custom logic, HTTPS variants, latency simulation, and response modification.
Install via npm as the http-proxy package. A separate ProxyTable add-on defines route-matching rules for reverse proxy setups.
Key features
- HTTP and HTTPS proxying
- WebSocket proxy support
- Request and response pipelines
- Header and cookie rewriting
- SSL verification options
- Optional built-in listen helper
- Proxy event hooks
- ProxyTable routing add-on
Use cases
- Reverse proxy components
- Load balancer building blocks
- Custom stand-alone proxy servers
- WebSocket proxying
- Request header or response rewriting