Book Image

Nginx Essentials

By : Valery Kholodkov, Valery I Kholodkov
Book Image

Nginx Essentials

By: Valery Kholodkov, Valery I Kholodkov

Overview of this book

Table of Contents (13 chapters)

Managing outbound traffic


Nginx also has a variety of options for outbound traffic management:

  • Distributing outbound connections among multiple servers

  • Configuring backup servers

  • Enabling persistent connections with backend servers

  • Limiting transfer rate while reading from backend servers

To enable most of these functions, the first thing you need is to declare your upstream servers explicitly.

Declaring upstream servers

Nginx allows you to declare upstream servers explicitly. You can then refer to them multiple times as a single entity from any part of the http configuration. If the location of your server or servers changes, there is no need to go over the entire configuration and adjust it. If new servers join a group, or existing servers leave a group, it's only necessary to adjust the declaration and not the usage.

An upstream server is declared in the upstream section:

http {
    upstream backend  {
        server server1.example.com;
        server server2.example.com;
        server server3...