#upstream
Posts
-
Digging into nginx's Source 11: Upstream and Proxy — One Request Through the Reverse Proxy
We follow, in the source, how one proxy_pass line installs a content handler on a location, how the proxy module fills the callbacks of ngx_http_upstream_t, and how upstream then takes care of the non-blocking connect, sending the request, reading the response header and streaming the body. We check the request the backend actually receives (HTTP/1.1 by default in this version, and no Connection header), where 502 and 504 are decided, proxy_next_upstream, and proxy_buffering on/off with its temporary file — using debug logs, gdb and a tiny backend.
-
Digging into nginx's Source 12: Load Balancing, Upstream Keepalive and the Stream Module — and Wrapping Up the Series
When an upstream {} block lists several servers, how does nginx pick one for each request? We trace the load-balancing frame built from three function pointers (peer.init, get, free), the smooth weighted round robin that spreads weights 5:1:1 as a a b a c a a, max_fails and fail_timeout, the keepalive module that wraps get/free to park connections in a cache (on by default in this version, even if you never write it), and the stream module that puts the same foundation under plain TCP — checked against the source and Docker examples — and then wrap up the series.