After getting the member servers ready, we will now proceed to configure nginx as the reverse proxy. Open the /etclsites-available/rev-proxy-Ib file in a text editor and enter the following data:

The first server dir(:Jctive just contains a rewrite to redirect all requests coming to UnixClinic.Net to http://unixclinic.net"

The upstream directive is in the nginx_http_upstream module that balances load across multiple back-end servers. This module uses a simple round-robin load balancing algorithm. The upstream directive specifies a set of servers that can be used in other directives such as proxyJlass andfastcgiJlass. The server directive specifies the name ofthe member server and the parameters applicable for a server.

• The name part can contain a domain name, IP address, a port number aQ.d a UNIX socket. If a domain name resolves to multiple IP addresses (multiple A records
in the DNS for a domain, see note), then all the IP addresses are used.

• A weight can be assigned to each server to specify its priority level for handling requests. If a weight is not assigned, then it is considered as 1. For example, if
a weight of 2 is specified for server _l.unixclinic.net as follows, then for every three requests, two will be

• The maxJails parameter specifies the maximum number of failed connection -attempts with a member server within a specified time period. This time period is specified by another parameterfaiCtimeout. The default value of this parameter is 1, and if this is set to 0 then the check is disabled. Setting this to 0 is certainly not recommended and I would advise setting this to atleast 2 or 3.

• The fail_timeout parameter contains the time duration in seconds. If all connection attempts with a member server for the specified time fail, then this would count as one failure. In our configuration above, thefaiCtimeout value is 30 seconds. This means that if the reverse proxy's connection attempts with one or more of our member servers failed for 30 seconds, then it would count as failed once, and another 30 second failure consecutively will take the 'failed' count to two.

After the failed count reaches two, which is what is the value of maxJails parameter in our case, the member server is marked as unresponsive for a certain amount of time. The default value for this is 10 seconds. And this timeout is controlled by other directives called proxy_ connecCtimeout and proXYJead_timeout. Read the nginxwiki for more details about this.

Name:  Configuring the reverse proxy (Layer 1).jpg
Views: 178
Size:  56.4 KB

• The down parameter ~arks the member server as permanently down. This is typically used with the directive ip_hash (discussed below).

• The backup parameter i~ only available in nginx version 0.6.7 or later. So if you decide to compile the latest nginx version for your use then this could be used. This parameter specifies the member server as a back-up server in case all the other member servers are busy or down.

The Debian Etch has nginx version 0.4.13-2, whereas the 'back ports' repository has nginx version 0.5.35-1. If you have decided to configure the 'back ports' repository in your server and then install nginx, you can make use of a new feature of the upstream directive, which is available since version 0.5.18. This feature allows you to log a few additional variables via the log module. These variables are:

• $upstream_addr-address of the upstream server that handled the request

• $upstream_status-upstream server status of the answer

• $upstream_response_time-this is recorded in milliseconds. Several answers will be divided by commas and colons.

• $upstream_http_$HEADER