README
1Name
2 nginx_ajp_module - support AJP protocol proxy with Nginx
3
4Synopsis
5 http {
6 upstream tomcats {
7 server 127.0.0.1:8009;
8 keepalive 10;
9 }
10
11 server {
12
13 listen 80;
14
15 location / {
16 ajp_keep_conn on;
17 ajp_pass tomcats;
18 }
19 }
20 }
21
22Description
23 With this module, Nginx can connect to AJP port directly. The motivation
24 of writing these modules is Nginx's high performance and robustness.
25
26Directives
27 ajp_buffers
28 syntax: *ajp_buffers the_number is_size;*
29
30 default: *ajp_buffers 8 4k/8k;*
31
32 context: *http, server, location*
33
34 This directive specifies the number and the size of buffers, into which
35 will be read the response, obtained from the AJP server. By default, the
36 size of one buffer is equal to the size of a page. Depending on platform
37 this is either 4K, 8K or 16K.
38
39 ajp_buffer_size
40 syntax: *ajp_buffer_size the_size;*
41
42 default: *ajp_buffer_size 4k/8k;*
43
44 context: *http, server, location*
45
46 This directive sets the buffer size, into which will be read the first
47 part of the response, obtained from the AJP server.
48
49 In this part of response the small response-header is located, as a
50 rule.
51
52 By default, the buffersize is equal to the size of one buffer in
53 directive "ajp_buffers"; however, it is possible to set it to less.
54
55 ajp_cache
56 syntax: *ajp_cache zone;*
57
58 default: *off*
59
60 context: *http, server, location*
61
62 The directive specifies the area which actually is the share memory's
63 name for caching. The same area can be used in several places. You must
64 set the "ajp_cache_path" first.
65
66 ajp_cache_key
67 syntax: *ajp_cache_key line;*
68
69 default: *none*
70
71 context: *http, server, location*
72
73 The directive specifies what information is included in the key for
74 caching, for example
75
76 ajp_cache_key "$host$request_uri$cookie_user";
77
78 Note that by default, the hostname of the server is not included in the
79 cache key. If you are using subdomains for different locations on your
80 website, you need to include it, e.g. by changing the cache key to
81 something like
82
83 ajp_cache_key "$scheme$host$request_uri";
84
85 ajp_cache_methods
86 syntax: *ajp_cache_methods [GET HEAD POST];*
87
88 default: *ajp_cache_methods GET HEAD;*
89
90 context: *main,http,location*
91
92 GET/HEAD is syntax sugar, i.e. you can not disable GET/HEAD even if you
93 set just
94
95 ajp_cache_methods POST;
96
97 ajp_cache_min_uses
98 syntax: *ajp_cache_min_uses n;*
99
100 default: *ajp_cache_min_uses 1;*
101
102 context: *http, server, location*
103
104 Sets the number of requests after which the response will be cached.
105
106 ajp_cache_path
107 syntax: *ajp_cache_path /path/to/cache [levels=m:n keys_zone=name:time
108 inactive=time clean_time=time];*
109
110 default: *none*
111
112 context: *http, server, location*
113
114 This directive sets the cache path and other cache parameters. Cached
115 data stored in files. Key and filename in cache is md5 of proxied URL.
116 Levels parameter set number of subdirectories in cache, for example for:
117
118 ajp_cache_path /data/nginx/cache levels=1:2 keys_zone=one:10m;
119
120 file names will be like:
121
122 /data/nginx/cache/c/29/b7f54b2df7773722d382f4809d65029c
123
124 ajp_cache_use_stale
125 syntax: *ajp_cache_use_stale
126 [updating|error|timeout|invalid_header|http_500];*
127
128 default: *ajp_cache_use_stale off;*
129
130 context: *http, server, location*
131
132 If an error occurs while working with the AJP server it is possible to
133 use a stale cached response. This directives determines in which cases
134 it is permitted. The directive’s parameters match those of the
135 "ajp_next_upstream" directive.
136
137 Additionally, the updating parameter permits to use a stale cached
138 response if it is currently being updated. This allows to minimize the
139 number of accesses to AJP servers when updating cached data.
140
141 ajp_cache_valid
142 syntax: *ajp_cache_valid [http_error_code|time];*
143
144 default: *none*
145
146 context: *http, server, location*
147
148 Sets caching time for different response codes. For example, the
149 following directives
150
151 ajp_cache_valid 200 302 10m;
152 ajp_cache_valid 404 1m;
153
154 set 10 minutes of caching for responses with codes 200 and 302, and 1
155 minute for responses with code 404.
156
157 If only caching time is specified
158
159 ajp_cache_valid 5m;
160
161 then only 200, 301, and 302 responses are cached.
162
163 In addition, it can be specified to cache any responses using the any
164 parameter:
165
166 ajp_cache_valid 200 302 10m;
167 ajp_cache_valid 301 1h;
168 ajp_cache_valid any 1m;
169
170 Parameters of caching can also be set directly in the response header.
171 This has a higher precedence than setting of caching time using the
172 directive. The “X-Accel-Expires” header field sets caching time of a
173 response in seconds. The value 0 disables to cache a response. If a
174 value starts with the prefix @, it sets an absolute time in seconds
175 since Epoch, up to which the response may be cached. If header does not
176 include the “X-Accel-Expires” field, parameters of caching may be
177 set in the header fields “Expires” or “Cache-Control”. If a
178 header includes the “Set-Cookie” field, such a response will not be
179 cached. Processing of one or more of these response header fields can be
180 disabled using the "ajp_ignore_headers" directive.
181
182 ajp_connect_timeout
183 syntax: *ajp_connect_timeout time;*
184
185 default: *ajp_connect_timeout 60s;*
186
187 context: *http, server, location*
188
189 This directive assigns a timeout for the connection to the upstream
190 server. It is necessary to keep in mind that this time out cannot be
191 more than 75 seconds.
192
193 This is not the time until the server returns the pages, this is the
194 ajp_read_timeout statement. If your upstream server is up, but hanging
195 (e.g. it does not have enough threads to process your request so it puts
196 you in the pool of connections to deal with later), then this statement
197 will not help as the connection to the server has been made.
198
199 ajp_header_packet_buffer_size
200 syntax: *ajp_header packet_buffer_size;*
201
202 default: *ajp_header_packet_buffer_size 8k;*
203
204 context: *http, server, location*
205
206 Set the buffer size of Forward Request packet. The range is (0, 2^16).
207
208 ajp_hide_header
209 syntax: *ajp_hide_header name;*
210
211 context: *http, server, location*
212
213 By default, Nginx does not pass headers "Status" and "X-Accel-..." from
214 the AJP process back to the client. This directive can be used to hide
215 other headers as well.
216
217 If the headers "Status" and "X-Accel-..." must be provided, then it is
218 necessary to use directive ajp_pass_header to force them to be returned
219 to the client.
220
221 ajp_ignore_headers
222 syntax: *ajp_ignore_headers name [name ...];*
223
224 default: *none*
225
226 context: *http, server, location*
227
228 This directive(0.7.54+) prohibits the processing of the header lines
229 from the proxy server's response.
230
231 It can specify the string as "X-Accel-Redirect", "X-Accel-Expires",
232 "Expires" or "Cache-Control".
233
234 ajp_ignore_client_abort
235 syntax: *ajp_ignore_client_abort on|off;*
236
237 default: *ajp_ignore_client_abort off;*
238
239 context: *http, server, location*
240
241 This directive determines if current request to the AJP-server must be
242 aborted in case the client aborts the request to the server.
243
244 ajp_intercept_errors
245 syntax: *ajp_intercept_errors on|off;*
246
247 default: *ajp_intercept_errors off;*
248
249 context: *http, server, location*
250
251 This directive determines whether or not to transfer 4xx and 5xx errors
252 back to the client or to allow Nginx to answer with directive
253 error_page.
254
255 Note: You need to explicitly define the error_page handler for this for
256 it to be useful. As Igor says, "nginx does not intercept an error if
257 there is no custom handler for it it does not show its default pages.
258 This allows to intercept some errors, while passing others as are."
259
260 ajp_keep_conn
261 syntax: *ajp_keep_conn on|off;*
262
263 default: *ajp_keep_conn off;*
264
265 context: *http, server, location*
266
267 This directive determines whether or not to keep the connection alive
268 with backend server.
269
270 ajp_next_upstream
271 syntax: *ajp_next_upstream
272 [error|timeout|invalid_header|http_500|http_502|http_503|http_504|http_4
273 04|off];*
274
275 default: *ajp_next_upstream error timeout;*
276
277 context: *http, server, location*
278
279 Directive determines, in what cases the request will be transmitted to
280 the next server:
281
282 error — an error has occurred while connecting to the server, sending
283 a request to it, or reading its response;
284 timeout — occurred timeout during the connection with the server,
285 transfer the request or while reading response from the server;
286 invalid_header — server returned a empty or incorrect answer;
287 http_500 — server returned answer with code 500;
288 http_502 — server returned answer with code 502;
289 http_503 — server returned answer with code 503;
290 http_504 — server returned answer with code 504;
291 http_404 — server returned answer with code 404;
292 off — it forbids the request transfer to the next server Transferring
293 the request to the next server is only possible when nothing has been
294 transferred to the client -- that is, if an error or timeout arises in
295 the middle of the transfer of the request, then it is not possible to
296 retry the current request on a different server.
297 ajp_max_data_packet_size
298 syntax: *ajp_max_data_packet_size size;*
299
300 default: *ajp_max_data_packet_size 8k;*
301
302 context: *http, server, location*
303
304 Set the maximum size of AJP's Data packet. The range is [8k, 2^16];
305
306 ajp_max_temp_file_size
307 syntax: *ajp_max_temp_file_size size;*
308
309 default: *ajp_max_temp_file_size 1G;*
310
311 context: *http, server, location, if*
312
313 The maximum size of a temporary file when the content is larger than the
314 proxy buffer. If file is larger than this size, it will be served
315 synchronously from upstream server rather than buffered to disk.
316
317 If ajp_max_temp_file_size is equal to zero, temporary files usage will
318 be disabled.
319
320 ajp_pass
321 syntax: *ajp_pass ajp-server*
322
323 default: *none*
324
325 context: *location, if in location*
326
327 Directive assigns the port or socket on which the AJP-server is
328 listening. Port can be indicated by itself or as an address and port,
329 for example:
330
331 ajp_pass localhost:9000;
332
333 using a Unix domain socket:
334
335 ajp_pass unix:/tmp/ajp.socket;
336
337 You may also use an upstream block.
338
339 upstream backend {
340 server localhost:1234;
341 }
342
343 ajp_pass backend;
344
345 ajp_pass_header
346 syntax: *ajp_pass_header name;*
347
348 context: *http, server, location*
349
350 Permits to pass specific header fields from the AJP server to a client.
351
352 ajp_pass_request_headers
353 syntax: *ajp_pass_request_headers [ on | off ];*
354
355 default: *ajp_pass_request_headers on;*
356
357 context: *http, server, location*
358
359 Permits to pass request header fields from the client to server.
360
361 ajp_pass_request_body
362 syntax: *ajp_pass_request_body [ on | off ] ;*
363
364 default: *ajp_pass_request_body on;*
365
366 context: *http, server, location*
367
368 Permits to pass request body from the client to server.
369
370 ajp_read_timeout
371 syntax: *ajp_read_timeout time;*
372
373 default: *ajp_read_timeout_time 60*
374
375 context: *http, server, location*
376
377 Directive sets the amount of time for upstream to wait for a AJP process
378 to send data. Change this directive if you have long running AJP
379 processes that do not produce output until they have finished
380 processing. If you are seeing an upstream timed out error in the error
381 log, then increase this parameter to something more appropriate.
382
383 ajp_send_lowat
384 syntax: *ajp_send_lowat [ on | off ];*
385
386 default: *ajp_send_lowat off;*
387
388 context: *http, server, location, if*
389
390 This directive set SO_SNDLOWAT. This directive is only available on
391 FreeBSD
392
393 ajp_send_timeout
394 syntax: *ajp_send_timeout time;*
395
396 default: *ajp_send_timeout 60;*
397
398 context: *http, server, location*
399
400 This directive assigns timeout with the transfer of request to the
401 upstream server. Timeout is established not on entire transfer of
402 request, but only between two write operations. If after this time the
403 upstream server will not take new data, then nginx is shutdown the
404 connection.
405
406 ajp_store
407 syntax: *ajp_store [on | off | path] ;*
408
409 default: *ajp_store off;*
410
411 context: *http, server, location*
412
413 This directive sets the path in which upstream files are stored. The
414 parameter "on" preserves files in accordance with path specified in
415 directives *alias* or *root*. The parameter "off" forbids storing.
416 Furthermore, the name of the path can be clearly assigned with the aid
417 of the line with the variables:
418
419 ajp_store /data/www$original_uri;
420
421 The time of modification for the file will be set to the date of
422 "Last-Modified" header in the response. To be able to safe files in this
423 directory it is necessary that the path is under the directory with
424 temporary files, given by directive "ajp_temp_path" for the data
425 location.
426
427 This directive can be used for creating the local copies for dynamic
428 output of the backend which is not very often changed, for example:
429
430 location /images/ {
431 root /data/www;
432 error_page 404 = @fetch;
433 }
434
435 location @fetch {
436 internal;
437 ajp_pass backend;
438 ajp_store on;
439 ajp_store_access user:rw group:rw all:r;
440 ajp_temp_path /data/temp;
441
442 root /data/www;
443 }
444
445 To be clear ajp_store is not a cache, it's rather mirror on demand.
446
447 ajp_store_access
448 syntax: *ajp_store_access users:permissions [users:permission ...];*
449
450 default: *ajp_store_access user:rw;*
451
452 context: *http, server, location*
453
454 This directive assigns the permissions for the created files and
455 directories, for example:
456
457 ajp_store_access user:rw group:rw all:r;
458
459 If any rights for groups or all are assigned, then it is not necessary
460 to assign rights for user:
461
462 ajp_store_access group:rw all:r;
463
464 ajp_temp_path
465 syntax: *ajp_temp_path dir-path [ level1 [ level2 [ level3 ] ] ] ;*
466
467 default: *$NGX_PREFIX/ajp_temp*
468
469 context: *http, server, location*
470
471 This directive works like client_body_temp_path to specify a location to
472 buffer large proxied requests to the filesystem.
473
474 ajp_temp_file_write_size
475 syntax: *ajp_temp_file_write_size size;*
476
477 default: *ajp_temp_file_write_size ["#ajp buffer size"] * 2;*
478
479 context: *http, server, location, if*
480
481 Sets the amount of data that will be flushed to the ajp_temp_path when
482 writing. It may be used to prevent a worker process blocking for too
483 long while spooling data.
484
485Installation
486 Download the latest version of the release tarball of this module from
487 github (<http://github.com/yaoweibin/nginx_ajp_module>)
488
489 Grab the nginx source code from nginx.org (<http://nginx.org/>), for
490 example, the version 1.2.0 (see nginx compatibility), and then build the
491 source with this module:
492
493 $ wget 'http://nginx.org/download/nginx-1.4.4.tar.gz'
494 $ tar -xzvf nginx-1.4.4.tar.gz
495 $ cd nginx-1.4.4/
496 $ ./configure --add-module=/path/to/nginx_ajp_module
497
498 $ make
499 $ make install
500
501Compatibility
502 The master branch is for Nginx-1.1.4+
503 If you want to use it with Nginx-1.0.x, you can use this nginx-1.0
504 (<https://github.com/yaoweibin/nginx_ajp_module/tree/nginx-1.0>) branch.
505TODO
506 SSL
507Known Issues
508 *
509
510Changelogs
511 v0.3
512 remove the jvm_route and keepalive module
513 v0.2
514 bugfix
515 v0.1
516 first release
517Authors
518 Weibin Yao(姚伟斌) *yaoweibin AT gmail DOT com*
519 Jinti Shen(路奇) *jinti.shen AT gmail DOT com*
520 Joshua Zhu(叔度) *zhuzhaoyuan AT gmail DOT com*
521 Simon Liu(雕梁) *simohayha.bobo AT gmail DOT com*
522 Matthew Ma(东坡) *mj19821214 AT gmail DOT com*
523Acknowledgments
524 Thanks 李金虎(beagem@163.com) to improve the keepalive feature with
525 this module.
526License
527 This README template is from agentzh (<http://github.com/agentzh>).
528
529 I borrowed a lot of codes from Fastcgi module of Nginx. This part of
530 code is copyrighted by Igor Sysoev. And the design of apache's
531 mod_ajp_proxy
532 (<http://httpd.apache.org/docs/trunk/mod/mod_proxy_ajp.html>). Thanks
533 for their hard work.
534
535 This module is licensed under the BSD license.
536
537 Redistribution and use in source and binary forms, with or without
538 modification, are permitted provided that the following conditions are
539 met:
540
541 Redistributions of source code must retain the above copyright notice,
542 this list of conditions and the following disclaimer.
543 Redistributions in binary form must reproduce the above copyright
544 notice, this list of conditions and the following disclaimer in the
545 documentation and/or other materials provided with the distribution.
546 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
547 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
548 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
549 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
550 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
551 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
552 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
553 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
554 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
555 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
556 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
557
558
README.markdown
1# Name
2
3__nginx\_ajp\_module__ - support AJP protocol proxy with Nginx
4
5# Synopsis
6
7 http {
8 upstream tomcats {
9 server 127.0.0.1:8009;
10 keepalive 10;
11 }
12
13 server {
14
15 listen 80;
16
17 location / {
18 ajp_keep_conn on;
19 ajp_pass tomcats;
20 }
21 }
22 }
23
24# Description
25
26With this module, Nginx can connect to AJP port directly. The motivation of writing these modules is Nginx's high performance and robustness.
27
28# Directives
29
30## ajp\_buffers
31
32__syntax:__ _ajp\_buffers the\_number is\_size;_
33
34__default:__ _ajp\_buffers 8 4k/8k;_
35
36__context:__ _http, server, location_
37
38This directive specifies the number and the size of buffers, into which will be read the response, obtained from the AJP server. By default, the size of one buffer is equal to the size of a page. Depending on platform this is either 4K, 8K or 16K.
39
40## ajp\_buffer\_size
41
42__syntax:__ _ajp\_buffer\_size the\_size;_
43
44__default:__ _ajp\_buffer\_size 4k/8k;_
45
46__context:__ _http, server, location_
47
48This directive sets the buffer size, into which will be read the first part of the response, obtained from the AJP server.
49
50In this part of response the small response-header is located, as a rule.
51
52By default, the buffersize is equal to the size of one buffer in directive `ajp_buffers`; however, it is possible to set it to less.
53
54## ajp\_cache
55
56__syntax:__ _ajp\_cache zone;_
57
58__default:__ _off_
59
60__context:__ _http, server, location_
61
62The directive specifies the area which actually is the share memory's name for caching. The same area can be used in several places. You must set the `ajp_cache_path` first.
63
64## ajp\_cache\_key
65
66__syntax:__ _ajp\_cache\_key line;_
67
68__default:__ _none_
69
70__context:__ _http, server, location_
71
72The directive specifies what information is included in the key for caching, for example
73
74 ajp_cache_key "$host$request_uri$cookie_user";
75
76Note that by default, the hostname of the server is not included in the cache key. If you are using subdomains for different locations on your website, you need to include it, e.g. by changing the cache key to something like
77
78 ajp_cache_key "$scheme$host$request_uri";
79
80## ajp\_cache\_methods
81
82__syntax:__ _ajp\_cache\_methods \[GET HEAD POST\];_
83
84__default:__ _ajp\_cache\_methods GET HEAD;_
85
86__context:__ _main,http,location_
87
88GET/HEAD is syntax sugar, i.e. you can not disable GET/HEAD even if you set just
89
90 ajp_cache_methods POST;
91
92## ajp\_cache\_min\_uses
93
94__syntax:__ _ajp\_cache\_min\_uses n;_
95
96__default:__ _ajp\_cache\_min\_uses 1;_
97
98__context:__ _http, server, location_
99
100Sets the number of requests after which the response will be cached.
101
102## ajp\_cache\_path
103
104__syntax:__ _ajp\_cache\_path /path/to/cache \[levels=m:n keys\_zone=name:time inactive=time clean\_time=time\];_
105
106__default:__ _none_
107
108__context:__ _http, server, location_
109
110This directive sets the cache path and other cache parameters. Cached data stored in files. Key and filename in cache is md5 of proxied URL. __Levels__ parameter set number of subdirectories in cache, for example for:
111
112 ajp_cache_path /data/nginx/cache levels=1:2 keys_zone=one:10m;
113
114file names will be like:
115
116/data/nginx/cache/c/29/b7f54b2df7773722d382f4809d65029c
117
118## ajp\_cache\_use\_stale
119
120__syntax:__ _ajp\_cache\_use\_stale \[updating|error|timeout|invalid\_header|http\_500\];_
121
122__default:__ _ajp\_cache\_use\_stale off;_
123
124__context:__ _http, server, location_
125
126If an error occurs while working with the AJP server it is possible to use a stale cached response. This directives determines in which cases it is permitted. The directive’s parameters match those of the `ajp_next_upstream` directive.
127
128Additionally, the updating parameter permits to use a stale cached response if it is currently being updated. This allows to minimize the number of accesses to AJP servers when updating cached data.
129
130## ajp\_cache\_valid
131
132__syntax:__ _ajp\_cache\_valid \[http\_error\_code|time\];_
133
134__default:__ _none_
135
136__context:__ _http, server, location_
137
138Sets caching time for different response codes. For example, the following directives
139
140 ajp_cache_valid 200 302 10m;
141 ajp_cache_valid 404 1m;
142
143set 10 minutes of caching for responses with codes 200 and 302, and 1 minute for responses with code 404.
144
145If only caching time is specified
146
147 ajp_cache_valid 5m;
148
149then only 200, 301, and 302 responses are cached.
150
151In addition, it can be specified to cache any responses using the any parameter:
152
153 ajp_cache_valid 200 302 10m;
154 ajp_cache_valid 301 1h;
155 ajp_cache_valid any 1m;
156
157Parameters of caching can also be set directly in the response header. This has a higher precedence than setting of caching time using the directive. The “X-Accel-Expires” header field sets caching time of a response in seconds. The value 0 disables to cache a response. If a value starts with the prefix @, it sets an absolute time in seconds since Epoch, up to which the response may be cached. If header does not include the “X-Accel-Expires” field, parameters of caching may be set in the header fields “Expires” or “Cache-Control”. If a header includes the “Set-Cookie” field, such a response will not be cached. Processing of one or more of these response header fields can be disabled using the `ajp_ignore_headers` directive.
158
159## ajp\_connect\_timeout
160
161__syntax:__ _ajp\_connect\_timeout time;_
162
163__default:__ _ajp\_connect\_timeout 60s;_
164
165__context:__ _http, server, location_
166
167This directive assigns a timeout for the connection to the upstream server. It is necessary to keep in mind that this time out cannot be more than 75 seconds.
168
169This is not the time until the server returns the pages, this is the [ ajp\_read\_timeout](#ajp_read_timeout) statement. If your upstream server is up, but hanging (e.g. it does not have enough threads to process your request so it puts you in the pool of connections to deal with later), then this statement will not help as the connection to the server has been made.
170
171## ajp\_header\_packet\_buffer\_size
172
173__syntax:__ _ajp\_header packet\_buffer\_size;_
174
175__default:__ _ajp\_header\_packet\_buffer\_size 8k;_
176
177__context:__ _http, server, location_
178
179Set the buffer size of Forward Request packet. The range is (0, 2^16).
180
181## ajp\_hide\_header
182
183__syntax:__ _ajp\_hide\_header name;_
184
185__context:__ _http, server, location_
186
187By default, Nginx does not pass headers "Status" and "X-Accel-..." from the AJP process back to the client. This directive can be used to hide other headers as well.
188
189If the headers "Status" and "X-Accel-..." must be provided, then it is necessary to use directive ajp\_pass\_header to force them to be returned to the client.
190
191## ajp\_ignore\_headers
192
193__syntax:__ _ajp\_ignore\_headers name \[name ...\];_
194
195__default:__ _none_
196
197__context:__ _http, server, location_
198
199This directive(0.7.54+) prohibits the processing of the header lines from the proxy server's response.
200
201It can specify the string as "[X-Accel-Redirect](https://metacpan.org/pod/NginxXSendfile)", "X-Accel-Expires", "Expires" or "Cache-Control".
202
203## ajp\_ignore\_client\_abort
204
205__syntax:__ _ajp\_ignore\_client\_abort on|off;_
206
207__default:__ _ajp\_ignore\_client\_abort off;_
208
209__context:__ _http, server, location_
210
211This directive determines if current request to the AJP-server must be aborted in case the client aborts the request to the server.
212
213## ajp\_intercept\_errors
214
215__syntax:__ _ajp\_intercept\_errors on|off;_
216
217__default:__ _ajp\_intercept\_errors off;_
218
219__context:__ _http, server, location_
220
221This directive determines whether or not to transfer 4xx and 5xx errors back to the client or to allow Nginx to answer with directive error\_page.
222
223Note: You need to explicitly define the error\_page handler for this for it to be useful. As Igor says, "nginx does not intercept an error if there is no custom handler for it it does not show its default pages. This allows to intercept some errors, while passing others as are."
224
225## ajp\_keep\_conn
226
227__syntax:__ _ajp\_keep\_conn on|off;_
228
229__default:__ _ajp\_keep\_conn off;_
230
231__context:__ _http, server, location_
232
233This directive determines whether or not to keep the connection alive with backend server.
234
235## ajp\_next\_upstream
236
237__syntax:__ _ajp\_next\_upstream \[error|timeout|invalid\_header|http\_500|http\_502|http\_503|http\_504|http\_404|off\];_
238
239__default:__ _ajp\_next\_upstream error timeout;_
240
241__context:__ _http, server, location_
242
243Directive determines, in what cases the request will be transmitted to the next server:
244
245- error — an error has occurred while connecting to the server, sending a request to it, or reading its response;
246- timeout — occurred timeout during the connection with the server, transfer the request or while reading response from the server;
247- invalid\_header — server returned a empty or incorrect answer;
248- http\_500 — server returned answer with code 500;
249- http\_502 — server returned answer with code 502;
250- http\_503 — server returned answer with code 503;
251- http\_504 — server returned answer with code 504;
252- http\_404 — server returned answer with code 404;
253- off — it forbids the request transfer to the next server Transferring the request to the next server is only possible when nothing has been transferred to the client -- that is, if an error or timeout arises in the middle of the transfer of the request, then it is not possible to retry the current request on a different server.
254
255## ajp\_max\_data\_packet\_size
256
257__syntax:__ _ajp\_max\_data\_packet\_size size;_
258
259__default:__ _ajp\_max\_data\_packet\_size 8k;_
260
261__context:__ _http, server, location_
262
263Set the maximum size of AJP's Data packet. The range is \[8k, 2^16\];
264
265## ajp\_max\_temp\_file\_size
266
267__syntax:__ _ajp\_max\_temp\_file\_size size;_
268
269__default:__ _ajp\_max\_temp\_file\_size 1G;_
270
271__context:__ _http, server, location, if_
272
273The maximum size of a temporary file when the content is larger than the proxy buffer. If file is larger than this size, it will be served synchronously from upstream server rather than buffered to disk.
274
275If ajp\_max\_temp\_file\_size is equal to zero, temporary files usage will be disabled.
276
277## ajp\_pass
278
279__syntax:__ _ajp\_pass ajp-server_
280
281__default:__ _none_
282
283__context:__ _location, if in location_
284
285Directive assigns the port or socket on which the AJP-server is listening. Port can be indicated by itself or as an address and port, for example:
286
287 ajp_pass localhost:9000;
288
289using a Unix domain socket:
290
291 ajp_pass unix:/tmp/ajp.socket;
292
293You may also use an upstream block.
294
295 upstream backend {
296 server localhost:1234;
297 }
298
299 ajp_pass backend;
300
301## ajp\_secret
302
303__syntax:__ _ajp\_secret ajpsecret
304
305__default:__ _none_
306
307Directive assigns the secret of the AJP-server.
308
309## ajp\_pass\_header
310
311__syntax:__ _ajp\_pass\_header name;_
312
313__context:__ _http, server, location_
314
315Permits to pass specific header fields from the AJP server to a client.
316
317## ajp\_pass\_request\_headers
318
319__syntax:__ _ajp\_pass\_request\_headers \[ on | off \];_
320
321__default:__ _ajp\_pass\_request\_headers on;_
322
323__context:__ _http, server, location_
324
325Permits to pass request header fields from the client to server.
326
327## ajp\_pass\_request\_body
328
329__syntax:__ _ajp\_pass\_request\_body \[ on | off \] ;_
330
331__default:__ _ajp\_pass\_request\_body on;_
332
333__context:__ _http, server, location_
334
335Permits to pass request body from the client to server.
336
337## ajp\_read\_timeout
338
339__syntax:__ _ajp\_read\_timeout time;_
340
341__default:__ _ajp\_read\_timeout\_time 60_
342
343__context:__ _http, server, location_
344
345Directive sets the amount of time for upstream to wait for a AJP process to send data. Change this directive if you have long running AJP processes that do not produce output until they have finished processing. If you are seeing an upstream timed out error in the error log, then increase this parameter to something more appropriate.
346
347## ajp\_send\_lowat
348
349__syntax:__ _ajp\_send\_lowat \[ on | off \];_
350
351__default:__ _ajp\_send\_lowat off;_
352
353__context:__ _http, server, location, if_
354
355This directive set SO\_SNDLOWAT. This directive is only available on FreeBSD
356
357## ajp\_send\_timeout
358
359__syntax:__ _ajp\_send\_timeout time;_
360
361__default:__ _ajp\_send\_timeout 60;_
362
363__context:__ _http, server, location_
364
365This directive assigns timeout with the transfer of request to the upstream server. Timeout is established not on entire transfer of request, but only between two write operations. If after this time the upstream server will not take new data, then nginx is shutdown the connection.
366
367## ajp\_store
368
369__syntax:__ _ajp\_store \[on | off | path\] ;_
370
371__default:__ _ajp\_store off;_
372
373__context:__ _http, server, location_
374
375This directive sets the path in which upstream files are stored. The parameter "on" preserves files in accordance with path specified in directives _alias_ or _root_. The parameter "off" forbids storing. Furthermore, the name of the path can be clearly assigned with the aid of the line with the variables:
376
377 ajp_store /data/www$original_uri;
378
379The time of modification for the file will be set to the date of "Last-Modified" header in the response. To be able to safe files in this directory it is necessary that the path is under the directory with temporary files, given by directive `ajp_temp_path` for the data location.
380
381This directive can be used for creating the local copies for dynamic output of the backend which is not very often changed, for example:
382
383 location /images/ {
384 root /data/www;
385 error_page 404 = @fetch;
386 }
387
388 location @fetch {
389 internal;
390 ajp_pass backend;
391 ajp_store on;
392 ajp_store_access user:rw group:rw all:r;
393 ajp_temp_path /data/temp;
394
395 root /data/www;
396 }
397
398To be clear ajp\_store is not a cache, it's rather mirror on demand.
399
400## ajp\_store\_access
401
402__syntax:__ _ajp\_store\_access users:permissions \[users:permission ...\];_
403
404__default:__ _ajp\_store\_access user:rw;_
405
406__context:__ _http, server, location_
407
408This directive assigns the permissions for the created files and directories, for example:
409
410 ajp_store_access user:rw group:rw all:r;
411
412If any rights for groups or all are assigned, then it is not necessary to assign rights for user:
413
414 ajp_store_access group:rw all:r;
415
416## ajp\_temp\_path
417
418__syntax:__ _ajp\_temp\_path dir-path \[ level1 \[ level2 \[ level3 \] \] \] ;_
419
420__default:__ _$NGX\_PREFIX/ajp\_temp_
421
422__context:__ _http, server, location_
423
424This directive works like [client\_body\_temp\_path](https://metacpan.org/pod/NginxHttpCoreModule#client_body_temp_path) to specify a location to buffer large proxied requests to the filesystem.
425
426## ajp\_temp\_file\_write\_size
427
428__syntax:__ _ajp\_temp\_file\_write\_size size;_
429
430__default:__ _ajp\_temp\_file\_write\_size \["#ajp buffer size"\] \* 2;_
431
432__context:__ _http, server, location, if_
433
434Sets the amount of data that will be flushed to the ajp\_temp\_path when writing. It may be used to prevent a worker process blocking for too long while spooling data.
435
436# Installation
437
438Download the latest version of the release tarball of this module from github ([http://github.com/yaoweibin/nginx\_ajp\_module](http://github.com/yaoweibin/nginx_ajp_module))
439
440Grab the nginx source code from nginx.org ([http://nginx.org/](http://nginx.org/)), for example, the version 1.2.0 (see nginx compatibility), and then build the source with this module:
441
442 $ wget 'http://nginx.org/download/nginx-1.4.4.tar.gz'
443 $ tar -xzvf nginx-1.4.4.tar.gz
444 $ cd nginx-1.4.4/
445 $ ./configure --add-module=/path/to/nginx_ajp_module
446
447 $ make
448 $ make install
449
450# Compatibility
451
452- The master branch is for Nginx-1.1.4+
453- If you want to use it with Nginx-1.0.x, you can use this nginx-1.0 ([https://github.com/yaoweibin/nginx\_ajp\_module/tree/nginx-1.0](https://github.com/yaoweibin/nginx_ajp_module/tree/nginx-1.0)) branch.
454
455# TODO
456
457- SSL
458
459# Known Issues
460
461\*
462
463# Changelogs
464
465## v0.3
466
467- remove the jvm\_route and keepalive module
468
469## v0.2
470
471- bugfix
472
473## v0.1
474
475- first release
476
477# Authors
478
479- Weibin Yao(姚伟斌) _yaoweibin AT gmail DOT com_
480- Jinti Shen(路奇) _jinti.shen AT gmail DOT com_
481- Joshua Zhu(叔度) _zhuzhaoyuan AT gmail DOT com_
482- Simon Liu(雕梁) _simohayha.bobo AT gmail DOT com_
483- Matthew Ma(东坡) _mj19821214 AT gmail DOT com_
484
485# Acknowledgments
486
487- Thanks 李金虎(beagem@163.com) to improve the keepalive feature with this module.
488
489# License
490
491This README template is from agentzh ([http://github.com/agentzh](http://github.com/agentzh)).
492
493I borrowed a lot of codes from Fastcgi module of Nginx. This part of code is copyrighted by Igor Sysoev. And the design of apache's mod\_ajp\_proxy ([http://httpd.apache.org/docs/trunk/mod/mod\_proxy\_ajp.html](http://httpd.apache.org/docs/trunk/mod/mod_proxy_ajp.html)). Thanks for their hard work.
494
495This module is licensed under the BSD license.
496
497Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
498
499- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
500- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
501
502THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
503
504# POD ERRORS
505
506Hey! __The above document had some coding errors, which are explained below:__
507
508- Around line 212:
509
510 L<> starts or ends with whitespace
511
README.wiki
1= Name =
2
3'''nginx_ajp_module''' - support AJP protocol proxy with Nginx
4
5= Synopsis =
6
7<geshi lang="nginx">
8
9 http {
10 upstream tomcats {
11 server 127.0.0.1:8009;
12 keepalive 10;
13 }
14
15 server {
16
17 listen 80;
18
19 location / {
20 ajp_keep_conn on;
21 ajp_pass tomcats;
22 }
23 }
24 }
25
26</geshi>
27
28= Description =
29With this module, Nginx can connect to AJP port directly. The motivation of writing these modules is Nginx's high performance and robustness.
30
31= Directives =
32
33== ajp_buffers ==
34
35'''syntax:''' ''ajp_buffers the_number is_size;''
36
37'''default:''' ''ajp_buffers 8 4k/8k;''
38
39'''context:''' ''http, server, location''
40
41This directive specifies the number and the size of buffers, into which will be read the response, obtained from the AJP server. By default, the size of one buffer is equal to the size of a page. Depending on platform this is either 4K, 8K or 16K.
42
43== ajp_buffer_size ==
44
45'''syntax:''' ''ajp_buffer_size the_size;''
46
47'''default:''' ''ajp_buffer_size 4k/8k;''
48
49'''context:''' ''http, server, location''
50
51This directive sets the buffer size, into which will be read the first part of the response, obtained from the AJP server.
52
53In this part of response the small response-header is located, as a rule.
54
55By default, the buffersize is equal to the size of one buffer in directive <code>ajp_buffers</code>; however, it is possible to set it to less.
56
57== ajp_cache ==
58
59'''syntax:''' ''ajp_cache zone;''
60
61'''default:''' ''off''
62
63'''context:''' ''http, server, location''
64
65The directive specifies the area which actually is the share memory's name for caching. The same area can be used in several places. You must set the <code>ajp_cache_path</code> first.
66
67== ajp_cache_key ==
68
69'''syntax:''' ''ajp_cache_key line;''
70
71'''default:''' ''none''
72
73'''context:''' ''http, server, location''
74
75The directive specifies what information is included in the key for caching, for example
76
77<geshi lang="nginx">
78
79 ajp_cache_key "$host$request_uri$cookie_user";
80
81</geshi>
82
83Note that by default, the hostname of the server is not included in the cache key. If you are using subdomains for different locations on your website, you need to include it, e.g. by changing the cache key to something like
84
85<geshi lang="nginx">
86 ajp_cache_key "$scheme$host$request_uri";
87</geshi>
88
89== ajp_cache_methods ==
90
91'''syntax:''' ''ajp_cache_methods [GET HEAD POST];''
92
93'''default:''' ''ajp_cache_methods GET HEAD;''
94
95'''context:''' ''main,http,location''
96
97GET/HEAD is syntax sugar, i.e. you can not disable GET/HEAD even if you set just
98
99<geshi lang="nginx">
100
101 ajp_cache_methods POST;
102
103</geshi>
104
105== ajp_cache_min_uses ==
106
107'''syntax:''' ''ajp_cache_min_uses n;''
108
109'''default:''' ''ajp_cache_min_uses 1;''
110
111'''context:''' ''http, server, location''
112
113Sets the number of requests after which the response will be cached.
114
115== ajp_cache_path ==
116
117'''syntax:''' ''ajp_cache_path /path/to/cache [levels=m:n keys_zone=name:time inactive=time clean_time=time];''
118
119'''default:''' ''none''
120
121'''context:''' ''http, server, location''
122
123This directive sets the cache path and other cache parameters. Cached data stored in files. Key and filename in cache is md5 of proxied URL. '''Levels''' parameter set number of subdirectories in cache, for example for:
124
125<geshi lang="nginx">
126
127 ajp_cache_path /data/nginx/cache levels=1:2 keys_zone=one:10m;
128
129</geshi>
130
131file names will be like:
132
133/data/nginx/cache/c/29/b7f54b2df7773722d382f4809d65029c
134
135== ajp_cache_use_stale ==
136
137'''syntax:''' ''ajp_cache_use_stale [updating|error|timeout|invalid_header|http_500];''
138
139'''default:''' ''ajp_cache_use_stale off;''
140
141'''context:''' ''http, server, location''
142
143If an error occurs while working with the AJP server it is possible to use a stale cached response. This directives determines in which cases it is permitted. The directive’s parameters match those of the <code>ajp_next_upstream</code> directive.
144
145Additionally, the updating parameter permits to use a stale cached response if it is currently being updated. This allows to minimize the number of accesses to AJP servers when updating cached data.
146
147== ajp_cache_valid ==
148
149'''syntax:''' ''ajp_cache_valid [http_error_code|time];''
150
151'''default:''' ''none''
152
153'''context:''' ''http, server, location''
154
155Sets caching time for different response codes. For example, the following directives
156
157<geshi lang="nginx">
158
159 ajp_cache_valid 200 302 10m;
160 ajp_cache_valid 404 1m;
161
162</geshi>
163
164set 10 minutes of caching for responses with codes 200 and 302, and 1 minute for responses with code 404.
165
166If only caching time is specified
167
168<geshi lang="nginx">
169
170 ajp_cache_valid 5m;
171
172</geshi>
173
174then only 200, 301, and 302 responses are cached.
175
176In addition, it can be specified to cache any responses using the any parameter:
177
178<geshi lang="nginx">
179
180 ajp_cache_valid 200 302 10m;
181 ajp_cache_valid 301 1h;
182 ajp_cache_valid any 1m;
183
184</geshi>
185
186Parameters of caching can also be set directly in the response header. This has a higher precedence than setting of caching time using the directive. The “X-Accel-Expires” header field sets caching time of a response in seconds. The value 0 disables to cache a response. If a value starts with the prefix @, it sets an absolute time in seconds since Epoch, up to which the response may be cached. If header does not include the “X-Accel-Expires” field, parameters of caching may be set in the header fields “Expires” or “Cache-Control”. If a header includes the “Set-Cookie” field, such a response will not be cached. Processing of one or more of these response header fields can be disabled using the <code>ajp_ignore_headers</code> directive.
187
188== ajp_connect_timeout ==
189
190'''syntax:''' ''ajp_connect_timeout time;''
191
192'''default:''' ''ajp_connect_timeout 60s;''
193
194'''context:''' ''http, server, location''
195
196This directive assigns a timeout for the connection to the upstream server. It is necessary to keep in mind that this time out cannot be more than 75 seconds.
197
198This is not the time until the server returns the pages, this is the [[#ajp_read_timeout| ajp_read_timeout]] statement. If your upstream server is up, but hanging (e.g. it does not have enough threads to process your request so it puts you in the pool of connections to deal with later), then this statement will not help as the connection to the server has been made.
199
200== ajp_header_packet_buffer_size ==
201
202'''syntax:''' ''ajp_header packet_buffer_size;''
203
204'''default:''' ''ajp_header_packet_buffer_size 8k;''
205
206'''context:''' ''http, server, location''
207
208Set the buffer size of Forward Request packet. The range is (0, 2^16).
209
210== ajp_hide_header ==
211
212'''syntax:''' ''ajp_hide_header name;''
213
214'''context:''' ''http, server, location''
215
216By default, Nginx does not pass headers "Status" and "X-Accel-..." from the AJP process back to the client. This directive can be used to hide other headers as well.
217
218If the headers "Status" and "X-Accel-..." must be provided, then it is necessary to use directive ajp_pass_header to force them to be returned to the client.
219
220== ajp_ignore_headers ==
221
222'''syntax:''' ''ajp_ignore_headers name [name ...];''
223
224'''default:''' ''none''
225
226'''context:''' ''http, server, location''
227
228This directive(0.7.54+) prohibits the processing of the header lines from the proxy server's response.
229
230It can specify the string as "[[NginxXSendfile|X-Accel-Redirect]]", "X-Accel-Expires", "Expires" or "Cache-Control".
231
232== ajp_ignore_client_abort ==
233
234'''syntax:''' ''ajp_ignore_client_abort on|off;''
235
236'''default:''' ''ajp_ignore_client_abort off;''
237
238'''context:''' ''http, server, location''
239
240This directive determines if current request to the AJP-server must be aborted in case the client aborts the request to the server.
241
242== ajp_intercept_errors ==
243
244'''syntax:''' ''ajp_intercept_errors on|off;''
245
246'''default:''' ''ajp_intercept_errors off;''
247
248'''context:''' ''http, server, location''
249
250This directive determines whether or not to transfer 4xx and 5xx errors back to the client or to allow Nginx to answer with directive error_page.
251
252Note: You need to explicitly define the error_page handler for this for it to be useful. As Igor says, "nginx does not intercept an error if there is no custom handler for it it does not show its default pages. This allows to intercept some errors, while passing others as are."
253
254== ajp_keep_conn ==
255
256'''syntax:''' ''ajp_keep_conn on|off;''
257
258'''default:''' ''ajp_keep_conn off;''
259
260'''context:''' ''http, server, location''
261
262This directive determines whether or not to keep the connection alive with backend server.
263
264== ajp_next_upstream ==
265
266'''syntax:''' ''ajp_next_upstream [error|timeout|invalid_header|http_500|http_502|http_503|http_504|http_404|off];''
267
268'''default:''' ''ajp_next_upstream error timeout;''
269
270'''context:''' ''http, server, location''
271
272Directive determines, in what cases the request will be transmitted to the next server:
273
274* error — an error has occurred while connecting to the server, sending a request to it, or reading its response;
275* timeout — occurred timeout during the connection with the server, transfer the request or while reading response from the server;
276* invalid_header — server returned a empty or incorrect answer;
277* http_500 — server returned answer with code 500;
278* http_502 — server returned answer with code 502;
279* http_503 — server returned answer with code 503;
280* http_504 — server returned answer with code 504;
281* http_404 — server returned answer with code 404;
282* off — it forbids the request transfer to the next server Transferring the request to the next server is only possible when nothing has been transferred to the client -- that is, if an error or timeout arises in the middle of the transfer of the request, then it is not possible to retry the current request on a different server.
283
284== ajp_max_data_packet_size ==
285
286'''syntax:''' ''ajp_max_data_packet_size size;''
287
288'''default:''' ''ajp_max_data_packet_size 8k;''
289
290'''context:''' ''http, server, location''
291
292Set the maximum size of AJP's Data packet. The range is [8k, 2^16];
293
294== ajp_max_temp_file_size ==
295
296'''syntax:''' ''ajp_max_temp_file_size size;''
297
298'''default:''' ''ajp_max_temp_file_size 1G;''
299
300'''context:''' ''http, server, location, if''
301
302The maximum size of a temporary file when the content is larger than the proxy buffer. If file is larger than this size, it will be served synchronously from upstream server rather than buffered to disk.
303
304If ajp_max_temp_file_size is equal to zero, temporary files usage will be disabled.
305
306== ajp_pass ==
307
308'''syntax:''' ''ajp_pass ajp-server''
309
310'''default:''' ''none''
311
312'''context:''' ''location, if in location''
313
314Directive assigns the port or socket on which the AJP-server is listening. Port can be indicated by itself or as an address and port, for example:
315
316<geshi lang="nginx">
317
318 ajp_pass localhost:9000;
319
320</geshi>
321
322using a Unix domain socket:
323
324<geshi lang="nginx">
325
326 ajp_pass unix:/tmp/ajp.socket;
327
328</geshi>
329
330You may also use an upstream block.
331
332<geshi lang="nginx">
333
334 upstream backend {
335 server localhost:1234;
336 }
337
338 ajp_pass backend;
339
340</geshi>
341
342== ajp_pass_header ==
343
344'''syntax:''' ''ajp_pass_header name;''
345
346'''context:''' ''http, server, location''
347
348Permits to pass specific header fields from the AJP server to a client.
349
350== ajp_pass_request_headers ==
351
352'''syntax:''' ''ajp_pass_request_headers [ on | off ];''
353
354'''default:''' ''ajp_pass_request_headers on;''
355
356'''context:''' ''http, server, location''
357
358Permits to pass request header fields from the client to server.
359
360== ajp_pass_request_body ==
361
362'''syntax:''' ''ajp_pass_request_body [ on | off ] ;''
363
364'''default:''' ''ajp_pass_request_body on;''
365
366'''context:''' ''http, server, location''
367
368Permits to pass request body from the client to server.
369
370== ajp_read_timeout ==
371
372'''syntax:''' ''ajp_read_timeout time;''
373
374'''default:''' ''ajp_read_timeout_time 60''
375
376'''context:''' ''http, server, location''
377
378Directive sets the amount of time for upstream to wait for a AJP process to send data. Change this directive if you have long running AJP processes that do not produce output until they have finished processing. If you are seeing an upstream timed out error in the error log, then increase this parameter to something more appropriate.
379
380== ajp_send_lowat ==
381
382'''syntax:''' ''ajp_send_lowat [ on | off ];''
383
384'''default:''' ''ajp_send_lowat off;''
385
386'''context:''' ''http, server, location, if''
387
388This directive set SO_SNDLOWAT. This directive is only available on FreeBSD
389
390== ajp_send_timeout ==
391
392'''syntax:''' ''ajp_send_timeout time;''
393
394'''default:''' ''ajp_send_timeout 60;''
395
396'''context:''' ''http, server, location''
397
398This directive assigns timeout with the transfer of request to the upstream server. Timeout is established not on entire transfer of request, but only between two write operations. If after this time the upstream server will not take new data, then nginx is shutdown the connection.
399
400== ajp_store ==
401
402'''syntax:''' ''ajp_store [on | off | path] ;''
403
404'''default:''' ''ajp_store off;''
405
406'''context:''' ''http, server, location''
407
408This directive sets the path in which upstream files are stored. The parameter "on" preserves files in accordance with path specified in directives ''alias'' or ''root''. The parameter "off" forbids storing. Furthermore, the name of the path can be clearly assigned with the aid of the line with the variables:
409
410<geshi lang="nginx">
411 ajp_store /data/www$original_uri;
412</geshi>
413
414The time of modification for the file will be set to the date of "Last-Modified" header in the response. To be able to safe files in this directory it is necessary that the path is under the directory with temporary files, given by directive <code>ajp_temp_path</code> for the data location.
415
416This directive can be used for creating the local copies for dynamic output of the backend which is not very often changed, for example:
417
418<geshi lang="nginx">
419 location /images/ {
420 root /data/www;
421 error_page 404 = @fetch;
422 }
423
424 location @fetch {
425 internal;
426 ajp_pass backend;
427 ajp_store on;
428 ajp_store_access user:rw group:rw all:r;
429 ajp_temp_path /data/temp;
430
431 root /data/www;
432 }
433</geshi>
434
435To be clear ajp_store is not a cache, it's rather mirror on demand.
436
437== ajp_store_access ==
438
439'''syntax:''' ''ajp_store_access users:permissions [users:permission ...];''
440
441'''default:''' ''ajp_store_access user:rw;''
442
443'''context:''' ''http, server, location''
444
445This directive assigns the permissions for the created files and directories, for example:
446
447<geshi lang="nginx">
448 ajp_store_access user:rw group:rw all:r;
449</geshi>
450
451If any rights for groups or all are assigned, then it is not necessary to assign rights for user:
452
453<geshi lang="nginx">
454 ajp_store_access group:rw all:r;
455</geshi>
456
457== ajp_temp_path ==
458
459'''syntax:''' ''ajp_temp_path dir-path [ level1 [ level2 [ level3 ] ] ] ;''
460
461'''default:''' ''$NGX_PREFIX/ajp_temp''
462
463'''context:''' ''http, server, location''
464
465This directive works like [[NginxHttpCoreModule#client_body_temp_path|client_body_temp_path]] to specify a location to buffer large proxied requests to the filesystem.
466
467== ajp_temp_file_write_size ==
468
469'''syntax:''' ''ajp_temp_file_write_size size;''
470
471'''default:''' ''ajp_temp_file_write_size ["#ajp buffer size"] * 2;''
472
473'''context:''' ''http, server, location, if''
474
475Sets the amount of data that will be flushed to the ajp_temp_path when writing. It may be used to prevent a worker process blocking for too long while spooling data.
476
477= Installation =
478
479Download the latest version of the release tarball of this module from [http://github.com/yaoweibin/nginx_ajp_module github]
480
481Grab the nginx source code from [http://nginx.org/ nginx.org], for example, the version 1.2.0 (see nginx compatibility), and then build the source with this module:
482
483<geshi lang="bash">
484 $ wget 'http://nginx.org/download/nginx-1.4.4.tar.gz'
485 $ tar -xzvf nginx-1.4.4.tar.gz
486 $ cd nginx-1.4.4/
487 $ ./configure --add-module=/path/to/nginx_ajp_module
488
489 $ make
490 $ make install
491</geshi>
492
493= Compatibility =
494
495* The master branch is for Nginx-1.1.4+
496* If you want to use it with Nginx-1.0.x, you can use this [https://github.com/yaoweibin/nginx_ajp_module/tree/nginx-1.0 nginx-1.0] branch.
497
498= TODO =
499
500* SSL
501
502= Known Issues =
503
504*
505
506= Changelogs =
507
508== v0.3 ==
509* remove the jvm_route and keepalive module
510
511== v0.2 ==
512* bugfix
513
514== v0.1 ==
515* first release
516
517= Authors =
518
519* Weibin Yao(姚伟斌) ''yaoweibin AT gmail DOT com''
520* Jinti Shen(路奇) ''jinti.shen AT gmail DOT com''
521* Joshua Zhu(叔度) ''zhuzhaoyuan AT gmail DOT com''
522* Simon Liu(雕梁) ''simohayha.bobo AT gmail DOT com''
523* Matthew Ma(东坡) ''mj19821214 AT gmail DOT com''
524
525= Acknowledgments =
526
527* Thanks 李金虎(beagem@163.com) to improve the keepalive feature with this module.
528
529= License =
530
531This README template is from [http://github.com/agentzh agentzh].
532
533I borrowed a lot of codes from Fastcgi module of Nginx. This part of code is copyrighted by Igor Sysoev. And the design of apache's [http://httpd.apache.org/docs/trunk/mod/mod_proxy_ajp.html mod_ajp_proxy]. Thanks for their hard work.
534
535This module is licensed under the BSD license.
536
537Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
538
539* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
540* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
541
542THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
543
544