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
