1e18a033bSKonstantin Ananyev
2e18a033bSKonstantin Ananyev/*
3e18a033bSKonstantin Ananyev * Copyright (C) Igor Sysoev
4e18a033bSKonstantin Ananyev * Copyright (C) Nginx, Inc.
5e18a033bSKonstantin Ananyev */
6e18a033bSKonstantin Ananyev
7e18a033bSKonstantin Ananyev
8e18a033bSKonstantin Ananyev#include <ngx_config.h>
9e18a033bSKonstantin Ananyev#include <ngx_core.h>
10e18a033bSKonstantin Ananyev#include <ngx_http.h>
11e18a033bSKonstantin Ananyev
12e18a033bSKonstantin Ananyev
13e18a033bSKonstantin Ananyevtypedef struct {
14e18a033bSKonstantin Ananyev    ngx_array_t                    caches;  /* ngx_http_file_cache_t * */
15e18a033bSKonstantin Ananyev} ngx_http_fastcgi_main_conf_t;
16e18a033bSKonstantin Ananyev
17e18a033bSKonstantin Ananyev
18e18a033bSKonstantin Ananyevtypedef struct {
19e18a033bSKonstantin Ananyev    ngx_array_t                   *flushes;
20e18a033bSKonstantin Ananyev    ngx_array_t                   *lengths;
21e18a033bSKonstantin Ananyev    ngx_array_t                   *values;
22e18a033bSKonstantin Ananyev    ngx_uint_t                     number;
23e18a033bSKonstantin Ananyev    ngx_hash_t                     hash;
24e18a033bSKonstantin Ananyev} ngx_http_fastcgi_params_t;
25e18a033bSKonstantin Ananyev
26e18a033bSKonstantin Ananyev
27e18a033bSKonstantin Ananyevtypedef struct {
28e18a033bSKonstantin Ananyev    ngx_http_upstream_conf_t       upstream;
29e18a033bSKonstantin Ananyev
30e18a033bSKonstantin Ananyev    ngx_str_t                      index;
31e18a033bSKonstantin Ananyev
32e18a033bSKonstantin Ananyev    ngx_http_fastcgi_params_t      params;
33e18a033bSKonstantin Ananyev#if (NGX_HTTP_CACHE)
34e18a033bSKonstantin Ananyev    ngx_http_fastcgi_params_t      params_cache;
35e18a033bSKonstantin Ananyev#endif
36e18a033bSKonstantin Ananyev
37e18a033bSKonstantin Ananyev    ngx_array_t                   *params_source;
38e18a033bSKonstantin Ananyev    ngx_array_t                   *catch_stderr;
39e18a033bSKonstantin Ananyev
40e18a033bSKonstantin Ananyev    ngx_array_t                   *fastcgi_lengths;
41e18a033bSKonstantin Ananyev    ngx_array_t                   *fastcgi_values;
42e18a033bSKonstantin Ananyev
43e18a033bSKonstantin Ananyev    ngx_flag_t                     keep_conn;
44e18a033bSKonstantin Ananyev
45e18a033bSKonstantin Ananyev#if (NGX_HTTP_CACHE)
46e18a033bSKonstantin Ananyev    ngx_http_complex_value_t       cache_key;
47e18a033bSKonstantin Ananyev#endif
48e18a033bSKonstantin Ananyev
49e18a033bSKonstantin Ananyev#if (NGX_PCRE)
50e18a033bSKonstantin Ananyev    ngx_regex_t                   *split_regex;
51e18a033bSKonstantin Ananyev    ngx_str_t                      split_name;
52e18a033bSKonstantin Ananyev#endif
53e18a033bSKonstantin Ananyev} ngx_http_fastcgi_loc_conf_t;
54e18a033bSKonstantin Ananyev
55e18a033bSKonstantin Ananyev
56e18a033bSKonstantin Ananyevtypedef enum {
57e18a033bSKonstantin Ananyev    ngx_http_fastcgi_st_version = 0,
58e18a033bSKonstantin Ananyev    ngx_http_fastcgi_st_type,
59e18a033bSKonstantin Ananyev    ngx_http_fastcgi_st_request_id_hi,
60e18a033bSKonstantin Ananyev    ngx_http_fastcgi_st_request_id_lo,
61e18a033bSKonstantin Ananyev    ngx_http_fastcgi_st_content_length_hi,
62e18a033bSKonstantin Ananyev    ngx_http_fastcgi_st_content_length_lo,
63e18a033bSKonstantin Ananyev    ngx_http_fastcgi_st_padding_length,
64e18a033bSKonstantin Ananyev    ngx_http_fastcgi_st_reserved,
65e18a033bSKonstantin Ananyev    ngx_http_fastcgi_st_data,
66e18a033bSKonstantin Ananyev    ngx_http_fastcgi_st_padding
67e18a033bSKonstantin Ananyev} ngx_http_fastcgi_state_e;
68e18a033bSKonstantin Ananyev
69e18a033bSKonstantin Ananyev
70e18a033bSKonstantin Ananyevtypedef struct {
71e18a033bSKonstantin Ananyev    u_char                        *start;
72e18a033bSKonstantin Ananyev    u_char                        *end;
73e18a033bSKonstantin Ananyev} ngx_http_fastcgi_split_part_t;
74e18a033bSKonstantin Ananyev
75e18a033bSKonstantin Ananyev
76e18a033bSKonstantin Ananyevtypedef struct {
77e18a033bSKonstantin Ananyev    ngx_http_fastcgi_state_e       state;
78e18a033bSKonstantin Ananyev    u_char                        *pos;
79e18a033bSKonstantin Ananyev    u_char                        *last;
80e18a033bSKonstantin Ananyev    ngx_uint_t                     type;
81e18a033bSKonstantin Ananyev    size_t                         length;
82e18a033bSKonstantin Ananyev    size_t                         padding;
83e18a033bSKonstantin Ananyev
84e18a033bSKonstantin Ananyev    ngx_chain_t                   *free;
85e18a033bSKonstantin Ananyev    ngx_chain_t                   *busy;
86e18a033bSKonstantin Ananyev
87e18a033bSKonstantin Ananyev    unsigned                       fastcgi_stdout:1;
88e18a033bSKonstantin Ananyev    unsigned                       large_stderr:1;
89e18a033bSKonstantin Ananyev    unsigned                       header_sent:1;
90e18a033bSKonstantin Ananyev
91e18a033bSKonstantin Ananyev    ngx_array_t                   *split_parts;
92e18a033bSKonstantin Ananyev
93e18a033bSKonstantin Ananyev    ngx_str_t                      script_name;
94e18a033bSKonstantin Ananyev    ngx_str_t                      path_info;
95e18a033bSKonstantin Ananyev} ngx_http_fastcgi_ctx_t;
96e18a033bSKonstantin Ananyev
97e18a033bSKonstantin Ananyev
98e18a033bSKonstantin Ananyev#define NGX_HTTP_FASTCGI_RESPONDER      1
99e18a033bSKonstantin Ananyev
100e18a033bSKonstantin Ananyev#define NGX_HTTP_FASTCGI_KEEP_CONN      1
101e18a033bSKonstantin Ananyev
102e18a033bSKonstantin Ananyev#define NGX_HTTP_FASTCGI_BEGIN_REQUEST  1
103e18a033bSKonstantin Ananyev#define NGX_HTTP_FASTCGI_ABORT_REQUEST  2
104e18a033bSKonstantin Ananyev#define NGX_HTTP_FASTCGI_END_REQUEST    3
105e18a033bSKonstantin Ananyev#define NGX_HTTP_FASTCGI_PARAMS         4
106e18a033bSKonstantin Ananyev#define NGX_HTTP_FASTCGI_STDIN          5
107e18a033bSKonstantin Ananyev#define NGX_HTTP_FASTCGI_STDOUT         6
108e18a033bSKonstantin Ananyev#define NGX_HTTP_FASTCGI_STDERR         7
109e18a033bSKonstantin Ananyev#define NGX_HTTP_FASTCGI_DATA           8
110e18a033bSKonstantin Ananyev
111e18a033bSKonstantin Ananyev
112e18a033bSKonstantin Ananyevtypedef struct {
113e18a033bSKonstantin Ananyev    u_char  version;
114e18a033bSKonstantin Ananyev    u_char  type;
115e18a033bSKonstantin Ananyev    u_char  request_id_hi;
116e18a033bSKonstantin Ananyev    u_char  request_id_lo;
117e18a033bSKonstantin Ananyev    u_char  content_length_hi;
118e18a033bSKonstantin Ananyev    u_char  content_length_lo;
119e18a033bSKonstantin Ananyev    u_char  padding_length;
120e18a033bSKonstantin Ananyev    u_char  reserved;
121e18a033bSKonstantin Ananyev} ngx_http_fastcgi_header_t;
122e18a033bSKonstantin Ananyev
123e18a033bSKonstantin Ananyev
124e18a033bSKonstantin Ananyevtypedef struct {
125e18a033bSKonstantin Ananyev    u_char  role_hi;
126e18a033bSKonstantin Ananyev    u_char  role_lo;
127e18a033bSKonstantin Ananyev    u_char  flags;
128e18a033bSKonstantin Ananyev    u_char  reserved[5];
129e18a033bSKonstantin Ananyev} ngx_http_fastcgi_begin_request_t;
130e18a033bSKonstantin Ananyev
131e18a033bSKonstantin Ananyev
132e18a033bSKonstantin Ananyevtypedef struct {
133e18a033bSKonstantin Ananyev    u_char  version;
134e18a033bSKonstantin Ananyev    u_char  type;
135e18a033bSKonstantin Ananyev    u_char  request_id_hi;
136e18a033bSKonstantin Ananyev    u_char  request_id_lo;
137e18a033bSKonstantin Ananyev} ngx_http_fastcgi_header_small_t;
138e18a033bSKonstantin Ananyev
139e18a033bSKonstantin Ananyev
140e18a033bSKonstantin Ananyevtypedef struct {
141e18a033bSKonstantin Ananyev    ngx_http_fastcgi_header_t         h0;
142e18a033bSKonstantin Ananyev    ngx_http_fastcgi_begin_request_t  br;
143e18a033bSKonstantin Ananyev    ngx_http_fastcgi_header_small_t   h1;
144e18a033bSKonstantin Ananyev} ngx_http_fastcgi_request_start_t;
145e18a033bSKonstantin Ananyev
146e18a033bSKonstantin Ananyev
147e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_eval(ngx_http_request_t *r,
148e18a033bSKonstantin Ananyev    ngx_http_fastcgi_loc_conf_t *flcf);
149e18a033bSKonstantin Ananyev#if (NGX_HTTP_CACHE)
150e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_create_key(ngx_http_request_t *r);
151e18a033bSKonstantin Ananyev#endif
152e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_create_request(ngx_http_request_t *r);
153e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_reinit_request(ngx_http_request_t *r);
154e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_body_output_filter(void *data,
155e18a033bSKonstantin Ananyev    ngx_chain_t *in);
156e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_process_header(ngx_http_request_t *r);
157e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_input_filter_init(void *data);
158e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_input_filter(ngx_event_pipe_t *p,
159e18a033bSKonstantin Ananyev    ngx_buf_t *buf);
160e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_non_buffered_filter(void *data,
161e18a033bSKonstantin Ananyev    ssize_t bytes);
162e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_process_record(ngx_http_request_t *r,
163e18a033bSKonstantin Ananyev    ngx_http_fastcgi_ctx_t *f);
164e18a033bSKonstantin Ananyevstatic void ngx_http_fastcgi_abort_request(ngx_http_request_t *r);
165e18a033bSKonstantin Ananyevstatic void ngx_http_fastcgi_finalize_request(ngx_http_request_t *r,
166e18a033bSKonstantin Ananyev    ngx_int_t rc);
167e18a033bSKonstantin Ananyev
168e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_add_variables(ngx_conf_t *cf);
169e18a033bSKonstantin Ananyevstatic void *ngx_http_fastcgi_create_main_conf(ngx_conf_t *cf);
170e18a033bSKonstantin Ananyevstatic void *ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf);
171e18a033bSKonstantin Ananyevstatic char *ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf,
172e18a033bSKonstantin Ananyev    void *parent, void *child);
173e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_init_params(ngx_conf_t *cf,
174e18a033bSKonstantin Ananyev    ngx_http_fastcgi_loc_conf_t *conf, ngx_http_fastcgi_params_t *params,
175e18a033bSKonstantin Ananyev    ngx_keyval_t *default_params);
176e18a033bSKonstantin Ananyev
177e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r,
178e18a033bSKonstantin Ananyev    ngx_http_variable_value_t *v, uintptr_t data);
179e18a033bSKonstantin Ananyevstatic ngx_int_t ngx_http_fastcgi_path_info_variable(ngx_http_request_t *r,
180e18a033bSKonstantin Ananyev    ngx_http_variable_value_t *v, uintptr_t data);
181e18a033bSKonstantin Ananyevstatic ngx_http_fastcgi_ctx_t *ngx_http_fastcgi_split(ngx_http_request_t *r,
182e18a033bSKonstantin Ananyev    ngx_http_fastcgi_loc_conf_t *flcf);
183e18a033bSKonstantin Ananyev
184e18a033bSKonstantin Ananyevstatic char *ngx_http_fastcgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
185e18a033bSKonstantin Ananyev    void *conf);
186e18a033bSKonstantin Ananyevstatic char *ngx_http_fastcgi_split_path_info(ngx_conf_t *cf,
187e18a033bSKonstantin Ananyev    ngx_command_t *cmd, void *conf);
188e18a033bSKonstantin Ananyevstatic char *ngx_http_fastcgi_store(ngx_conf_t *cf, ngx_command_t *cmd,
189e18a033bSKonstantin Ananyev    void *conf);
190e18a033bSKonstantin Ananyev#if (NGX_HTTP_CACHE)
191e18a033bSKonstantin Ananyevstatic char *ngx_http_fastcgi_cache(ngx_conf_t *cf, ngx_command_t *cmd,
192e18a033bSKonstantin Ananyev    void *conf);
193e18a033bSKonstantin Ananyevstatic char *ngx_http_fastcgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd,
194e18a033bSKonstantin Ananyev    void *conf);
195e18a033bSKonstantin Ananyev#endif
196e18a033bSKonstantin Ananyev
197e18a033bSKonstantin Ananyevstatic char *ngx_http_fastcgi_lowat_check(ngx_conf_t *cf, void *post,
198e18a033bSKonstantin Ananyev    void *data);
199e18a033bSKonstantin Ananyev
200e18a033bSKonstantin Ananyev
201e18a033bSKonstantin Ananyevstatic ngx_conf_post_t  ngx_http_fastcgi_lowat_post =
202e18a033bSKonstantin Ananyev    { ngx_http_fastcgi_lowat_check };
203e18a033bSKonstantin Ananyev
204e18a033bSKonstantin Ananyev
205e18a033bSKonstantin Ananyevstatic ngx_conf_bitmask_t  ngx_http_fastcgi_next_upstream_masks[] = {
206e18a033bSKonstantin Ananyev    { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR },
207e18a033bSKonstantin Ananyev    { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT },
208e18a033bSKonstantin Ananyev    { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER },
209e18a033bSKonstantin Ananyev    { ngx_string("non_idempotent"), NGX_HTTP_UPSTREAM_FT_NON_IDEMPOTENT },
210e18a033bSKonstantin Ananyev    { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 },
211e18a033bSKonstantin Ananyev    { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 },
212e18a033bSKonstantin Ananyev    { ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 },
213e18a033bSKonstantin Ananyev    { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
214e18a033bSKonstantin Ananyev    { ngx_string("http_429"), NGX_HTTP_UPSTREAM_FT_HTTP_429 },
215e18a033bSKonstantin Ananyev    { ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING },
216e18a033bSKonstantin Ananyev    { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
217e18a033bSKonstantin Ananyev    { ngx_null_string, 0 }
218e18a033bSKonstantin Ananyev};
219e18a033bSKonstantin Ananyev
220e18a033bSKonstantin Ananyev
221e18a033bSKonstantin Ananyevngx_module_t  ngx_http_fastcgi_module;
222e18a033bSKonstantin Ananyev
223e18a033bSKonstantin Ananyev
224e18a033bSKonstantin Ananyevstatic ngx_command_t  ngx_http_fastcgi_commands[] = {
225e18a033bSKonstantin Ananyev
226e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_pass"),
227e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1,
228e18a033bSKonstantin Ananyev      ngx_http_fastcgi_pass,
229e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
230e18a033bSKonstantin Ananyev      0,
231e18a033bSKonstantin Ananyev      NULL },
232e18a033bSKonstantin Ananyev
233e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_index"),
234e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
235e18a033bSKonstantin Ananyev      ngx_conf_set_str_slot,
236e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
237e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, index),
238e18a033bSKonstantin Ananyev      NULL },
239e18a033bSKonstantin Ananyev
240e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_split_path_info"),
241e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
242e18a033bSKonstantin Ananyev      ngx_http_fastcgi_split_path_info,
243e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
244e18a033bSKonstantin Ananyev      0,
245e18a033bSKonstantin Ananyev      NULL },
246e18a033bSKonstantin Ananyev
247e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_store"),
248e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
249e18a033bSKonstantin Ananyev      ngx_http_fastcgi_store,
250e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
251e18a033bSKonstantin Ananyev      0,
252e18a033bSKonstantin Ananyev      NULL },
253e18a033bSKonstantin Ananyev
254e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_store_access"),
255e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123,
256e18a033bSKonstantin Ananyev      ngx_conf_set_access_slot,
257e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
258e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.store_access),
259e18a033bSKonstantin Ananyev      NULL },
260e18a033bSKonstantin Ananyev
261e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_buffering"),
262e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
263e18a033bSKonstantin Ananyev      ngx_conf_set_flag_slot,
264e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
265e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.buffering),
266e18a033bSKonstantin Ananyev      NULL },
267e18a033bSKonstantin Ananyev
268e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_request_buffering"),
269e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
270e18a033bSKonstantin Ananyev      ngx_conf_set_flag_slot,
271e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
272e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.request_buffering),
273e18a033bSKonstantin Ananyev      NULL },
274e18a033bSKonstantin Ananyev
275e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_ignore_client_abort"),
276e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
277e18a033bSKonstantin Ananyev      ngx_conf_set_flag_slot,
278e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
279e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.ignore_client_abort),
280e18a033bSKonstantin Ananyev      NULL },
281e18a033bSKonstantin Ananyev
282e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_bind"),
283e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12,
284e18a033bSKonstantin Ananyev      ngx_http_upstream_bind_set_slot,
285e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
286e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.local),
287e18a033bSKonstantin Ananyev      NULL },
288e18a033bSKonstantin Ananyev
289e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_connect_timeout"),
290e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
291e18a033bSKonstantin Ananyev      ngx_conf_set_msec_slot,
292e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
293e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.connect_timeout),
294e18a033bSKonstantin Ananyev      NULL },
295e18a033bSKonstantin Ananyev
296e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_send_timeout"),
297e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
298e18a033bSKonstantin Ananyev      ngx_conf_set_msec_slot,
299e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
300e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.send_timeout),
301e18a033bSKonstantin Ananyev      NULL },
302e18a033bSKonstantin Ananyev
303e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_send_lowat"),
304e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
305e18a033bSKonstantin Ananyev      ngx_conf_set_size_slot,
306e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
307e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.send_lowat),
308e18a033bSKonstantin Ananyev      &ngx_http_fastcgi_lowat_post },
309e18a033bSKonstantin Ananyev
310e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_buffer_size"),
311e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
312e18a033bSKonstantin Ananyev      ngx_conf_set_size_slot,
313e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
314e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.buffer_size),
315e18a033bSKonstantin Ananyev      NULL },
316e18a033bSKonstantin Ananyev
317e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_pass_request_headers"),
318e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
319e18a033bSKonstantin Ananyev      ngx_conf_set_flag_slot,
320e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
321e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_request_headers),
322e18a033bSKonstantin Ananyev      NULL },
323e18a033bSKonstantin Ananyev
324e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_pass_request_body"),
325e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
326e18a033bSKonstantin Ananyev      ngx_conf_set_flag_slot,
327e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
328e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.pass_request_body),
329e18a033bSKonstantin Ananyev      NULL },
330e18a033bSKonstantin Ananyev
331e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_intercept_errors"),
332e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
333e18a033bSKonstantin Ananyev      ngx_conf_set_flag_slot,
334e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
335e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.intercept_errors),
336e18a033bSKonstantin Ananyev      NULL },
337e18a033bSKonstantin Ananyev
338e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_read_timeout"),
339e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
340e18a033bSKonstantin Ananyev      ngx_conf_set_msec_slot,
341e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
342e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.read_timeout),
343e18a033bSKonstantin Ananyev      NULL },
344e18a033bSKonstantin Ananyev
345e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_buffers"),
346e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
347e18a033bSKonstantin Ananyev      ngx_conf_set_bufs_slot,
348e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
349e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.bufs),
350e18a033bSKonstantin Ananyev      NULL },
351e18a033bSKonstantin Ananyev
352e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_busy_buffers_size"),
353e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
354e18a033bSKonstantin Ananyev      ngx_conf_set_size_slot,
355e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
356e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.busy_buffers_size_conf),
357e18a033bSKonstantin Ananyev      NULL },
358e18a033bSKonstantin Ananyev
359e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_force_ranges"),
360e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
361e18a033bSKonstantin Ananyev      ngx_conf_set_flag_slot,
362e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
363e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.force_ranges),
364e18a033bSKonstantin Ananyev      NULL },
365e18a033bSKonstantin Ananyev
366e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_limit_rate"),
367e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
368e18a033bSKonstantin Ananyev      ngx_conf_set_size_slot,
369e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
370e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.limit_rate),
371e18a033bSKonstantin Ananyev      NULL },
372e18a033bSKonstantin Ananyev
373e18a033bSKonstantin Ananyev#if (NGX_HTTP_CACHE)
374e18a033bSKonstantin Ananyev
375e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_cache"),
376e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
377e18a033bSKonstantin Ananyev      ngx_http_fastcgi_cache,
378e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
379e18a033bSKonstantin Ananyev      0,
380e18a033bSKonstantin Ananyev      NULL },
381e18a033bSKonstantin Ananyev
382e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_cache_key"),
383e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
384e18a033bSKonstantin Ananyev      ngx_http_fastcgi_cache_key,
385e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
386e18a033bSKonstantin Ananyev      0,
387e18a033bSKonstantin Ananyev      NULL },
388e18a033bSKonstantin Ananyev
389e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_cache_path"),
390e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_CONF_2MORE,
391e18a033bSKonstantin Ananyev      ngx_http_file_cache_set_slot,
392e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF_OFFSET,
393e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_main_conf_t, caches),
394e18a033bSKonstantin Ananyev      &ngx_http_fastcgi_module },
395e18a033bSKonstantin Ananyev
396e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_cache_bypass"),
397e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
398e18a033bSKonstantin Ananyev      ngx_http_set_predicate_slot,
399e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
400e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.cache_bypass),
401e18a033bSKonstantin Ananyev      NULL },
402e18a033bSKonstantin Ananyev
403e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_no_cache"),
404e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
405e18a033bSKonstantin Ananyev      ngx_http_set_predicate_slot,
406e18a033bSKonstantin Ananyev      NGX_HTTP_LOC_CONF_OFFSET,
407e18a033bSKonstantin Ananyev      offsetof(ngx_http_fastcgi_loc_conf_t, upstream.no_cache),
408e18a033bSKonstantin Ananyev      NULL },
409e18a033bSKonstantin Ananyev
410e18a033bSKonstantin Ananyev    { ngx_string("fastcgi_cache_valid"),
411e18a033bSKonstantin Ananyev      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
412