20
21
#define NGX_HTTP_UPSTREAM_FT_TIMEOUT 0x00000004
21
22
#define NGX_HTTP_UPSTREAM_FT_INVALID_HEADER 0x00000008
22
23
#define NGX_HTTP_UPSTREAM_FT_HTTP_500 0x00000010
23
#define NGX_HTTP_UPSTREAM_FT_HTTP_503 0x00000020
24
#define NGX_HTTP_UPSTREAM_FT_HTTP_404 0x00000040
25
#define NGX_HTTP_UPSTREAM_FT_BUSY_LOCK 0x00000080
26
#define NGX_HTTP_UPSTREAM_FT_MAX_WAITING 0x00000100
24
#define NGX_HTTP_UPSTREAM_FT_HTTP_502 0x00000020
25
#define NGX_HTTP_UPSTREAM_FT_HTTP_503 0x00000040
26
#define NGX_HTTP_UPSTREAM_FT_HTTP_504 0x00000080
27
#define NGX_HTTP_UPSTREAM_FT_HTTP_404 0x00000100
28
#define NGX_HTTP_UPSTREAM_FT_UPDATING 0x00000200
29
#define NGX_HTTP_UPSTREAM_FT_BUSY_LOCK 0x00000400
30
#define NGX_HTTP_UPSTREAM_FT_MAX_WAITING 0x00000800
27
31
#define NGX_HTTP_UPSTREAM_FT_NOLIVE 0x40000000
28
32
#define NGX_HTTP_UPSTREAM_FT_OFF 0x80000000
34
#define NGX_HTTP_UPSTREAM_FT_STATUS (NGX_HTTP_UPSTREAM_FT_HTTP_500 \
35
|NGX_HTTP_UPSTREAM_FT_HTTP_502 \
36
|NGX_HTTP_UPSTREAM_FT_HTTP_503 \
37
|NGX_HTTP_UPSTREAM_FT_HTTP_504 \
38
|NGX_HTTP_UPSTREAM_FT_HTTP_404)
31
40
#define NGX_HTTP_UPSTREAM_INVALID_HEADER 40
43
#define NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT 0x00000002
44
#define NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES 0x00000004
45
#define NGX_HTTP_UPSTREAM_IGN_EXPIRES 0x00000008
46
#define NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL 0x00000010
47
#define NGX_HTTP_UPSTREAM_IGN_SET_COOKIE 0x00000020
48
#define NGX_HTTP_UPSTREAM_IGN_XA_LIMIT_RATE 0x00000040
49
#define NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING 0x00000080
50
#define NGX_HTTP_UPSTREAM_IGN_XA_CHARSET 0x00000100
40
ngx_uint_t response_msec;
59
ngx_uint_t response_msec;
60
off_t response_length;
43
63
} ngx_http_upstream_state_t;
47
ngx_hash_t headers_in_hash;
48
ngx_array_t upstreams;
67
ngx_hash_t headers_in_hash;
68
ngx_array_t upstreams;
49
69
/* ngx_http_upstream_srv_conf_t */
50
70
} ngx_http_upstream_main_conf_t;
87
107
struct ngx_http_upstream_srv_conf_s {
88
ngx_http_upstream_peer_t peer;
91
ngx_array_t *servers; /* ngx_http_upstream_server_t */
98
in_port_t default_port;
108
ngx_http_upstream_peer_t peer;
111
ngx_array_t *servers; /* ngx_http_upstream_server_t */
118
in_port_t default_port;
119
ngx_uint_t no_port; /* unsigned no_port:1 */
103
ngx_http_upstream_srv_conf_t *upstream;
105
ngx_msec_t connect_timeout;
106
ngx_msec_t send_timeout;
107
ngx_msec_t read_timeout;
113
size_t busy_buffers_size;
114
size_t max_temp_file_size;
115
size_t temp_file_write_size;
117
size_t busy_buffers_size_conf;
118
size_t max_temp_file_size_conf;
119
size_t temp_file_write_size_conf;
121
ngx_uint_t next_upstream;
122
ngx_uint_t store_access;
126
ngx_flag_t buffering;
127
ngx_flag_t pass_request_headers;
128
ngx_flag_t pass_request_body;
130
ngx_flag_t ignore_client_abort;
131
ngx_flag_t intercept_errors;
132
ngx_flag_t cyclic_temp_file;
134
ngx_path_t *temp_path;
136
ngx_hash_t hide_headers_hash;
137
ngx_array_t *hide_headers;
138
ngx_array_t *pass_headers;
142
ngx_array_t *store_lengths;
143
ngx_array_t *store_values;
146
unsigned intercept_404:1;
147
unsigned change_buffering:1;
125
ngx_http_complex_value_t *value;
126
} ngx_http_upstream_local_t;
130
ngx_http_upstream_srv_conf_t *upstream;
132
ngx_msec_t connect_timeout;
133
ngx_msec_t send_timeout;
134
ngx_msec_t read_timeout;
140
size_t busy_buffers_size;
141
size_t max_temp_file_size;
142
size_t temp_file_write_size;
144
size_t busy_buffers_size_conf;
145
size_t max_temp_file_size_conf;
146
size_t temp_file_write_size_conf;
150
ngx_uint_t ignore_headers;
151
ngx_uint_t next_upstream;
152
ngx_uint_t store_access;
153
ngx_flag_t buffering;
154
ngx_flag_t pass_request_headers;
155
ngx_flag_t pass_request_body;
157
ngx_flag_t ignore_client_abort;
158
ngx_flag_t intercept_errors;
159
ngx_flag_t cyclic_temp_file;
161
ngx_path_t *temp_path;
163
ngx_hash_t hide_headers_hash;
164
ngx_array_t *hide_headers;
165
ngx_array_t *pass_headers;
167
ngx_http_upstream_local_t *local;
170
ngx_shm_zone_t *cache;
172
ngx_uint_t cache_min_uses;
173
ngx_uint_t cache_use_stale;
174
ngx_uint_t cache_methods;
176
ngx_flag_t cache_lock;
177
ngx_msec_t cache_lock_timeout;
179
ngx_array_t *cache_valid;
180
ngx_array_t *cache_bypass;
181
ngx_array_t *no_cache;
184
ngx_array_t *store_lengths;
185
ngx_array_t *store_values;
188
unsigned intercept_404:1;
189
unsigned change_buffering:1;
149
191
#if (NGX_HTTP_SSL)
193
ngx_flag_t ssl_session_reuse;
153
197
} ngx_http_upstream_conf_t;
158
ngx_http_header_handler_pt handler;
160
ngx_http_header_handler_pt copy_handler;
162
ngx_uint_t redirect; /* unsigned redirect:1; */
202
ngx_http_header_handler_pt handler;
204
ngx_http_header_handler_pt copy_handler;
206
ngx_uint_t redirect; /* unsigned redirect:1; */
163
207
} ngx_http_upstream_header_t;
170
ngx_str_t status_line;
172
ngx_table_elt_t *status;
173
ngx_table_elt_t *date;
174
ngx_table_elt_t *server;
175
ngx_table_elt_t *connection;
177
ngx_table_elt_t *expires;
178
ngx_table_elt_t *etag;
179
ngx_table_elt_t *x_accel_expires;
180
ngx_table_elt_t *x_accel_redirect;
181
ngx_table_elt_t *x_accel_limit_rate;
183
ngx_table_elt_t *content_type;
184
ngx_table_elt_t *content_length;
186
ngx_table_elt_t *last_modified;
187
ngx_table_elt_t *location;
188
ngx_table_elt_t *accept_ranges;
189
ngx_table_elt_t *www_authenticate;
214
ngx_str_t status_line;
216
ngx_table_elt_t *status;
217
ngx_table_elt_t *date;
218
ngx_table_elt_t *server;
219
ngx_table_elt_t *connection;
221
ngx_table_elt_t *expires;
222
ngx_table_elt_t *etag;
223
ngx_table_elt_t *x_accel_expires;
224
ngx_table_elt_t *x_accel_redirect;
225
ngx_table_elt_t *x_accel_limit_rate;
227
ngx_table_elt_t *content_type;
228
ngx_table_elt_t *content_length;
230
ngx_table_elt_t *last_modified;
231
ngx_table_elt_t *location;
232
ngx_table_elt_t *accept_ranges;
233
ngx_table_elt_t *www_authenticate;
234
ngx_table_elt_t *transfer_encoding;
191
236
#if (NGX_HTTP_GZIP)
192
ngx_table_elt_t *content_encoding;
237
ngx_table_elt_t *content_encoding;
195
off_t content_length_n;
197
ngx_array_t cache_control;
240
off_t content_length_n;
242
ngx_array_t cache_control;
244
unsigned connection_close:1;
198
246
} ngx_http_upstream_headers_in_t;
204
ngx_uint_t default_port; /* unsigned default_port:1 */
207
ngx_resolver_ctx_t *ctx;
252
ngx_uint_t no_port; /* unsigned no_port:1 */
257
struct sockaddr *sockaddr;
260
ngx_resolver_ctx_t *ctx;
208
261
} ngx_http_upstream_resolved_t;
264
typedef void (*ngx_http_upstream_handler_pt)(ngx_http_request_t *r,
265
ngx_http_upstream_t *u);
211
268
struct ngx_http_upstream_s {
212
ngx_peer_connection_t peer;
214
ngx_event_pipe_t *pipe;
216
ngx_chain_t *request_bufs;
218
ngx_output_chain_ctx_t output;
219
ngx_chain_writer_ctx_t writer;
221
ngx_http_upstream_conf_t *conf;
223
ngx_http_upstream_headers_in_t headers_in;
225
ngx_http_upstream_resolved_t *resolved;
230
ngx_chain_t *out_bufs;
231
ngx_chain_t *busy_bufs;
232
ngx_chain_t *free_bufs;
234
ngx_int_t (*input_filter_init)(void *data);
235
ngx_int_t (*input_filter)(void *data, ssize_t bytes);
236
void *input_filter_ctx;
238
ngx_int_t (*create_request)(ngx_http_request_t *r);
239
ngx_int_t (*reinit_request)(ngx_http_request_t *r);
240
ngx_int_t (*process_header)(ngx_http_request_t *r);
241
void (*abort_request)(ngx_http_request_t *r);
242
void (*finalize_request)(ngx_http_request_t *r,
244
ngx_int_t (*rewrite_redirect)(ngx_http_request_t *r,
245
ngx_table_elt_t *h, size_t prefix);
249
ngx_http_upstream_state_t *state;
255
ngx_http_cleanup_pt *cleanup;
258
unsigned cacheable:1;
262
unsigned buffering:1;
264
unsigned request_sent:1;
265
unsigned header_sent:1;
269
ngx_http_upstream_handler_pt read_event_handler;
270
ngx_http_upstream_handler_pt write_event_handler;
272
ngx_peer_connection_t peer;
274
ngx_event_pipe_t *pipe;
276
ngx_chain_t *request_bufs;
278
ngx_output_chain_ctx_t output;
279
ngx_chain_writer_ctx_t writer;
281
ngx_http_upstream_conf_t *conf;
283
ngx_http_upstream_headers_in_t headers_in;
285
ngx_http_upstream_resolved_t *resolved;
287
ngx_buf_t from_client;
292
ngx_chain_t *out_bufs;
293
ngx_chain_t *busy_bufs;
294
ngx_chain_t *free_bufs;
296
ngx_int_t (*input_filter_init)(void *data);
297
ngx_int_t (*input_filter)(void *data, ssize_t bytes);
298
void *input_filter_ctx;
301
ngx_int_t (*create_key)(ngx_http_request_t *r);
303
ngx_int_t (*create_request)(ngx_http_request_t *r);
304
ngx_int_t (*reinit_request)(ngx_http_request_t *r);
305
ngx_int_t (*process_header)(ngx_http_request_t *r);
306
void (*abort_request)(ngx_http_request_t *r);
307
void (*finalize_request)(ngx_http_request_t *r,
309
ngx_int_t (*rewrite_redirect)(ngx_http_request_t *r,
310
ngx_table_elt_t *h, size_t prefix);
311
ngx_int_t (*rewrite_cookie)(ngx_http_request_t *r,
316
ngx_http_upstream_state_t *state;
322
ngx_http_cleanup_pt *cleanup;
325
unsigned cacheable:1;
329
unsigned cache_status:3;
332
unsigned buffering:1;
333
unsigned keepalive:1;
336
unsigned request_sent:1;
337
unsigned header_sent:1;
344
} ngx_http_upstream_next_t;
350
ngx_uint_t skip_empty;
351
} ngx_http_upstream_param_t;
269
354
ngx_int_t ngx_http_upstream_header_variable(ngx_http_request_t *r,
270
355
ngx_http_variable_value_t *v, uintptr_t data);
357
ngx_int_t ngx_http_upstream_create(ngx_http_request_t *r);
272
358
void ngx_http_upstream_init(ngx_http_request_t *r);
273
359
ngx_http_upstream_srv_conf_t *ngx_http_upstream_add(ngx_conf_t *cf,
274
360
ngx_url_t *u, ngx_uint_t flags);
361
char *ngx_http_upstream_bind_set_slot(ngx_conf_t *cf, ngx_command_t *cmd,
363
char *ngx_http_upstream_param_set_slot(ngx_conf_t *cf, ngx_command_t *cmd,
275
365
ngx_int_t ngx_http_upstream_hide_headers_hash(ngx_conf_t *cf,
276
366
ngx_http_upstream_conf_t *conf, ngx_http_upstream_conf_t *prev,
277
367
ngx_str_t *default_hide_headers, ngx_hash_init_t *hash);