explaingit

http-party/node-http-proxy

14,141JavaScriptAudience · developerComplexity · 3/5LicenseSetup · easy

TLDR

A Node.js library for building HTTP and WebSocket proxy servers, sits in the middle of web traffic, forwards requests to other servers, and returns their responses. Good for reverse proxies and load balancers.

Mindmap

mindmap
  root((node-http-proxy))
    What it does
      Forward HTTP requests
      Forward WebSockets
      Reverse proxy
      Load balancing
    How it works
      Sits in the middle
      You write the logic
      Event-based API
    Use cases
      Custom middleware
      Header rewriting
      Latency simulation
    Setup
      npm install
      Node.js required
      No extra infra
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Build a reverse proxy that forwards public internet requests to internal backend servers.

USE CASE 2

Create a load balancer that spreads incoming traffic across several servers so none get overwhelmed.

USE CASE 3

Proxy WebSocket connections for real-time features like chat or live updates.

USE CASE 4

Add custom logic, like rewriting headers or adding delays, to requests passing through your proxy.

Tech stack

JavaScriptNode.js

Getting it running

Difficulty · easy Time to first run · 30min

Requires Node.js, install via npm, no external infrastructure needed.

Open-source, use freely in your own projects including commercial ones.

In plain English

node-http-proxy is a building block for programmers who write servers in Node.js, a system for running JavaScript outside the browser. A proxy is a piece of software that sits in the middle of web traffic: a request comes in, the proxy passes it along to another server, and then it sends that server's response back to whoever asked. This library lets you build that middleman in your own code. The README explains that it is well suited for two common jobs. One is a reverse proxy, which receives requests from the public and forwards them to internal servers. The other is a load balancer, which spreads incoming requests across several servers so that no single one gets overwhelmed. It also supports websockets, a technology used for live, two-way connections such as chat or real-time updates. You start by installing it with the Node package manager and then creating a proxy server in your code. The library gives you a small set of methods: one for forwarding normal web requests, one for forwarding websocket requests, one to wrap the proxy in an actual web server listening on a port, and one to shut it down. Because you write the surrounding logic yourself, you stay in control of how each request is handled. The documentation walks through several worked examples with sample code. These include a basic stand-alone proxy, a proxy that runs your own custom logic, one that rewrites request headers before passing them on, one that changes the response coming back, one that adds deliberate delay to simulate latency, using HTTPS for secure connections, and proxying websockets. It also describes how to listen for events such as errors, and how to read or set various options. This is a developer library rather than a finished application, so it assumes you are comfortable writing Node.js code. The project is open source and includes sections on running its tests, contributing, and its license.

Copy-paste prompts

Prompt 1
Using node-http-proxy, write a Node.js script that forwards all requests arriving on port 3000 to http://localhost:8080 and logs each request URL.
Prompt 2
With node-http-proxy, create a simple round-robin load balancer in Node.js that alternates requests between two backend servers.
Prompt 3
Show me how to use node-http-proxy to rewrite the Host header before forwarding a request to an upstream server.
Prompt 4
Using node-http-proxy, proxy WebSocket connections from port 3000 to a backend WebSocket server at ws://localhost:8080.
Open on GitHub → Explain another repo

← http-party on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.