0
0
Nginxdevops~30 mins

Upstream blocks in Nginx - Mini Project: Build & Apply

Choose your learning style9 modes available
Configuring an Nginx Upstream Block
📖 Scenario: You are setting up a simple load balancer using Nginx to distribute web traffic to multiple backend servers. This helps your website handle more visitors smoothly.
🎯 Goal: Build an Nginx configuration that defines an upstream block with two backend servers and uses it in a server block to proxy requests.
📋 What You'll Learn
Create an upstream block named backend with two servers: 192.168.1.10:8080 and 192.168.1.11:8080
Add a server block listening on port 80
Configure the location / to proxy requests to the backend upstream
Use the directive proxy_pass http://backend; inside the location block
💡 Why This Matters
🌍 Real World
Nginx upstream blocks are used to balance load between multiple backend servers, improving website reliability and speed.
💼 Career
Understanding upstream blocks is essential for DevOps roles managing web server configurations and scaling web applications.
Progress0 / 4 steps
1
Create the upstream block
Create an upstream block named backend with two servers: 192.168.1.10:8080 and 192.168.1.11:8080.
Nginx
Need a hint?

Use the upstream directive followed by the name backend. Inside the block, add two server lines with the exact IP addresses and ports.

2
Add a server block listening on port 80
Add a server block that listens on port 80.
Nginx
Need a hint?

Use the server directive and inside it add listen 80; to accept HTTP traffic on port 80.

3
Configure location block to proxy requests
Inside the server block, add a location / block that uses proxy_pass http://backend; to forward requests to the upstream.
Nginx
Need a hint?

Inside the server block, add location / {} and inside it add proxy_pass http://backend;.

4
Display the complete Nginx configuration
Print the complete Nginx configuration including the upstream and server blocks.
Nginx
Need a hint?

Show the full configuration text exactly as built in previous steps.