annotate xml/en/docs/http/ngx_http_upstream_module.xml @ 526:4f907cde0382

1.3.1 changes: ip_hash+weight, least_conn.
author Ruslan Ermilov <ru@nginx.com>
date Tue, 05 Jun 2012 21:42:57 +0000
parents 1fb1c077658b
children fb630c3c5039
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
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
3 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
4
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
5 <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
6 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
7 lang="en">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
8
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
9 <section id="summary">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
10
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
11 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
12 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
13 allows to define groups of servers that can be referenced
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
14 from the <link doc="ngx_http_proxy_module.xml" id="proxy_pass"/> and
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
15 <link doc="ngx_http_fastcgi_module.xml" id="fastcgi_pass"/> directives.
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
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
18 </section>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
19
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
20
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
21 <section id="example" name="Example Configuration">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
22
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 <example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
25 upstream <emphasis>backend</emphasis> {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
26 server backend1.example.com weight=5;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
27 server backend2.example.com:8080;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
28 server unix:/tmp/backend3;
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 server backup1.example.com:8080 backup;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
31 server backup2.example.com:8080 backup;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
32 }
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
33
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
34 server {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
35 location / {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
36 proxy_pass http://<emphasis>backend</emphasis>;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
37 }
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 </example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
40 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
41
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
42 </section>
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 <section id="directives" name="Directives">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
46
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
47 <directive name="ip_hash">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
48 <syntax/>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
49 <default/>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
50 <context>upstream</context>
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 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
53 Specifies that a group should use a balancing method where requests
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
54 are distributed between servers based on client IP addresses.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
55 A class C network containing the client IP address is used as a hashing key.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
56 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
57 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
58 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
59 most probably it will also be the same server.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
60 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
61
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
62 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
63 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
64 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
65 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
66 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
67
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
68 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
69 Example:
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
70 <example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
71 upstream backend {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
72 ip_hash;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
73
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
74 server backend1.example.com;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
75 server backend2.example.com;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
76 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
77 server backend4.example.com;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
78 }
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
79 </example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
80 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
81
526
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
82 <para>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
83 <note>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
84 Until version 1.3.1 it was not possible to specify a weight for
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
85 servers using the <literal>ip_hash</literal> balancing method.
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
86 </note>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
87 </para>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
88
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
89 </directive>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
90
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
91
316
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
92 <directive name="keepalive">
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
93 <syntax><value>connections</value></syntax>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
94 <default/>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
95 <context>upstream</context>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
96 <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
97
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
98 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
99 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
100 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
101
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
102 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
103 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
104 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
105 the cache per one worker process.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
106 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
107 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
108 be closed.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
109 <note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
110 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
111 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
112 process can open to upstream servers.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
113 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
114 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
115 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
116 connections as well.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
117 </note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
118 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
119
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
120 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
121 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
122 <example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
123 upstream memcached_backend {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
124 server 127.0.0.1:11211;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
125 server 10.0.0.2:11211;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
126
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
127 keepalive 32;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
128 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
129
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
130 server {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
131 ...
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
132
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
133 location /memcached/ {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
134 set $memcached_key $uri;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
135 memcached_pass memcached_backend;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
136 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
137
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
138 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
139 </example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
140 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
141
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
142 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
143 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
144 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
145 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
146 <example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
147 upstream http_backend {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
148 server 127.0.0.1:8080;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
149
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
150 keepalive 16;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
151 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
152
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
153 server {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
154 ...
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
155
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
156 location /http/ {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
157 proxy_pass http://http_backend;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
158 proxy_http_version 1.1;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
159 proxy_set_header Connection "";
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
160 ...
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
161 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
162 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
163 </example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
164 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
165
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
166 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
167 <note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
168 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
169 <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
170 though this is not recommended.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
171 </note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
172 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
173
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
174 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
175 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
176 <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
177 for keepalive connections to work:
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
178 <example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
179 upstream fastcgi_backend {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
180 server 127.0.0.1:9000;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
181
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
182 keepalive 8;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
183 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
184
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
185 server {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
186 ...
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
187
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
188 location /fastcgi/ {
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
189 fastcgi_pass fastcgi_backend;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
190 fastcgi_keep_conn on;
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
191 ...
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
192 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
193 }
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
194 </example>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
195 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
196
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
197 <para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
198 <note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
199 When using load balancer modules other than the default
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
200 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
201 the <literal>keepalive</literal> directive.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
202 </note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
203
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
204 <note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
205 SCGI and uwsgi protocols do not define keepalive connections.
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
206 </note>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
207 </para>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
208
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
209 </directive>
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
210
1fb1c077658b Documented the following directives: "keepalive", "proxy_http_version",
Ruslan Ermilov <ru@nginx.com>
parents: 293
diff changeset
211
526
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
212 <directive name="least_conn">
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
213 <syntax/>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
214 <default/>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
215 <context>upstream</context>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
216 <appeared-in>1.3.1</appeared-in>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
217
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
218 <para>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
219 Specifies that a group should use a balancing method where a request
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
220 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
221 taking into account weights of servers.
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
222 If there are several such servers, they are tried in a
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
223 weighted round-robin fashion.
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
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
226 </directive>
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
227
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
228
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
229 <directive name="server">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
230 <syntax><value>name</value> [<value>parameters</value>]</syntax>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
231 <default/>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
232 <context>upstream</context>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
233
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
234 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
235 Sets a <value>name</value> and other <value>parameters</value> of the server.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
236 A <value>name</value> can be a domain name, an address, a port, or a
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
237 path of the UNIX-domain socket.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
238 If a domain name resolves to several addresses, all of them are used.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
239 <list type="tag">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
240
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
241 <tag-name><literal>weight</literal>=<value>number</value></tag-name>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
242 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
243 sets a weight of the server, by default 1.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
244 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
245
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
246 <tag-name><literal>max_fails</literal>=<value>number</value></tag-name>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
247 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
248 sets a number of unsuccessful attempts to communicate with the server
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
249 during a time set by the <literal>fail_timeout</literal> parameter
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
250 after which it will be considered down for a period of time also set
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
251 by the <literal>fail_timeout</literal> parameter.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
252 By default, the number of unsuccessful attempts is set to 1.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
253 A value of zero disables accounting of attempts.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
254 What is considered to be an unsuccessful attempt is configured by the
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
255 <link doc="ngx_http_proxy_module.xml" id="proxy_next_upstream"/>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
256 and <link doc="ngx_http_fastcgi_module.xml" id="fastcgi_next_upstream"/>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
257 directives.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
258 The <literal>http_404</literal> state is not considered
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
259 an unsuccessful attempt.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
260 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
261
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
262 <tag-name><literal>fail_timeout</literal>=<value>time</value></tag-name>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
263 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
264 sets
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
265 <list type="bullet">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
266
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
267 <listitem>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
268 a time during which the specified number of unsuccessful attempts to
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
269 communicate with the server should happen for the server to be
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
270 considered down;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
271 </listitem>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
272
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
273 <listitem>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
274 and a period of time the server will be considered down.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
275 </listitem>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
276
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
277 </list>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
278 By default, timeout is set to 10 seconds.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
279 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
280
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
281 <tag-name><literal>backup</literal></tag-name>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
282 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
283 marks the server as a backup server.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
284 It will be passed requests when the primary servers are down.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
285 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
286
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
287 <tag-name><literal>down</literal></tag-name>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
288 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
289 marks the server as permanently down; used along with
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
290 the <link id="ip_hash"/> directive.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
291 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
292
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
293 </list>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
294 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
295
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
296 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
297 Example:
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
298 <example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
299 upstream backend {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
300 server backend1.example.com weight=5;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
301 server 127.0.0.1:8080 max_fails=3 fail_timeout=30s;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
302 server unix:/tmp/backend3;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
303
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
304 server backup1.example.com:8080 backup;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
305 }
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
306 </example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
307 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
308
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
309 </directive>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
310
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
311
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
312 <directive name="upstream">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
313 <syntax block="yes"><value>name</value></syntax>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
314 <default/>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
315 <context>http</context>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
316
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
317 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
318 Defines a group of servers.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
319 Servers can listen on different ports.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
320 In addition, servers listening on TCP and UNIX-domain sockets
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
321 can be used simultaneously.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
322 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
323
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
324 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
325 Example:
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
326 <example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
327 upstream backend {
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
328 server backend1.example.com weight=5;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
329 server 127.0.0.1:8080 max_fails=3 fail_timeout=30s;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
330 server unix:/tmp/backend3;
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
331 }
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
332 </example>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
333 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
334
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
335 <para>
526
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
336 Requests are distributed between servers in a
4f907cde0382 1.3.1 changes: ip_hash+weight, least_conn.
Ruslan Ermilov <ru@nginx.com>
parents: 316
diff changeset
337 weighted round-robin fashion.
293
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
338 In the above example, each 7 requests will be distributed as follows:
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
339 5 requests to <literal>backend1.example.com</literal>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
340 and one request to each of second and third servers.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
341 If an error occurs when communicating with the server, a request will
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
342 be passed to the next server, and so on until all of the functioning
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
343 servers will be tried.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
344 If a successful response could not be obtained from any of the servers,
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
345 the client will be returned the result of contacting the last server.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
346 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
347
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
348 </directive>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
349
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
350 </section>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
351
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
352
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
353 <section id="variables" name="Embedded Variables">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
354
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
355 <para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
356 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
357 supports the following embedded variables:
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
358 <list type="tag">
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
359
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
360 <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
361 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
362 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
363 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
364 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
365 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
366 “<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
367 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
368 using
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
369 <header>X-Accel-Redirect</header> or
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
370 <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
371 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
372 “<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
373 </tag-desc>
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 <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
376 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
377 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
378 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
379 </tag-desc>
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_status</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 servers response codes.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
384 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
385 </tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
386
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
387 <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
388 <tag-desc>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
389 keep server response header fields.
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
390 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
391 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
392 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
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 </list>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
396 </para>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
397
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
398 </section>
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
399
34246e706f48 English translation of the ngx_http_upstream_module documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
400 </module>