annotate xml/en/docs/http/ngx_http_upstream_module.xml @ 589:764fbac1b8b4

Added document revision.
author Ruslan Ermilov <ru@nginx.com>
date Tue, 17 Jul 2012 05:02:15 +0000
parents be54c443235a
children 841118e33f41
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
1 <?xml version="1.0"?>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
2
580
be54c443235a Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents: 566
diff changeset
3 <!--
be54c443235a Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents: 566
diff changeset
4 Copyright (C) Igor Sysoev
be54c443235a Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents: 566
diff changeset
5 Copyright (C) Nginx, Inc.
be54c443235a Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents: 566
diff changeset
6 -->
be54c443235a Added copyright markers to documentation sources.
Ruslan Ermilov <ru@nginx.com>
parents: 566
diff changeset
7
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
8 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
9
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
10 <module name="Module ngx_http_upstream_module"
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
11 link="/en/docs/http/ngx_http_upstream_module.html"
589
764fbac1b8b4 Added document revision.
Ruslan Ermilov <ru@nginx.com>
parents: 580
diff changeset
12 lang="en"
764fbac1b8b4 Added document revision.
Ruslan Ermilov <ru@nginx.com>
parents: 580
diff changeset
13 rev="1">
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
14
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
15 <section id="summary">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
16
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
17 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
18 The <literal>ngx_http_upstream_module</literal> module
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
19 allows to define groups of servers that can be referenced
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
20 from the <link doc="ngx_http_proxy_module.xml" id="proxy_pass"/>,
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
21 <link doc="ngx_http_fastcgi_module.xml" id="fastcgi_pass"/>, and
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
22 <link doc="ngx_http_memcached_module.xml" id="memcached_pass"/> directives.
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
23 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
24
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
25 </section>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
26
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
27
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
28 <section id="example" name="Example Configuration">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
29
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
30 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
31 <example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
32 upstream <emphasis>backend</emphasis> {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
33 server backend1.example.com weight=5;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
34 server backend2.example.com:8080;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
35 server unix:/tmp/backend3;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
36
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
37 server backup1.example.com:8080 backup;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
38 server backup2.example.com:8080 backup;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
39 }
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
40
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
41 server {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
42 location / {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
43 proxy_pass http://<emphasis>backend</emphasis>;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
44 }
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
45 }
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
46 </example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
47 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
48
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
49 </section>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
50
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
51
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
52 <section id="directives" name="Directives">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
53
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
54 <directive name="upstream">
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
55 <syntax block="yes"><value>name</value></syntax>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
56 <default/>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
57 <context>http</context>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
58
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
59 <para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
60 Defines a group of servers.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
61 Servers can listen on different ports.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
62 In addition, servers listening on TCP and UNIX-domain sockets
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
63 can be mixed.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
64 </para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
65
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
66 <para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
67 Example:
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
68 <example>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
69 upstream backend {
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
70 server backend1.example.com weight=5;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
71 server 127.0.0.1:8080 max_fails=3 fail_timeout=30s;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
72 server unix:/tmp/backend3;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
73 }
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
74 </example>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
75 </para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
76
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
77 <para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
78 By default, requests are distributed between servers using a
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
79 weighted round-robin balancing method.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
80 In the above example, each 7 requests will be distributed as follows:
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
81 5 requests to <literal>backend1.example.com</literal>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
82 and one request to each of second and third servers.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
83 If an error occurs when communicating with the server, a request will
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
84 be passed to the next server, and so on until all of the functioning
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
85 servers will be tried.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
86 If a successful response could not be obtained from any of the servers,
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
87 the client will be returned the result of contacting the last server.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
88 </para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
89
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
90 </directive>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
91
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
92
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
93 <directive name="server">
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
94 <syntax><value>address</value> [<value>parameters</value>]</syntax>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
95 <default/>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
96 <context>upstream</context>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
97
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
98 <para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
99 Defines an <value>address</value> and other <value>parameters</value>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
100 of the server.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
101 An address can be specified as a domain name or IP address,
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
102 and an optional port, or as a UNIX-domain socket path
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
103 specified after the “<literal>unix:</literal>” prefix.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
104 If port is not specified, the port 80 is used.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
105 A domain name that resolves to several IP addresses essentially defines
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
106 multiple servers.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
107 </para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
108
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
109 <para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
110 The following parameters can be defined:
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
111 <list type="tag">
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
112
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
113 <tag-name><literal>weight</literal>=<value>number</value></tag-name>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
114 <tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
115 sets a weight of the server, by default 1.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
116 </tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
117
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
118 <tag-name><literal>max_fails</literal>=<value>number</value></tag-name>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
119 <tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
120 sets a number of unsuccessful attempts to communicate with the server
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
121 during a time set by the <literal>fail_timeout</literal> parameter
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
122 after which it will be considered down for a period of time also set
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
123 by the <literal>fail_timeout</literal> parameter.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
124 By default, the number of unsuccessful attempts is set to 1.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
125 A value of zero disables accounting of attempts.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
126 What is considered to be an unsuccessful attempt is configured by the
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
127 <link doc="ngx_http_proxy_module.xml" id="proxy_next_upstream"/>,
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
128 <link doc="ngx_http_fastcgi_module.xml" id="fastcgi_next_upstream"/>, and
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
129 <link doc="ngx_http_memcached_module.xml" id="memcached_next_upstream"/>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
130 directives.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
131 The <literal>http_404</literal> state is not considered
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
132 an unsuccessful attempt.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
133 </tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
134
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
135 <tag-name><literal>fail_timeout</literal>=<value>time</value></tag-name>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
136 <tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
137 sets
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
138 <list type="bullet">
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
139
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
140 <listitem>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
141 a time during which the specified number of unsuccessful attempts to
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
142 communicate with the server should happen for the server to be
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
143 considered down;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
144 </listitem>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
145
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
146 <listitem>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
147 and a period of time the server will be considered down.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
148 </listitem>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
149
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
150 </list>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
151 By default, timeout is set to 10 seconds.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
152 </tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
153
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
154 <tag-name><literal>backup</literal></tag-name>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
155 <tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
156 marks the server as a backup server.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
157 It will be passed requests when the primary servers are down.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
158 </tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
159
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
160 <tag-name><literal>down</literal></tag-name>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
161 <tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
162 marks the server as permanently down; used along with
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
163 the <link id="ip_hash"/> directive.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
164 </tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
165
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
166 </list>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
167 </para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
168
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
169 <para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
170 Example:
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
171 <example>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
172 upstream backend {
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
173 server backend1.example.com weight=5;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
174 server 127.0.0.1:8080 max_fails=3 fail_timeout=30s;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
175 server unix:/tmp/backend3;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
176
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
177 server backup1.example.com:8080 backup;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
178 }
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
179 </example>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
180 </para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
181
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
182 </directive>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
183
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
184
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
185 <directive name="ip_hash">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
186 <syntax/>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
187 <default/>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
188 <context>upstream</context>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
189
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
190 <para>
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
191 Specifies that a group should use a load balancing method where requests
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
192 are distributed between servers based on client IP addresses.
542
a9e6a8613534 Documented IPv6 support in ip_hash.
Ruslan Ermilov <ru@nginx.com>
parents: 533
diff changeset
193 The first three octets of the client IPv4 address, or the entire IPv6 address,
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
194 are used as a hashing key.
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
195 The method ensures that requests of the same client will always be
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
196 passed to the same server except when this server is considered down
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
197 in which case client requests will be passed to another server and
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
198 most probably it will also be the same server.
542
a9e6a8613534 Documented IPv6 support in ip_hash.
Ruslan Ermilov <ru@nginx.com>
parents: 533
diff changeset
199 <note>
566
f8148fc88224 Documented 1.2.2 changes.
Ruslan Ermilov <ru@nginx.com>
parents: 542
diff changeset
200 IPv6 addresses are supported starting from versions 1.3.2 and 1.2.2.
542
a9e6a8613534 Documented IPv6 support in ip_hash.
Ruslan Ermilov <ru@nginx.com>
parents: 533
diff changeset
201 </note>
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
202 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
203
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
204 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
205 If one of the servers needs to be temporarily removed, it should
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
206 be marked with the <literal>down</literal> parameter in
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
207 order to preserve the current hashing of client IP addresses.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
208 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
209
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
210 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
211 Example:
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
212 <example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
213 upstream backend {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
214 ip_hash;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
215
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
216 server backend1.example.com;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
217 server backend2.example.com;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
218 server backend3.example.com <emphasis>down</emphasis>;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
219 server backend4.example.com;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
220 }
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
221 </example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
222 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
223
526
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
224 <para>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
225 <note>
566
f8148fc88224 Documented 1.2.2 changes.
Ruslan Ermilov <ru@nginx.com>
parents: 542
diff changeset
226 Until versions 1.3.1 and 1.2.2 it was not possible to specify a weight for
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
227 servers using the <literal>ip_hash</literal> load balancing method.
526
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
228 </note>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
229 </para>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
230
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
231 </directive>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
232
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
233
316
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
234 <directive name="keepalive">
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
235 <syntax><value>connections</value></syntax>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
236 <default/>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
237 <context>upstream</context>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
238 <appeared-in>1.1.4</appeared-in>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
239
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
240 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
241 Activates cache of connections to upstream servers.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
242 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
243
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
244 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
245 The <value>connections</value> parameter sets the maximum number of
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
246 keepalive connections to upstream servers that are retained in
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
247 the cache per one worker process.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
248 If there are more idle connections to retain to an upstream than
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
249 are specified by this number, the least recently used ones will
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
250 be closed.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
251 <note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
252 It should be noted that <literal>keepalive</literal> directive
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
253 does not limit the total number of connections that nginx worker
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
254 process can open to upstream servers.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
255 The new connections are always created on demand.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
256 The <value>connections</value> parameter should be set low enough
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
257 to allow upstream servers to process additional new incoming
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
258 connections as well.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
259 </note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
260 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
261
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
262 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
263 Example configuration of memcached upstream with keepalive connections:
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
264 <example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
265 upstream memcached_backend {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
266 server 127.0.0.1:11211;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
267 server 10.0.0.2:11211;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
268
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
269 keepalive 32;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
270 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
271
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
272 server {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
273 ...
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
274
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
275 location /memcached/ {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
276 set $memcached_key $uri;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
277 memcached_pass memcached_backend;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
278 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
279
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
280 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
281 </example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
282 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
283
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
284 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
285 For HTTP, the <link doc="ngx_http_proxy_module.xml" id="proxy_http_version"/>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
286 directive should be set to “<literal>1.1</literal>”
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
287 and the <header>Connection</header> header field should be cleared:
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
288 <example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
289 upstream http_backend {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
290 server 127.0.0.1:8080;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
291
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
292 keepalive 16;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
293 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
294
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
295 server {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
296 ...
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
297
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
298 location /http/ {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
299 proxy_pass http://http_backend;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
300 proxy_http_version 1.1;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
301 proxy_set_header Connection "";
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
302 ...
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
303 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
304 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
305 </example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
306 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
307
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
308 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
309 <note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
310 Alternatively, HTTP/1.0 persistent connections can be used by passing the
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
311 <header>Connection: Keep-Alive</header> header field to an upstream server,
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
312 though this is not recommended.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
313 </note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
314 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
315
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
316 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
317 For FastCGI servers, it is required to set
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
318 <link doc="ngx_http_fastcgi_module.xml" id="fastcgi_keep_conn"/>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
319 for keepalive connections to work:
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
320 <example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
321 upstream fastcgi_backend {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
322 server 127.0.0.1:9000;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
323
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
324 keepalive 8;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
325 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
326
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
327 server {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
328 ...
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
329
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
330 location /fastcgi/ {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
331 fastcgi_pass fastcgi_backend;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
332 fastcgi_keep_conn on;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
333 ...
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
334 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
335 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
336 </example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
337 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
338
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
339 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
340 <note>
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
341 When using load balancer methods other than the default
316
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
342 round-robin, it is necessary to activate them before
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
343 the <literal>keepalive</literal> directive.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
344 </note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
345
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
346 <note>
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
347 SCGI and uwsgi protocols do not have a notion of keepalive connections.
316
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
348 </note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
349 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
350
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
351 </directive>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
352
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
353
526
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
354 <directive name="least_conn">
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
355 <syntax/>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
356 <default/>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
357 <context>upstream</context>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
358 <appeared-in>1.3.1</appeared-in>
566
f8148fc88224 Documented 1.2.2 changes.
Ruslan Ermilov <ru@nginx.com>
parents: 542
diff changeset
359 <appeared-in>1.2.2</appeared-in>
526
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
360
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
361 <para>
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
362 Specifies that a group should use a load balancing method where a request
526
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
363 is passed to the server with the least number of active connections,
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
364 taking into account weights of servers.
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
365 If there are several such servers, they are tried using a
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
366 weighted round-robin balancing method.
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
367 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
368
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
369 </directive>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
370
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
371 </section>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
372
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
373
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
374 <section id="variables" name="Embedded Variables">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
375
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
376 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
377 The <literal>ngx_http_upstream_module</literal> module
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
378 supports the following embedded variables:
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
379 <list type="tag">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
380
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
381 <tag-name><var>$upstream_addr</var></tag-name>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
382 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
383 keeps an IP address and port of the server,
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
384 or a path to the UNIX-domain socket.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
385 If several servers were contacted during request processing,
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
386 their addresses are separated by commas, e.g.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
387 “<literal>192.168.1.1:80, 192.168.1.2:80, unix:/tmp/sock</literal>”.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
388 If an internal redirect from one server group to another happened
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
389 using
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
390 <header>X-Accel-Redirect</header> or
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
391 <link doc="ngx_http_core_module.xml" id="error_page"/>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
392 then these server groups are separated by colons, e.g.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
393 “<literal>192.168.1.1:80, 192.168.1.2:80, unix:/tmp/sock : 192.168.10.1:80, 192.168.10.2:80</literal>”.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
394 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
395
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
396 <tag-name><var>$upstream_response_time</var></tag-name>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
397 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
398 keeps servers response times in seconds with a milliseconds resolution.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
399 Several responses are also separated by commas and colons.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
400 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
401
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
402 <tag-name><var>$upstream_status</var></tag-name>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
403 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
404 keeps servers response codes.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
405 Several responses are also separated by commas and colons.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
406 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
407
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
408 <tag-name><var>$upstream_http_...</var></tag-name>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
409 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
410 keep server response header fields.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
411 For example, the <header>Server</header> response header field
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
412 is made available through the <var>$upstream_http_server</var> variable.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
413 Note that only the last server’s response header fields are saved.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
414 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
415
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
416 </list>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
417 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
418
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
419 </section>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
420
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
421 </module>