comparison src/http/ngx_http_upstream.h @ 464:c8cfb6c462ef NGINX_0_7_44

nginx 0.7.44 *) Feature: the ngx_http_proxy_module preliminary cache support. *) Feature: the --with-pcre option in the configure. *) Feature: the "try_files" directive is now allowed on the server block level. *) Bugfix: the "try_files" directive handled incorrectly a query string in a fallback parameter. *) Bugfix: the "try_files" directive might test incorrectly directories. *) Bugfix: if there is the single server for given address:port pair, then captures in regular expressions in a "server_name" directive did not work.
author Igor Sysoev <http://sysoev.ru>
date Mon, 23 Mar 2009 00:00:00 +0300
parents 49a0eb7ce20c
children 392c16f2d858
comparison
equal deleted inserted replaced
463:51cb914e6d3a 464:c8cfb6c462ef
37 37
38 #define NGX_HTTP_UPSTREAM_INVALID_HEADER 40 38 #define NGX_HTTP_UPSTREAM_INVALID_HEADER 40
39 39
40 40
41 typedef struct { 41 typedef struct {
42 ngx_msec_t bl_time; 42 ngx_msec_t bl_time;
43 ngx_uint_t bl_state; 43 ngx_uint_t bl_state;
44 44
45 ngx_uint_t status; 45 ngx_uint_t status;
46 time_t response_sec; 46 time_t response_sec;
47 ngx_uint_t response_msec; 47 ngx_uint_t response_msec;
48 off_t response_length; 48 off_t response_length;
49 49
50 ngx_str_t *peer; 50 ngx_str_t *peer;
51 } ngx_http_upstream_state_t; 51 } ngx_http_upstream_state_t;
52 52
53 53
54 typedef struct { 54 typedef struct {
55 ngx_hash_t headers_in_hash; 55 ngx_hash_t headers_in_hash;
56 ngx_array_t upstreams; 56 ngx_array_t upstreams;
57 /* ngx_http_upstream_srv_conf_t */ 57 /* ngx_http_upstream_srv_conf_t */
58 } ngx_http_upstream_main_conf_t; 58 } ngx_http_upstream_main_conf_t;
59 59
60 typedef struct ngx_http_upstream_srv_conf_s ngx_http_upstream_srv_conf_t; 60 typedef struct ngx_http_upstream_srv_conf_s ngx_http_upstream_srv_conf_t;
61 61
64 typedef ngx_int_t (*ngx_http_upstream_init_peer_pt)(ngx_http_request_t *r, 64 typedef ngx_int_t (*ngx_http_upstream_init_peer_pt)(ngx_http_request_t *r,
65 ngx_http_upstream_srv_conf_t *us); 65 ngx_http_upstream_srv_conf_t *us);
66 66
67 67
68 typedef struct { 68 typedef struct {
69 ngx_http_upstream_init_pt init_upstream; 69 ngx_http_upstream_init_pt init_upstream;
70 ngx_http_upstream_init_peer_pt init; 70 ngx_http_upstream_init_peer_pt init;
71 void *data; 71 void *data;
72 } ngx_http_upstream_peer_t; 72 } ngx_http_upstream_peer_t;
73 73
74 74
75 typedef struct { 75 typedef struct {
76 ngx_peer_addr_t *addrs; 76 ngx_peer_addr_t *addrs;
77 ngx_uint_t naddrs; 77 ngx_uint_t naddrs;
78 ngx_uint_t weight; 78 ngx_uint_t weight;
79 ngx_uint_t max_fails; 79 ngx_uint_t max_fails;
80 time_t fail_timeout; 80 time_t fail_timeout;
81 81
82 unsigned down:1; 82 unsigned down:1;
83 unsigned backup:1; 83 unsigned backup:1;
84 } ngx_http_upstream_server_t; 84 } ngx_http_upstream_server_t;
85 85
86 86
87 #define NGX_HTTP_UPSTREAM_CREATE 0x0001 87 #define NGX_HTTP_UPSTREAM_CREATE 0x0001
88 #define NGX_HTTP_UPSTREAM_WEIGHT 0x0002 88 #define NGX_HTTP_UPSTREAM_WEIGHT 0x0002
91 #define NGX_HTTP_UPSTREAM_DOWN 0x0010 91 #define NGX_HTTP_UPSTREAM_DOWN 0x0010
92 #define NGX_HTTP_UPSTREAM_BACKUP 0x0020 92 #define NGX_HTTP_UPSTREAM_BACKUP 0x0020
93 93
94 94
95 struct ngx_http_upstream_srv_conf_s { 95 struct ngx_http_upstream_srv_conf_s {
96 ngx_http_upstream_peer_t peer; 96 ngx_http_upstream_peer_t peer;
97 void **srv_conf; 97 void **srv_conf;
98 98
99 ngx_array_t *servers; /* ngx_http_upstream_server_t */ 99 ngx_array_t *servers; /* ngx_http_upstream_server_t */
100 100
101 ngx_uint_t flags; 101 ngx_uint_t flags;
102 ngx_str_t host; 102 ngx_str_t host;
103 u_char *file_name; 103 u_char *file_name;
104 ngx_uint_t line; 104 ngx_uint_t line;
105 in_port_t port; 105 in_port_t port;
106 in_port_t default_port; 106 in_port_t default_port;
107 }; 107 };
108 108
109 109
110 typedef struct { 110 typedef struct {
111 ngx_http_upstream_srv_conf_t *upstream; 111 ngx_http_upstream_srv_conf_t *upstream;
112 112
113 ngx_msec_t connect_timeout; 113 ngx_msec_t connect_timeout;
114 ngx_msec_t send_timeout; 114 ngx_msec_t send_timeout;
115 ngx_msec_t read_timeout; 115 ngx_msec_t read_timeout;
116 ngx_msec_t timeout; 116 ngx_msec_t timeout;
117 117
118 size_t send_lowat; 118 size_t send_lowat;
119 size_t buffer_size; 119 size_t buffer_size;
120 120
121 size_t busy_buffers_size; 121 size_t busy_buffers_size;
122 size_t max_temp_file_size; 122 size_t max_temp_file_size;
123 size_t temp_file_write_size; 123 size_t temp_file_write_size;
124 124
125 size_t busy_buffers_size_conf; 125 size_t busy_buffers_size_conf;
126 size_t max_temp_file_size_conf; 126 size_t max_temp_file_size_conf;
127 size_t temp_file_write_size_conf; 127 size_t temp_file_write_size_conf;
128 128
129 ngx_uint_t next_upstream; 129 ngx_bufs_t bufs;
130 ngx_uint_t store_access; 130
131 131 ngx_uint_t next_upstream;
132 ngx_bufs_t bufs; 132 ngx_uint_t store_access;
133 133 ngx_flag_t buffering;
134 ngx_flag_t buffering; 134 ngx_flag_t pass_request_headers;
135 ngx_flag_t pass_request_headers; 135 ngx_flag_t pass_request_body;
136 ngx_flag_t pass_request_body; 136
137 137 ngx_flag_t ignore_client_abort;
138 ngx_flag_t ignore_client_abort; 138 ngx_flag_t intercept_errors;
139 ngx_flag_t intercept_errors; 139 ngx_flag_t cyclic_temp_file;
140 ngx_flag_t cyclic_temp_file; 140
141 141 ngx_path_t *temp_path;
142 ngx_path_t *temp_path; 142
143 143 ngx_hash_t hide_headers_hash;
144 ngx_hash_t hide_headers_hash; 144 ngx_array_t *hide_headers;
145 ngx_array_t *hide_headers; 145 ngx_array_t *pass_headers;
146 ngx_array_t *pass_headers; 146
147 147 #if (NGX_HTTP_CACHE)
148 ngx_array_t *store_lengths; 148 ngx_shm_zone_t *cache;
149 ngx_array_t *store_values; 149
150 150 ngx_uint_t cache_min_uses;
151 signed store:2; 151 ngx_uint_t cache_use_stale;
152 unsigned intercept_404:1; 152
153 unsigned change_buffering:1; 153 ngx_array_t *cache_valid;
154 #endif
155
156 ngx_array_t *store_lengths;
157 ngx_array_t *store_values;
158
159 signed store:2;
160 unsigned intercept_404:1;
161 unsigned change_buffering:1;
154 162
155 #if (NGX_HTTP_SSL) 163 #if (NGX_HTTP_SSL)
156 ngx_ssl_t *ssl; 164 ngx_ssl_t *ssl;
157 ngx_flag_t ssl_session_reuse; 165 ngx_flag_t ssl_session_reuse;
158 #endif 166 #endif
159 167
160 } ngx_http_upstream_conf_t; 168 } ngx_http_upstream_conf_t;
161 169
162 170
163 typedef struct { 171 typedef struct {
164 ngx_str_t name; 172 ngx_str_t name;
165 ngx_http_header_handler_pt handler; 173 ngx_http_header_handler_pt handler;
166 ngx_uint_t offset; 174 ngx_uint_t offset;
167 ngx_http_header_handler_pt copy_handler; 175 ngx_http_header_handler_pt copy_handler;
168 ngx_uint_t conf; 176 ngx_uint_t conf;
169 ngx_uint_t redirect; /* unsigned redirect:1; */ 177 ngx_uint_t redirect; /* unsigned redirect:1; */
170 } ngx_http_upstream_header_t; 178 } ngx_http_upstream_header_t;
171 179
172 180
173 typedef struct { 181 typedef struct {
174 ngx_list_t headers; 182 ngx_list_t headers;
175 183
176 ngx_uint_t status_n; 184 ngx_uint_t status_n;
177 ngx_str_t status_line; 185 ngx_str_t status_line;
178 186
179 ngx_table_elt_t *status; 187 ngx_table_elt_t *status;
180 ngx_table_elt_t *date; 188 ngx_table_elt_t *date;
181 ngx_table_elt_t *server; 189 ngx_table_elt_t *server;
182 ngx_table_elt_t *connection; 190 ngx_table_elt_t *connection;
183 191
184 ngx_table_elt_t *expires; 192 ngx_table_elt_t *expires;
185 ngx_table_elt_t *etag; 193 ngx_table_elt_t *etag;
186 ngx_table_elt_t *x_accel_expires; 194 ngx_table_elt_t *x_accel_expires;
187 ngx_table_elt_t *x_accel_redirect; 195 ngx_table_elt_t *x_accel_redirect;
188 ngx_table_elt_t *x_accel_limit_rate; 196 ngx_table_elt_t *x_accel_limit_rate;
189 197
190 ngx_table_elt_t *content_type; 198 ngx_table_elt_t *content_type;
191 ngx_table_elt_t *content_length; 199 ngx_table_elt_t *content_length;
192 200
193 ngx_table_elt_t *last_modified; 201 ngx_table_elt_t *last_modified;
194 ngx_table_elt_t *location; 202 ngx_table_elt_t *location;
195 ngx_table_elt_t *accept_ranges; 203 ngx_table_elt_t *accept_ranges;
196 ngx_table_elt_t *www_authenticate; 204 ngx_table_elt_t *www_authenticate;
197 205
198 #if (NGX_HTTP_GZIP) 206 #if (NGX_HTTP_GZIP)
199 ngx_table_elt_t *content_encoding; 207 ngx_table_elt_t *content_encoding;
200 #endif 208 #endif
201 209
202 off_t content_length_n; 210 off_t content_length_n;
203 211
204 ngx_array_t cache_control; 212 ngx_array_t cache_control;
205 } ngx_http_upstream_headers_in_t; 213 } ngx_http_upstream_headers_in_t;
206 214
207 215
208 typedef struct { 216 typedef struct {
209 ngx_str_t host; 217 ngx_str_t host;
210 in_port_t port; 218 in_port_t port;
211 ngx_uint_t no_port; /* unsigned no_port:1 */ 219 ngx_uint_t no_port; /* unsigned no_port:1 */
212 220
213 ngx_uint_t naddrs; 221 ngx_uint_t naddrs;
214 in_addr_t *addrs; 222 in_addr_t *addrs;
215 223
216 struct sockaddr *sockaddr; 224 struct sockaddr *sockaddr;
217 socklen_t socklen; 225 socklen_t socklen;
218 226
219 ngx_resolver_ctx_t *ctx; 227 ngx_resolver_ctx_t *ctx;
220 } ngx_http_upstream_resolved_t; 228 } ngx_http_upstream_resolved_t;
221 229
222 230
223 typedef void (*ngx_http_upstream_handler_pt)(ngx_http_request_t *r, 231 typedef void (*ngx_http_upstream_handler_pt)(ngx_http_request_t *r,
224 ngx_http_upstream_t *u); 232 ngx_http_upstream_t *u);
225 233
226 234
227 struct ngx_http_upstream_s { 235 struct ngx_http_upstream_s {
228 ngx_http_upstream_handler_pt read_event_handler; 236 ngx_http_upstream_handler_pt read_event_handler;
229 ngx_http_upstream_handler_pt write_event_handler; 237 ngx_http_upstream_handler_pt write_event_handler;
230 238
231 ngx_peer_connection_t peer; 239 ngx_peer_connection_t peer;
232 240
233 ngx_event_pipe_t *pipe; 241 ngx_event_pipe_t *pipe;
234 242
235 ngx_chain_t *request_bufs; 243 ngx_chain_t *request_bufs;
236 244
237 ngx_output_chain_ctx_t output; 245 ngx_output_chain_ctx_t output;
238 ngx_chain_writer_ctx_t writer; 246 ngx_chain_writer_ctx_t writer;
239 247
240 ngx_http_upstream_conf_t *conf; 248 ngx_http_upstream_conf_t *conf;
241 249
242 ngx_http_upstream_headers_in_t headers_in; 250 ngx_http_upstream_headers_in_t headers_in;
243 251
244 ngx_http_upstream_resolved_t *resolved; 252 ngx_http_upstream_resolved_t *resolved;
245 253
246 ngx_buf_t buffer; 254 ngx_buf_t buffer;
247 size_t length; 255 size_t length;
248 256
249 ngx_chain_t *out_bufs; 257 ngx_chain_t *out_bufs;
250 ngx_chain_t *busy_bufs; 258 ngx_chain_t *busy_bufs;
251 ngx_chain_t *free_bufs; 259 ngx_chain_t *free_bufs;
252 260
253 ngx_int_t (*input_filter_init)(void *data); 261 ngx_int_t (*input_filter_init)(void *data);
254 ngx_int_t (*input_filter)(void *data, ssize_t bytes); 262 ngx_int_t (*input_filter)(void *data, ssize_t bytes);
255 void *input_filter_ctx; 263 void *input_filter_ctx;
256 264
257 ngx_int_t (*create_request)(ngx_http_request_t *r); 265 #if (NGX_HTTP_CACHE)
258 ngx_int_t (*reinit_request)(ngx_http_request_t *r); 266 ngx_int_t (*create_key)(ngx_http_request_t *r);
259 ngx_int_t (*process_header)(ngx_http_request_t *r); 267 #endif
260 void (*abort_request)(ngx_http_request_t *r); 268 ngx_int_t (*create_request)(ngx_http_request_t *r);
261 void (*finalize_request)(ngx_http_request_t *r, 269 ngx_int_t (*reinit_request)(ngx_http_request_t *r);
262 ngx_int_t rc); 270 ngx_int_t (*process_header)(ngx_http_request_t *r);
263 ngx_int_t (*rewrite_redirect)(ngx_http_request_t *r, 271 void (*abort_request)(ngx_http_request_t *r);
264 ngx_table_elt_t *h, size_t prefix); 272 void (*finalize_request)(ngx_http_request_t *r,
265 273 ngx_int_t rc);
266 ngx_msec_t timeout; 274 ngx_int_t (*rewrite_redirect)(ngx_http_request_t *r,
267 275 ngx_table_elt_t *h, size_t prefix);
268 ngx_http_upstream_state_t *state; 276
269 277 ngx_msec_t timeout;
270 ngx_str_t method; 278
271 ngx_str_t schema; 279 ngx_http_upstream_state_t *state;
272 ngx_str_t uri; 280
273 281 ngx_str_t method;
274 ngx_http_cleanup_pt *cleanup; 282 ngx_str_t schema;
275 283 ngx_str_t uri;
276 unsigned store:1; 284
277 unsigned cacheable:1; 285 ngx_http_cleanup_pt *cleanup;
278 unsigned accel:1; 286
279 unsigned ssl:1; 287 unsigned store:1;
280 288 unsigned cacheable:1;
281 unsigned buffering:1; 289 unsigned accel:1;
282 290 unsigned ssl:1;
283 unsigned request_sent:1; 291 #if (NGX_HTTP_CACHE)
284 unsigned header_sent:1; 292 unsigned stale_cache:1;
293 #endif
294
295 unsigned buffering:1;
296
297 unsigned request_sent:1;
298 unsigned header_sent:1;
285 }; 299 };
286 300
287 301
288 typedef struct { 302 typedef struct {
289 ngx_uint_t status; 303 ngx_uint_t status;