How does NGINX upstream work? What does NGINX upstream mean?


how does nginx upstream work

Upstream is a useful NGINX block that is used for reverse proxy configuration. It allows NGINX to direct incoming requests to multiple backend servers and even do load balancing. One of the common questions people have is “How does NGINX upstream work?”. Let us look at it below.

 

How does NGINX upstream work? What does NGINX upstream mean?

 

Upstream is basically used for proxying requests to other servers.  It defines a cluster of back end processors that NGINX can proxy requests to. It is used for load balancing or routing requests. Here’s a simple example of a load balancer that uses upstream


http {
 upstream myproject {
  server 127.0.0.1:8010 weight=3;
  server 127.0.0.1:8011;
  server 127.0.0.1:8012;
  server 127.0.0.1:8013;
 }

 server {
  listen 80;
  server_name www.example.com;
  location / {
   proxy_pass http://myproject;
  }
 }
}

 

In the above code, NGINX listens to port 80 as a reverse proxy. All incoming requests are sent to cluster of backend servers, called myproject, listening to ports 8010-8013, with a preference to the server listening to port 8010.

You can also look into more detailed uses of upstream in NGINX reverse proxy configuration.

 

About Sreeram Sreenivasan

Sreeram Sreenivasan is the Founder of Ubiq, a business dashboard & reporting platform for small & medium businesses. Ubiq makes it easy to build business dashboards & reports for your business. Try it for free today!