HTTP Proxy

HTTP proxy principle and implementation

Web Proxy is an entity that exists in the middle of the network and offers a wide range of functions. In modern network system, Web proxy is everywhere. In my previous blog post about HTTP, I mentioned several times the effect of proxies on HTTP requests and responses. This article today, I intend to talk about some of the principles of the HTTP proxy itself, and how to quickly implement the proxysite with Node.js.

HTTP proxy exists in two forms, which are briefly described as follows:

The first is a generic proxy as described in RFC 7230 – HTTP / 1.1: Message Syntax and Routing, the first part of the revised RFC 2616, HTTP / 1.1 protocol. This agent acts as a “middleman,” which is the server for the clients that connect to it; it is the client for the server to connect to. It is responsible for sending HTTP packets back and forth between the two ends.

The second is Tunneling TCP based protocols through Web proxy servers, which describe the tunneling agents described in the tunneling of TCP-based protocols through the Web proxy. It communicates through the body of the HTTP protocol and implements any TCP-based application layer protocol proxy in HTTP.

This proxy uses the CONNECT method of HTTP to establish a connection, but CONNECT was not initially part of RFC 2616 – HTTP / 1.1. The description of CONNECT and the tunnel proxy was not added until the release of HTTP / 1.1 in 2014. See RFC 7231 – HTTP / 1.1: Semantics and Content. In fact, this agent has long been widely implemented.

The first type of proxy described in this article corresponds to Chapter 6 “Proxy” in the “HTTP Authoritative Guide,” and the second type corresponds to Section 8.5, “Integration Points: Gateways, Tunnels and Trunks,” in Chapter 8, “Tunneling.