Mercurial > hg > nginx-site
annotate xml/cn/docs/http/ngx_http_proxy_module.xml @ 3020:61996cb486f9
Reordered and added to toc fs methods in njs Reference.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Mon, 23 Oct 2023 19:23:28 +0100 |
parents | ceb8a4e374b7 |
children |
rev | line source |
---|---|
792
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1 <?xml version="1.0"?> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
2 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
3 <!-- |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
4 Copyright (C) Igor Sysoev |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
5 Copyright (C) Nginx, Inc. |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
6 --> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
7 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
8 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
9 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
10 <module name="ngx_http_proxy_module 模块" |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
11 link="/cn/docs/http/ngx_http_proxy_module.html" |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
12 lang="cn" |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
13 translator="cfsego" |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
14 rev="1"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
15 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
16 <section id="summary"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
17 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
18 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
19 <literal>ngx_http_proxy_module</literal> 模块允许传送请求到其它服务器。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
20 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
21 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
22 </section> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
23 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
24 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
25 <section id="example" name="配置示例"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
26 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
27 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
28 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
29 location / { |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
30 proxy_pass http://localhost:8000; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
31 proxy_set_header Host $host; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
32 proxy_set_header X-Real-IP $remote_addr; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
33 } |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
34 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
35 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
36 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
37 </section> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
38 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
39 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
40 <section id="directives" name="指令"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
41 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
42 <directive name="proxy_buffer_size"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
43 <syntax><value>size</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
44 <default>4k|8k</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
45 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
46 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
47 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
48 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
49 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
50 设置缓冲区的大小为<value>size</value>。nginx从被代理的服务器读取响应时,使用该缓冲区保存响应的开始部分。这部分通常包含着一个小小的响应头。该缓冲区大小默认等于<link id="proxy_buffers"/>指令设置的一块缓冲区的大小,但它也可以被设置得更小。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
51 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
52 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
53 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
54 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
55 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
56 <directive name="proxy_buffering"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
57 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
58 <default>on</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
59 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
60 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
61 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
62 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
63 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
64 代理的时候,开启或关闭缓冲后端服务器的响应。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
65 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
66 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
67 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
68 当开启缓冲时,nginx尽可能快地从被代理的服务器接收响应,再将它存入<link id="proxy_buffer_size"/>和<link id="proxy_buffers"/>指令设置的缓冲区中。如果响应无法整个纳入内存,那么其中一部分将存入磁盘上的<link id="proxy_temp_path">临时文件</link>。<link id="proxy_max_temp_file_size"/>和<link id="proxy_temp_file_write_size"/>指令可以控制临时文件的写入。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
69 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
70 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
71 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
72 当关闭缓冲时,收到响应后,nginx立即将其同步传给客户端。nginx不会尝试从被代理的服务器读取整个请求,而是将<link id="proxy_buffer_size"/>指令设定的大小作为一次读取的最大长度。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
73 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
74 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
75 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
76 响应头<header>X-Accel-Buffering</header>传递“<literal>yes</literal>”或“<literal>no</literal>”可以动态地开启或关闭代理的缓冲功能。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
77 这个能力可以通过<link doc="ngx_http_proxy_module.xml" id="proxy_ignore_headers"/>指令关闭。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
78 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
79 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
80 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
81 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
82 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
83 <directive name="proxy_buffers"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
84 <syntax><value>number</value> <value>size</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
85 <default>8 4k|8k</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
86 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
87 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
88 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
89 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
90 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
91 为每个连接设置缓冲区的数量为<value>number</value>,每块缓冲区的大小为<value>size</value>。这些缓冲区用于保存从被代理的服务器读取的响应。每块缓冲区默认等于一个内存页的大小。这个值是4K还是8K,取决于平台。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
92 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
93 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
94 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
95 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
96 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
97 <directive name="proxy_busy_buffers_size"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
98 <syntax><value>size</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
99 <default>8k|16k</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
100 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
101 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
102 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
103 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
104 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
105 当开启<link id="proxy_buffering">缓冲</link>响应的功能以后,在没有读到全部响应的情况下,写缓冲到达一定<value>大小</value>时,nginx一定会向客户端发送响应,直到缓冲小于此值。这条指令用来设置此值。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
106 同时,剩余的缓冲区可以用于接收响应,如果需要,一部分内容将缓冲到临时文件。该<value>大小</value>默认是<link id="proxy_buffer_size"/>和<link id="proxy_buffers"/>指令设置单块缓冲大小的两倍。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
107 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
108 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
109 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
110 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
111 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
112 <directive name="proxy_cache"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
113 <syntax><value>zone</value> | <literal>off</literal></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
114 <default>off</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
115 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
116 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
117 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
118 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
119 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
120 指定用于页面缓存的共享内存。同一块共享内存可以在多个地方使用。<literal>off</literal>参数可以屏蔽从上层配置继承的缓存功能。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
121 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
122 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
123 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
124 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
125 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
126 <directive name="proxy_cache_bypass"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
127 <syntax><value>string</value> ...</syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
128 <default/> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
129 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
130 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
131 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
132 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
133 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
134 定义nginx不从缓存取响应的条件。如果至少一个字符串条件非空而且非“0”,nginx就不会从缓存中去取响应: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
135 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
136 proxy_cache_bypass $cookie_nocache $arg_nocache$arg_comment; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
137 proxy_cache_bypass $http_pragma $http_authorization; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
138 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
139 本指令可和与<link id="proxy_no_cache"/>一起使用。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
140 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
141 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
142 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
143 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
144 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
145 <directive name="proxy_cache_key"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
146 <syntax><value>string</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
147 <default>$scheme$proxy_host$request_uri</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
148 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
149 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
150 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
151 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
152 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
153 定义如何生成缓存的键,比如 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
154 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
155 proxy_cache_key "$host$request_uri $cookie_user"; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
156 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
157 这条指令的默认值类似于下面字符串 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
158 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
159 proxy_cache_key $scheme$proxy_host$uri$is_args$args; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
160 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
161 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
162 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
163 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
164 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
165 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
166 <directive name="proxy_cache_lock"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
167 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
168 <default>off</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
169 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
170 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
171 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
172 <appeared-in>1.1.12</appeared-in> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
173 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
174 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
175 开启此功能时,对于相同的请求,同时只允许一个请求发往后端,并根据<link id="proxy_cache_key"/>指令的设置在缓存中植入一个新条目。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
176 其他请求相同条目的请求将一直等待,直到缓存中出现相应的内容,或者锁在<link id="proxy_cache_lock_timeout"/>指令设置的超时后被释放。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
177 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
178 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
179 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
180 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
181 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
182 <directive name="proxy_cache_lock_timeout"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
183 <syntax><value>time</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
184 <default>5s</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
185 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
186 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
187 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
188 <appeared-in>1.1.12</appeared-in> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
189 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
190 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
191 为<link id="proxy_cache_lock"/>指令设置锁的超时。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
192 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
193 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
194 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
195 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
196 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
197 <directive name="proxy_cache_min_uses"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
198 <syntax><value>number</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
199 <default>1</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
200 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
201 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
202 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
203 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
204 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
205 设置响应被缓存的最小请求<value>次数</value>。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
206 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
207 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
208 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
209 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
210 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
211 <directive name="proxy_cache_path"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
212 <syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
213 <value>path</value> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
214 [<literal>levels</literal>=<value>levels</value>] |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
215 <literal>keys_zone</literal>=<value>name</value>:<value>size</value> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
216 [<literal>inactive</literal>=<value>time</value>] |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
217 [<literal>max_size</literal>=<value>size</value>] |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
218 [<literal>loader_files</literal>=<value>number</value>] |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
219 [<literal>loader_sleep</literal>=<value>time</value>] |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
220 [<literal>loader_threshold</literal>=<value>time</value>]</syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
221 <default/> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
222 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
223 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
224 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
225 设置缓存的路径和其他参数。缓存数据是保存在文件中的,缓存的键和文件名都是在代理URL上执行MD5的结果。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
226 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
227 <literal>levels</literal>参数定义了缓存的层次结构。比如,下面配置 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
228 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
229 proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=one:10m; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
230 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
231 缓存中文件名看起来是这样的: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
232 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
233 /data/nginx/cache/<emphasis>c</emphasis>/<emphasis>29</emphasis>/b7f54b2df7773722d382f4809d650<emphasis>29c</emphasis> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
234 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
235 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
236 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
237 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
238 被缓存的响应首先写入一个临时文件,然后进行重命名。从0.8.9版本开始,临时文件和缓存可以放在不同的文件系统。但请注意,这将导致文件在这两个文件系统中进行拷贝,而不是廉价的重命名操作。因此,针对任何路径,都建议将缓存和<link id="proxy_temp_path"/>指令设置的临时文件目录放在同一文件系统。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
239 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
240 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
241 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
242 此外,所有活动的键和缓存数据相关的信息都被存放在共享内存中。共享内存通过<literal>keys_zone</literal>参数的<value>name</value>和<value>size</value>来定义。被缓存的数据如果在<literal>inactive</literal>参数指定的时间内未被访问,就会被从缓存中移除,不论它是否是刚产生的。<literal>inactive</literal>的默认值是10分钟。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
243 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
244 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
245 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
246 特殊进程“cache manager”监控缓存的条目数量,如果超过<literal>max_size</literal>参数设置的最大值,使用LRU算法移除缓存数据。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
247 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
248 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
249 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
250 nginx新启动后不就,特殊进程“cache loader”就被启动。该进程将文件系统上保存的过去缓存的数据的相关信息重新加载到共享内存。加载过程分多次迭代完成,每次迭代,进程只加载不多于<literal>loader_files</literal>参数指定的文件数量(默认值为100)。此外,每次迭代过程的持续时间不能超过<literal>loader_threshold</literal>参数的值(默认200毫秒)。每次迭代之间,nginx的暂停时间由<literal>loader_sleep</literal>参数指定(默认50毫秒)。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
251 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
252 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
253 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
254 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
255 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
256 <directive name="proxy_cache_use_stale"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
257 <syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
258 <literal>error</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
259 <literal>timeout</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
260 <literal>invalid_header</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
261 <literal>updating</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
262 <literal>http_500</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
263 <literal>http_502</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
264 <literal>http_503</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
265 <literal>http_504</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
266 <literal>http_404</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
267 <literal>off</literal> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
268 ...</syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
269 <default>off</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
270 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
271 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
272 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
273 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
274 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
275 如果后端服务器出现状况,nginx是可以使用过期的响应缓存的。这条指令就是定义何种条件下允许开启此机制。这条指令的参数与<link id="proxy_next_upstream"/>指令的参数相同。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
276 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
277 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
278 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
279 此外,<literal>updating</literal>参数允许nginx在正在更新缓存的情况下使用过期的缓存作为响应。这样做可以使更新缓存数据时,访问源服务器的次数最少。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
280 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
281 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
282 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
283 在植入新的缓存条目时,如果想使访问源服务器的次数最少,可以使用<link id="proxy_cache_lock"/>指令。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
284 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
285 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
286 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
287 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
288 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
289 <directive name="proxy_cache_valid"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
290 <syntax>[<value>code</value> ...] <value>time</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
291 <default/> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
292 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
293 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
294 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
295 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
296 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
297 为不同的响应状态码设置不同的缓存时间。比如,下面指令 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
298 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
299 proxy_cache_valid 200 302 10m; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
300 proxy_cache_valid 404 1m; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
301 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
302 设置状态码为200和302的响应的缓存时间为10分钟,状态码为404的响应的缓存时间为1分钟。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
303 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
304 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
305 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
306 如果仅仅指定了<value>time</value>, |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
307 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
308 proxy_cache_valid 5m; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
309 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
310 那么只有状态码为200、300和302的响应会被缓存。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
311 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
312 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
313 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
314 如果使用了<literal>any</literal>参数,那么就可以缓存任何响应: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
315 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
316 proxy_cache_valid 200 302 10m; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
317 proxy_cache_valid 301 1h; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
318 proxy_cache_valid any 1m; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
319 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
320 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
321 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
322 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
323 缓存参数也可以直接在响应头中设定。这种方式的优先级高于使用这条指令设置缓存时间。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
324 <header>X-Accel-Expires</header>响应头可以以秒为单位设置响应的缓存时间,如果值为0,表示禁止缓存响应,如果值以<literal>@</literal>开始,表示自1970年1月1日以来的秒数,响应一直会被缓存到这个绝对时间点。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
325 如果不含<header>X-Accel-Expires</header>响应头,缓存参数仍可能被<header>Expires</header>或者<header>Cache-Control</header>响应头设置。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
326 如果响应头含有<header>Set-Cookie</header>,响应将不能被缓存。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
327 这些头的处理过程可以使用指令<link id="proxy_ignore_headers"/>忽略。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
328 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
329 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
330 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
331 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
332 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
333 <directive name="proxy_connect_timeout"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
334 <syntax><value>time</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
335 <default>60s</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
336 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
337 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
338 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
339 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
340 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
341 设置与后端服务器建立连接的超时时间。应该注意这个超时一般不可能大于75秒。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
342 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
343 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
344 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
345 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
346 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
347 <directive name="proxy_cookie_domain"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
348 <syntax><literal>off</literal></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
349 <syntax><value>domain</value> <value>replacement</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
350 <default>off</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
351 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
352 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
353 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
354 <appeared-in>1.1.15</appeared-in> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
355 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
356 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
357 设置<header>Set-Cookie</header>响应头中的<literal>domain</literal>属性的替换文本。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
358 假设后端服务器返回的<header>Set-Cookie</header>响应头含有属性“<literal>domain=localhost</literal>”,那么指令 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
359 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
360 proxy_cookie_domain localhost example.org; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
361 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
362 将这个属性改写为“<literal>domain=example.org</literal>”。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
363 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
364 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
365 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
366 <value>domain</value>和<value>replacement</value>配置字符串,以及<literal>domain</literal>属性中起始的点将被忽略。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
367 匹配过程大小写不敏感。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
368 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
369 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
370 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
371 <value>domain</value>和<value>replacement</value>配置字符串中可以包含变量: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
372 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
373 proxy_cookie_domain www.$host $host; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
374 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
375 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
376 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
377 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
378 这条指令同样可以使用正则表达式。这时,<value>domain</value>应以“<literal>~</literal>”标志开始,且可以使用命名匹配组和位置匹配组,而<value>replacement</value>可以引用这些匹配组: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
379 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
380 proxy_cookie_domain ~\.(?P<sl_domain>[-0-9a-z]+\.[a-z]+)$ $sl_domain; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
381 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
382 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
383 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
384 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
385 可以同时定义多条<literal>proxy_cookie_domain</literal>指令: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
386 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
387 proxy_cookie_domain localhost example.org; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
388 proxy_cookie_domain ~\.([a-z]+\.[a-z]+)$ $1; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
389 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
390 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
391 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
392 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
393 <literal>off</literal>参数可以取消当前配置级别的所有<literal>proxy_cookie_domain</literal>指令: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
394 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
395 proxy_cookie_domain off; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
396 proxy_cookie_domain localhost example.org; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
397 proxy_cookie_domain www.example.org example.org; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
398 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
399 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
400 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
401 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
402 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
403 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
404 <directive name="proxy_cookie_path"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
405 <syntax><literal>off</literal></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
406 <syntax><value>path</value> <value>replacement</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
407 <default>off</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
408 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
409 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
410 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
411 <appeared-in>1.1.15</appeared-in> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
412 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
413 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
414 设置<header>Set-Cookie</header>响应头中的<literal>path</literal>属性的替换文本。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
415 假设后端服务器返回的<header>Set-Cookie</header>响应头含有属性“<literal>path=/two/some/uri/</literal>”,那么指令 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
416 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
417 proxy_cookie_path /two/ /; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
418 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
419 将这个属性改写为“<literal>path=/some/uri/</literal>”。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
420 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
421 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
422 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
423 <value>path</value>和<value>replacement</value>配置字符串可以包含变量: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
424 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
425 proxy_cookie_path $uri /some$uri; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
426 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
427 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
428 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
429 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
430 这条指令同样可以使用正则表达式。如果使用大小写敏感的匹配,<value>path</value>应以“<literal>~</literal>”标志开始,如果使用大小写不敏感的匹配,<value>path</value>应以“<literal>~*</literal>”标志开始。<value>path</value>可以使用命名匹配组和位置匹配组,<value>replacement</value>可以引用这些匹配组: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
431 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
432 proxy_cookie_path ~*^/user/([^/]+) /u/$1; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
433 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
434 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
435 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
436 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
437 可以同时定义多条<literal>proxy_cookie_path</literal>指令: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
438 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
439 proxy_cookie_path /one/ /; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
440 proxy_cookie_path / /two/; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
441 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
442 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
443 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
444 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
445 <literal>off</literal>参数可以取消当前配置级别的所有<literal>proxy_cookie_path</literal>指令: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
446 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
447 proxy_cookie_path off; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
448 proxy_cookie_path /two/ /; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
449 proxy_cookie_path ~*^/user/([^/]+) /u/$1; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
450 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
451 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
452 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
453 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
454 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
455 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
456 <directive name="proxy_hide_header"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
457 <syntax><value>field</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
458 <default/> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
459 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
460 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
461 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
462 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
463 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
464 nginx默认不会将<header>Date</header>、<header>Server</header>、<header>X-Pad</header>,和<header>X-Accel-...</header>响应头发送给客户端。<literal>proxy_hide_header</literal>指令则可以设置额外的响应头,这些响应头也不会发送给客户端。相反的,如果希望允许传递某些响应头给客户端,可以使用<link id="proxy_pass_header"/>指令。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
465 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
466 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
467 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
468 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
469 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
470 <directive name="proxy_http_version"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
471 <syntax><literal>1.0</literal> | <literal>1.1</literal></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
472 <default>1.0</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
473 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
474 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
475 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
476 <appeared-in>1.1.4</appeared-in> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
477 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
478 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
479 设置代理使用的HTTP协议版本。默认使用的版本是1.0,而1.1版本则推荐在使用<link doc="ngx_http_upstream_module.xml" id="keepalive"/>连接时一起使用。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
480 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
481 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
482 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
483 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
484 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
485 <directive name="proxy_ignore_client_abort"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
486 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
487 <default>off</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
488 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
489 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
490 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
491 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
492 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
493 决定当客户端在响应传输完成前就关闭连接时,nginx是否应关闭后端连接。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
494 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
495 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
496 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
497 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
498 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
499 <directive name="proxy_ignore_headers"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
500 <syntax><value>field</value> ...</syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
501 <default/> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
502 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
503 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
504 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
505 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
506 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
507 不处理后端服务器返回的指定响应头。下面的响应头可以被设置: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
508 <header>X-Accel-Redirect</header>,<header>X-Accel-Expires</header>,<header>X-Accel-Limit-Rate</header> (1.1.6),<header>X-Accel-Buffering</header> (1.1.6), |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
509 <header>X-Accel-Charset</header> (1.1.6),<header>Expires</header>,<header>Cache-Control</header>,和<header>Set-Cookie</header> (0.8.44)。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
510 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
511 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
512 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
513 如果不被取消,这些头部的处理可能产生下面结果: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
514 <list type="bullet" compact="no"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
515 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
516 <listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
517 <header>X-Accel-Expires</header>,<header>Expires</header>,<header>Cache-Control</header>,和<header>Set-Cookie</header> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
518 设置响应<link id="proxy_cache_valid">缓存</link>的参数; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
519 </listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
520 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
521 <listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
522 <header>X-Accel-Redirect</header>执行到指定URI的<link doc="ngx_http_core_module.xml" id="internal">内部跳转</link>; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
523 </listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
524 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
525 <listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
526 <header>X-Accel-Limit-Rate</header>设置响应到客户端的传输<link doc="ngx_http_core_module.xml" id="limit_rate">速率限制</link>; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
527 </listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
528 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
529 <listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
530 <header>X-Accel-Buffering</header>启动或者关闭响应<link id="proxy_buffering">缓冲</link>; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
531 </listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
532 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
533 <listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
534 <header>X-Accel-Charset</header>设置响应所需的<link doc="ngx_http_charset_module.xml" id="charset">字符集</link>。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
535 </listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
536 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
537 </list> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
538 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
539 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
540 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
541 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
542 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
543 <directive name="proxy_intercept_errors"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
544 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
545 <default>off</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
546 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
547 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
548 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
549 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
550 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
551 当后端服务器的响应状态码大于等于400时,决定是否直接将响应发送给客户端,亦或将响应转发给nginx由<link doc="ngx_http_core_module.xml" id="error_page"/>指令来处理。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
552 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
553 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
554 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
555 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
556 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
557 <directive name="proxy_max_temp_file_size"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
558 <syntax><value>size</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
559 <default>1024m</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
560 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
561 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
562 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
563 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
564 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
565 打开响应<link id="proxy_buffering">缓冲</link>以后,如果整个响应不能存放在<link id="proxy_buffer_size"/>和<link id="proxy_buffers"/>指令设置的缓冲区内,部分响应可以存放在临时文件中。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
566 这条指令可以设置临时文件的最大<value>容量</value>。而每次写入临时文件的数据量则由<link id="proxy_temp_file_write_size"/>指令定义。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
567 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
568 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
569 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
570 将此值设置为0将禁止响应写入临时文件。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
571 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
572 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
573 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
574 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
575 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
576 <directive name="proxy_next_upstream"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
577 <syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
578 <literal>error</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
579 <literal>timeout</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
580 <literal>invalid_header</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
581 <literal>http_500</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
582 <literal>http_502</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
583 <literal>http_503</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
584 <literal>http_504</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
585 <literal>http_404</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
586 <literal>off</literal> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
587 ...</syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
588 <default>error timeout</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
589 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
590 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
591 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
592 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
593 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
594 指定在何种情况下一个失败的请求应该被发送到下一台后端服务器: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
595 <list type="tag"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
596 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
597 <tag-name><literal>error</literal></tag-name> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
598 <tag-desc>和后端服务器建立连接时,或者向后端服务器发送请求时,或者从后端服务器接收响应头时,出现错误;</tag-desc> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
599 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
600 <tag-name><literal>timeout</literal></tag-name> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
601 <tag-desc>和后端服务器建立连接时,或者向后端服务器发送请求时,或者从后端服务器接收响应头时,出现超时;</tag-desc> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
602 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
603 <tag-name><literal>invalid_header</literal></tag-name> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
604 <tag-desc>后端服务器返回空响应或者非法响应头;</tag-desc> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
605 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
606 <tag-name><literal>http_500</literal></tag-name> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
607 <tag-desc>后端服务器返回的响应状态码为500;</tag-desc> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
608 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
609 <tag-name><literal>http_502</literal></tag-name> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
610 <tag-desc>后端服务器返回的响应状态码为502;</tag-desc> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
611 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
612 <tag-name><literal>http_503</literal></tag-name> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
613 <tag-desc>后端服务器返回的响应状态码为503;</tag-desc> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
614 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
615 <tag-name><literal>http_504</literal></tag-name> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
616 <tag-desc>后端服务器返回的响应状态码为504;</tag-desc> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
617 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
618 <tag-name><literal>http_404</literal></tag-name> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
619 <tag-desc>后端服务器返回的响应状态码为404;</tag-desc> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
620 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
621 <tag-name><literal>off</literal></tag-name> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
622 <tag-desc>停止将请求发送给下一台后端服务器。</tag-desc> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
623 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
624 </list> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
625 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
626 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
627 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
628 需要理解一点的是,只有在没有向客户端发送任何数据以前,将请求转给下一台后端服务器才是可行的。也就是说,如果在传输响应到客户端时出现错误或者超时,这类错误是不可能恢复的。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
629 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
630 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
631 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
632 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
633 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
634 <directive name="proxy_no_cache"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
635 <syntax><value>string</value> ...</syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
636 <default/> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
637 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
638 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
639 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
640 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
641 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
642 定义nginx不将响应写入缓存的条件。如果至少一个字符串条件非空而且非“0”,nginx就不将响应存入缓存: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
643 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
644 proxy_no_cache $cookie_nocache $arg_nocache$arg_comment; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
645 proxy_no_cache $http_pragma $http_authorization; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
646 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
647 这条指令可以和<link id="proxy_cache_bypass"/>指令一起使用。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
648 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
649 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
650 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
651 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
652 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
653 <directive name="proxy_pass"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
654 <syntax><value>URL</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
655 <default/> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
656 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
657 <context>if in location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
658 <context>limit_except</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
659 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
660 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
661 设置后端服务器的协议和地址,还可以设置可选的URI以定义本地路径和后端服务器的映射关系。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
662 这条指令可以设置的协议是“<literal>http</literal>”或者“<literal>https</literal>”,而地址既可以使用域名或者IP地址加端口(可选)的形式来定义: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
663 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
664 proxy_pass http://localhost:8000/uri/; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
665 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
666 又可以使用UNIX域套接字路径来定义。该路径接在“<literal>unix</literal>”字符串后面,两端由冒号所包围,比如: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
667 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
668 proxy_pass http://unix:/tmp/backend.socket:/uri/; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
669 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
670 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
671 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
672 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
673 如果解析一个域名得到多个地址,所有的地址都会以轮转的方式被使用。当然,也可以使用<link doc="ngx_http_upstream_module.xml">服务器组</link>来定义地址。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
674 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
675 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
676 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
677 请求URI按下面规则传送给后端服务器: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
678 <list type="bullet" compact="no"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
679 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
680 <listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
681 如果<literal>proxy_pass</literal>使用了URI,当传送请求到后端服务器时,<link doc="ngx_http_core_module.xml" id="location">规范化</link>以后的请求路径与配置中的路径的匹配部分将被替换为指令中定义的URI: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
682 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
683 location /name/ { |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
684 proxy_pass http://127.0.0.1/remote/; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
685 } |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
686 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
687 </listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
688 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
689 <listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
690 如果<literal>proxy_pass</literal>没有使用URI,传送到后端服务器的请求URI一般客户端发起的原始URI,如果nginx改变了请求URI,则传送的URI是nginx改变以后完整的规范化URI: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
691 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
692 location /some/path/ { |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
693 proxy_pass http://127.0.0.1; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
694 } |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
695 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
696 <note> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
697 在1.1.12版以前,如果<literal>proxy_pass</literal>没有使用URI,某些情况下,nginx改变URI以后,会错误地将原始URI而不是改变以后的URI发送到后端服务器。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
698 </note> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
699 </listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
700 </list> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
701 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
702 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
703 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
704 某些情况下,无法确定请求URI中应该被替换的部分: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
705 <list type="bullet" compact="no"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
706 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
707 <listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
708 使用正则表达式定义路径。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
709 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
710 这种情况下,指令不应该使用URI。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
711 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
712 </listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
713 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
714 <listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
715 在需要代理的路径中,使用<link doc="ngx_http_rewrite_module.xml" id="rewrite"/>指令改变了URI,但仍使用相同配置处理请求(<literal>break</literal>): |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
716 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
717 location /name/ { |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
718 rewrite /name/([^/]+) /users?name=$1 break; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
719 proxy_pass http://127.0.0.1; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
720 } |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
721 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
722 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
723 这种情况下,本指令设置的URI会被忽略,改变后的URI将被发送给后端服务器。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
724 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
725 </listitem> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
726 </list> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
727 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
728 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
729 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
730 后端服务器的地址,端口和URI中都可以使用变量: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
731 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
732 proxy_pass http://$host$uri; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
733 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
734 甚至像这样: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
735 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
736 proxy_pass $request; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
737 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
738 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
739 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
740 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
741 这种情况下,后端服务器的地址将会在定义的<link doc="ngx_http_upstream_module.xml">服务器组</link>中查找。如果查找不到,nginx使用<link doc="ngx_http_core_module.xml" id="resolver"/>来查找该地址。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
742 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
743 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
744 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
745 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
746 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
747 <directive name="proxy_pass_header"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
748 <syntax><value>field</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
749 <default/> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
750 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
751 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
752 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
753 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
754 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
755 允许传送<link id="proxy_hide_header">被屏蔽</link>的后端服务器响应头到客户端。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
756 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
757 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
758 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
759 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
760 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
761 <directive name="proxy_read_timeout"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
762 <syntax><value>time</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
763 <default>60s</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
764 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
765 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
766 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
767 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
768 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
769 定义从后端服务器读取响应的超时。此超时是指相邻两次读操作之间的最长时间间隔,而不是整个响应传输完成的最长时间。如果后端服务器在超时时间段内没有传输任何数据,连接将被关闭。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
770 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
771 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
772 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
773 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
774 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
775 <directive name="proxy_redirect"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
776 <syntax><literal>default</literal></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
777 <syntax><literal>off</literal></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
778 <syntax><value>redirect</value> <value>replacement</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
779 <default>default</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
780 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
781 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
782 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
783 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
784 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
785 设置后端服务器<header>Location</header>响应头和<header>Refresh</header>响应头的替换文本。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
786 假设后端服务器返回的响应头是 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
787 “<literal>Location: http://localhost:8000/two/some/uri/</literal>”,那么指令 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
788 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
789 proxy_redirect http://localhost:8000/two/ http://frontend/one/; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
790 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
791 将把字符串改写为 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
792 “<literal>Location: http://frontend/one/some/uri/</literal>”。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
793 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
794 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
795 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
796 <value>replacement</value>字符串可以省略服务器名: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
797 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
798 proxy_redirect http://localhost:8000/two/ /; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
799 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
800 此时将使用代理服务器的主域名和端口号来替换。如果端口是80,可以不加。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
801 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
802 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
803 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
804 用<literal>default</literal>参数指定的默认替换使用了<link doc="ngx_http_core_module.xml" id="location"/>和<link id="proxy_pass"/>指令的参数。因此,下面两例配置等价: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
805 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
806 location /one/ { |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
807 proxy_pass http://upstream:port/two/; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
808 proxy_redirect default; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
809 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
810 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
811 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
812 location /one/ { |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
813 proxy_pass http://upstream:port/two/; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
814 proxy_redirect http://upstream:port/two/ /one/; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
815 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
816 而且因为同样的原因,<link id="proxy_pass"/>指令使用变量时,不允许本指令使用<literal>default</literal>参数。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
817 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
818 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
819 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
820 <value>replacement</value>字符串可以包含变量: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
821 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
822 proxy_redirect http://localhost:8000/ http://$host:$server_port/; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
823 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
824 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
825 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
826 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
827 而<value>redirect</value>字符串从1.1.11版本开始也可以包含变量: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
828 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
829 proxy_redirect http://$proxy_host:8000/ /; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
830 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
831 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
832 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
833 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
834 同时,从1.1.11版本开始,指令支持正则表达式。使用正则表达式的话,如果是大小写敏感的匹配,<value>redirect</value>以“<literal>~</literal>”作为开始,如果是大小写不敏感的匹配,<value>redirect</value>以“<literal>~*</literal>”作为开始。而且<value>redirect</value>的正则表达式中可以包含命名匹配组和位置匹配组,而在<value>replacement</value>中可以引用这些匹配组的值: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
835 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
836 proxy_redirect ~^(http://[^:]+):\d+(/.+)$ $1$2; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
837 proxy_redirect ~*/user/([^/]+)/(.+)$ http://$1.example.com/$2; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
838 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
839 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
840 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
841 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
842 除此以外,可以同时定义多个<literal>proxy_redirect</literal>指令: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
843 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
844 proxy_redirect default; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
845 proxy_redirect http://localhost:8000/ /; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
846 proxy_redirect http://www.example.com/ /; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
847 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
848 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
849 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
850 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
851 另外,<literal>off</literal>参数可以使所有相同配置级别的<literal>proxy_redirect</literal>指令无效: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
852 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
853 proxy_redirect off; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
854 proxy_redirect default; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
855 proxy_redirect http://localhost:8000/ /; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
856 proxy_redirect http://www.example.com/ /; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
857 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
858 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
859 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
860 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
861 最后,使用这条指令也可以为地址为相对地址的重定向添加域名: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
862 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
863 proxy_redirect / /; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
864 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
865 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
866 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
867 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
868 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
869 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
870 <directive name="proxy_send_timeout"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
871 <syntax><value>time</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
872 <default>60s</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
873 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
874 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
875 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
876 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
877 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
878 定义向后端服务器传输请求的超时。此超时是指相邻两次写操作之间的最长时间间隔,而不是整个请求传输完成的最长时间。如果后端服务器在超时时间段内没有接收到任何数据,连接将被关闭。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
879 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
880 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
881 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
882 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
883 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
884 <directive name="proxy_set_header"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
885 <syntax><value>field</value> <value>value</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
886 <default>Host $proxy_host</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
887 <default>Connection close</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
888 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
889 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
890 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
891 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
892 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
893 允许重新定义或者添加发往后端服务器的请求头。<value>value</value>可以包含文本、变量或者它们的组合。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
894 当且仅当当前配置级别中没有定义<literal>proxy_set_header</literal>指令时,会从上面的级别继承配置。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
895 默认情况下,只有两个请求头会被重新定义: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
896 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
897 proxy_set_header Host $proxy_host; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
898 proxy_set_header Connection close; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
899 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
900 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
901 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
902 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
903 如果不想改变请求头<header>Host</header>的值,可以这样来设置: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
904 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
905 proxy_set_header Host $http_host; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
906 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
907 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
908 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
909 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
910 但是,如果客户端请求头中没有携带这个头部,那么传递到后端服务器的请求也不含这个头部。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
911 这种情况下,更好的方式是使用<var>$host</var>变量——它的值在请求包含<header>Host</header>请求头时为<header>Host</header>字段的值,在请求未携带<header>Host</header>请求头时为虚拟主机的主域名: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
912 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
913 proxy_set_header Host $host; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
914 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
915 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
916 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
917 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
918 此外,服务器名可以和后端服务器的端口一起传送: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
919 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
920 proxy_set_header Host $host:$proxy_port; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
921 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
922 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
923 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
924 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
925 如果某个请求头的值为空,那么这个请求头将不会传送给后端服务器: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
926 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
927 proxy_set_header Accept-Encoding ""; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
928 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
929 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
930 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
931 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
932 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
933 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
934 <directive name="proxy_ssl_session_reuse"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
935 <syntax><literal>on</literal> | <literal>off</literal></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
936 <default>on</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
937 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
938 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
939 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
940 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
941 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
942 决定是否重用与后端服务器的SSL会话。如果日志中出现“<literal>SSL3_GET_FINISHED:digest check failed</literal>”错误,请尝试关闭会话重用。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
943 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
944 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
945 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
946 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
947 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
948 <directive name="proxy_store"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
949 <syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
950 <literal>on</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
951 <literal>off</literal> | |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
952 <value>string</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
953 <default>off</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
954 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
955 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
956 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
957 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
958 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
959 开启将文件保存到磁盘上的功能。如果设置为<literal>on</literal>,nginx将文件保存在<link doc="ngx_http_core_module.xml" id="alias"/>指令或<link doc="ngx_http_core_module.xml" id="root"/>指令设置的路径中。如果设置为<literal>off</literal>,nginx将关闭文件保存的功能。此外,保存的文件名也可以使用含变量的<value>string</value>参数来指定: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
960 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
961 proxy_store /data/www$original_uri; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
962 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
963 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
964 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
965 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
966 保存文件的修改时间根据接收到的<header>Last-Modified</header>响应头来设置。响应都是先写到临时文件,然后进行重命名来生成的。从0.8.9版本开始,临时文件和持久化存储可以放在不同的文件系统,但是需要注意这时文件执行的是在两个文件系统间拷贝操作,而不是廉价的重命名操作。因此建议保存文件的路径和<link id="proxy_temp_path"/>指令设置的临时文件的路径在同一个文件系统中。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
967 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
968 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
969 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
970 这条指令可以用于创建静态无更改文件的本地拷贝,比如: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
971 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
972 location /images/ { |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
973 root /data/www; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
974 open_file_cache_errors off; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
975 error_page 404 = /fetch$uri; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
976 } |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
977 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
978 location /fetch/ { |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
979 internal; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
980 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
981 proxy_pass http://backend/; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
982 proxy_store on; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
983 proxy_store_access user:rw group:rw all:r; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
984 proxy_temp_path /data/temp; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
985 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
986 alias /data/www/; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
987 } |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
988 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
989 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
990 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
991 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
992 或者像这样: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
993 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
994 location /images/ { |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
995 root /data/www; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
996 error_page 404 = @fetch; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
997 } |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
998 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
999 location @fetch { |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1000 internal; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1001 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1002 proxy_pass http://backend; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1003 proxy_store on; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1004 proxy_store_access user:rw group:rw all:r; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1005 proxy_temp_path /data/temp; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1006 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1007 root /data/www; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1008 } |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1009 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1010 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1011 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1012 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1013 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1014 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1015 <directive name="proxy_store_access"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1016 <syntax><value>users</value>:<value>permissions</value> ...</syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1017 <default>user:rw</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1018 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1019 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1020 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1021 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1022 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1023 设置新创建的文件和目录的访问权限,比如: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1024 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1025 proxy_store_access user:rw group:rw all:r; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1026 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1027 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1028 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1029 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1030 如果指定了任何<literal>group</literal>或者<literal>all</literal>的访问权限,那么可以略去<literal>user</literal>的访问权限: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1031 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1032 proxy_store_access group:rw all:r; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1033 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1034 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1035 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1036 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1037 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1038 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1039 <directive name="proxy_temp_file_write_size"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1040 <syntax><value>size</value></syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1041 <default>8k|16k</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1042 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1043 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1044 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1045 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1046 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1047 在开启缓冲后端服务器响应到临时文件的功能后,设置nginx每次写数据到临时文件的<value>size(大小)</value>限制。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1048 <value>size</value>的默认值是<link id="proxy_buffer_size"/>指令和<link id="proxy_buffers"/>指令定义的每块缓冲区大小的两倍, |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1049 而临时文件最大容量由<link id="proxy_max_temp_file_size"/>指令设置。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1050 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1051 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1052 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1053 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1054 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1055 <directive name="proxy_temp_path"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1056 <syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1057 <value>path</value> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1058 [<value>level1</value> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1059 [<value>level2</value> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1060 [<value>level3</value>]]]</syntax> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1061 <default>proxy_temp</default> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1062 <context>http</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1063 <context>server</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1064 <context>location</context> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1065 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1066 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1067 定义从后端服务器接收的临时文件的存放路径,可以为临时文件路径定义至多三层子目录的目录树。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1068 比如,下面配置 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1069 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1070 proxy_temp_path /spool/nginx/proxy_temp 1 2; |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1071 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1072 那么临时文件的路径看起来会是这样: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1073 <example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1074 /spool/nginx/proxy_temp/<emphasis>7</emphasis>/<emphasis>45</emphasis>/00000123<emphasis>457</emphasis> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1075 </example> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1076 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1077 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1078 </directive> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1079 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1080 </section> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1081 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1082 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1083 <section id="variables" name="内嵌变量"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1084 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1085 <para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1086 <literal>ngx_http_proxy_module</literal>支持内嵌变量,可以用于在<link id="proxy_set_header"/>指令中构造请求头: |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1087 <list type="tag"> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1088 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1089 <tag-name><var>$proxy_host</var></tag-name> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1090 <tag-desc>后端服务器的主机名和端口;</tag-desc> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1091 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1092 <tag-name><var>$proxy_port</var></tag-name> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1093 <tag-desc>后端服务器的端口;</tag-desc> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1094 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1095 <tag-name><var>$proxy_add_x_forwarded_for</var></tag-name> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1096 <tag-desc>将<var>$remote_addr</var>变量值添加在客户端<header>X-Forwarded-For</header>请求头的后面,并以逗号分隔。 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1097 如果客户端请求未携带<header>X-Forwarded-For</header>请求头,<var>$proxy_add_x_forwarded_for</var>变量值将与<var>$remote_addr</var>变量相同。</tag-desc> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1098 </list> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1099 </para> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1100 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1101 </section> |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1102 |
ceb8a4e374b7
Updated the Chinese documentation.
Ruslan Ermilov <ru@nginx.com>
parents:
diff
changeset
|
1103 </module> |