liveBook · Manning

Upstream definition

As explained in Road to Kubernetes

An upstream definition is an NGINX configuration construct that names a group of backend destinations for request forwarding.

An upstream definition names backend destinations that NGINX can use for request forwarding and load balancing. section 7.4.1

Configure an upstream group by:

  • Declaring an upstream name such as myapp. section 7.4.1
  • Listing backend servers with hostnames or addresses and their ports. section 7.4.1
  • Passing requests to the group with proxy_pass, such as http://myapp. section 7.4.1

Load balancing Compose services

A Docker Compose deployment can define bruce, tony, and thor as Python services plus scott as a JavaScript service. An NGINX upstream then targets bruce:8080, tony:8080, thor:8080, and scott:3000. Compose resolves those service names, while NGINX forwards requests through the group. section 7.4.1

Listing 7.18 NGINX upstream configuration
upstream myapp {
    server bruce:8080;
    server tony:8080;
    server thor:8080;
    server scott:3000;
}

server {
    listen 80;
    server_name localhost;

    location / {
        proxy_pass http://myapp;
    }
}

Inspect a complete NGINX upstream configuration that forwards traffic to multiple Compose services. section 7.4.1

How Road to Kubernetes covers it

How deep it goes
Explains declaration, destination syntax, proxy_pass integration, and a Compose deployment, but omits balancing algorithms.
Examples
Uses localhost and IP destinations, then routes to bruce, tony, thor, and scott Compose services.
What it assumes
Assumes basic NGINX configuration and Docker Compose service declarations.
What you can do after
Operate/configure NGINX to load-balance requests across multiple Docker Compose services.
How it connects
Connects NGINX, load balancing, reverse proxying, Docker Compose, service names, and proxy_pass.

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.