annotate xml/en/docs/http/ngx_http_upstream_module.xml @ 580:be54c443235a

Added copyright markers to documentation sources.
author Ruslan Ermilov <ru@nginx.com>
date Tue, 10 Jul 2012 12:59:42 +0000
parents f8148fc88224
children 764fbac1b8b4
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"
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
12 lang="en">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
13
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
14 <section id="summary">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
15
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
16 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
17 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
18 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
19 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
20 <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
21 <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
22 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
23
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
24 </section>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
25
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 <section id="example" name="Example Configuration">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
28
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
29 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
30 <example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
31 upstream <emphasis>backend</emphasis> {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
32 server backend1.example.com weight=5;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
33 server backend2.example.com:8080;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
34 server unix:/tmp/backend3;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
35
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
36 server backup1.example.com:8080 backup;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
37 server backup2.example.com:8080 backup;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
38 }
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 server {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
41 location / {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
42 proxy_pass http://<emphasis>backend</emphasis>;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
43 }
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 </example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
46 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
47
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
48 </section>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
49
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 <section id="directives" name="Directives">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
52
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
53 <directive name="upstream">
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
54 <syntax block="yes"><value>name</value></syntax>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
55 <default/>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
56 <context>http</context>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
57
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
58 <para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
59 Defines a group of servers.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
60 Servers can listen on different ports.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
61 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
62 can be mixed.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
63 </para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
64
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
65 <para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
66 Example:
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 upstream backend {
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
69 server backend1.example.com weight=5;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
70 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
71 server unix:/tmp/backend3;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
72 }
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
73 </example>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
74 </para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
75
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
76 <para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
77 By default, requests are distributed between servers using a
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
78 weighted round-robin balancing method.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
79 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
80 5 requests to <literal>backend1.example.com</literal>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
81 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
82 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
83 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
84 servers will be tried.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
85 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
86 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
87 </para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
88
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
89 </directive>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
90
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 <directive name="server">
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
93 <syntax><value>address</value> [<value>parameters</value>]</syntax>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
94 <default/>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
95 <context>upstream</context>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
96
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
97 <para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
98 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
99 of the server.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
100 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
101 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
102 specified after the “<literal>unix:</literal>” prefix.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
103 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
104 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
105 multiple servers.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
106 </para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
107
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
108 <para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
109 The following parameters can be defined:
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
110 <list type="tag">
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
111
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
112 <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
113 <tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
114 sets a weight of the server, by default 1.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
115 </tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
116
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
117 <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
118 <tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
119 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
120 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
121 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
122 by the <literal>fail_timeout</literal> parameter.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
123 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
124 A value of zero disables accounting of attempts.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
125 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
126 <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
127 <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
128 <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
129 directives.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
130 The <literal>http_404</literal> state is not considered
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
131 an unsuccessful attempt.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
132 </tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
133
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
134 <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
135 <tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
136 sets
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
137 <list type="bullet">
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
138
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
139 <listitem>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
140 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
141 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
142 considered down;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
143 </listitem>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
144
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
145 <listitem>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
146 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
147 </listitem>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
148
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
149 </list>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
150 By default, timeout is set to 10 seconds.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
151 </tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
152
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
153 <tag-name><literal>backup</literal></tag-name>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
154 <tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
155 marks the server as a backup server.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
156 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
157 </tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
158
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
159 <tag-name><literal>down</literal></tag-name>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
160 <tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
161 marks the server as permanently down; used along with
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
162 the <link id="ip_hash"/> directive.
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
163 </tag-desc>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
164
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
165 </list>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
166 </para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
167
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
168 <para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
169 Example:
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 upstream backend {
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
172 server backend1.example.com weight=5;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
173 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
174 server unix:/tmp/backend3;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
175
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
176 server backup1.example.com:8080 backup;
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
177 }
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
178 </example>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
179 </para>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
180
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
181 </directive>
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
182
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
183
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
184 <directive name="ip_hash">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
185 <syntax/>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
186 <default/>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
187 <context>upstream</context>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
188
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
189 <para>
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
190 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
191 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
192 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
193 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
194 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
195 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
196 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
197 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
198 <note>
566
f8148fc88224 Documented 1.2.2 changes.
Ruslan Ermilov <ru@nginx.com>
parents: 542
diff changeset
199 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
200 </note>
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
201 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
202
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
203 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
204 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
205 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
206 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
207 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
208
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
209 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
210 Example:
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 upstream backend {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
213 ip_hash;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
214
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
215 server backend1.example.com;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
216 server backend2.example.com;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
217 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
218 server backend4.example.com;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
219 }
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
220 </example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
221 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
222
526
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
223 <para>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
224 <note>
566
f8148fc88224 Documented 1.2.2 changes.
Ruslan Ermilov <ru@nginx.com>
parents: 542
diff changeset
225 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
226 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
227 </note>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
228 </para>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
229
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
230 </directive>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
231
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
232
316
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
233 <directive name="keepalive">
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
234 <syntax><value>connections</value></syntax>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
235 <default/>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
236 <context>upstream</context>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
237 <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
238
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
239 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
240 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
241 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
242
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
243 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
244 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
245 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
246 the cache per one worker process.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
247 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
248 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
249 be closed.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
250 <note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
251 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
252 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
253 process can open to upstream servers.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
254 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
255 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
256 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
257 connections as well.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
258 </note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
259 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
260
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
261 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
262 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
263 <example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
264 upstream memcached_backend {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
265 server 127.0.0.1:11211;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
266 server 10.0.0.2:11211;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
267
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
268 keepalive 32;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
269 }
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 server {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
272 ...
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 location /memcached/ {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
275 set $memcached_key $uri;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
276 memcached_pass memcached_backend;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
277 }
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 </example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
281 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
282
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
283 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
284 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
285 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
286 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
287 <example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
288 upstream http_backend {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
289 server 127.0.0.1:8080;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
290
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
291 keepalive 16;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
292 }
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 server {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
295 ...
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 location /http/ {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
298 proxy_pass http://http_backend;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
299 proxy_http_version 1.1;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
300 proxy_set_header Connection "";
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
301 ...
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 </example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
305 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
306
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
307 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
308 <note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
309 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
310 <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
311 though this is not recommended.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
312 </note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
313 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
314
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
315 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
316 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
317 <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
318 for keepalive connections to work:
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
319 <example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
320 upstream fastcgi_backend {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
321 server 127.0.0.1:9000;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
322
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
323 keepalive 8;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
324 }
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 server {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
327 ...
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 location /fastcgi/ {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
330 fastcgi_pass fastcgi_backend;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
331 fastcgi_keep_conn on;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
332 ...
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 </example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
336 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
337
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
338 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
339 <note>
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
340 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
341 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
342 the <literal>keepalive</literal> directive.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
343 </note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
344
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
345 <note>
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
346 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
347 </note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
348 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
349
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
350 </directive>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
351
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
352
526
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
353 <directive name="least_conn">
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
354 <syntax/>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
355 <default/>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
356 <context>upstream</context>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
357 <appeared-in>1.3.1</appeared-in>
566
f8148fc88224 Documented 1.2.2 changes.
Ruslan Ermilov <ru@nginx.com>
parents: 542
diff changeset
358 <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
359
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
360 <para>
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
361 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
362 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
363 taking into account weights of servers.
533
fb630c3c5039 Revamped the upstream documentation somewhat.
Ruslan Ermilov <ru@nginx.com>
parents: 526
diff changeset
364 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
365 weighted round-robin balancing method.
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
366 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
367
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
368 </directive>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
369
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
370 </section>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
371
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 <section id="variables" name="Embedded Variables">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
374
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
375 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
376 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
377 supports the following embedded variables:
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
378 <list type="tag">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
379
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
380 <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
381 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
382 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
383 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
384 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
385 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
386 “<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
387 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
388 using
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
389 <header>X-Accel-Redirect</header> or
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
390 <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
391 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
392 “<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
393 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
394
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
395 <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
396 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
397 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
398 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
399 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
400
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
401 <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
402 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
403 keeps servers response codes.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
404 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
405 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
406
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
407 <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
408 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
409 keep server response header fields.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
410 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
411 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
412 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
413 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
414
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
415 </list>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
416 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
417
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
418 </section>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
419
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
420 </module>