blob: ccdcae06deb94dc3e4c625b181c446b7bc6fd398 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
#ifndef _NGX_HTTP_PROXY_HANDLER_H_INCLUDED_
#define _NGX_HTTP_PROXY_HANDLER_H_INCLUDED_
#include <ngx_config.h>
#include <ngx_array.h>
#include <ngx_event_proxy.h>
#include <ngx_http.h>
#define NGX_HTTP_PROXY_PARSE_NO_HEADER 20
#define NGX_HTTP_PARSE_TOO_LONG_STATUS_LINE 21
typedef struct {
ngx_table_elt_t *date;
ngx_table_elt_t *server;
ngx_table_elt_t *connection;
ngx_table_elt_t *content_type;
ngx_table_elt_t *content_length;
ngx_table_elt_t *last_modified;
ngx_table_t *headers;
} ngx_http_proxy_headers_in_t;
typedef struct {
u_int32_t addr;
ngx_str_t host;
int port;
ngx_str_t addr_port_name;
int fails;
time_t accessed;
} ngx_http_proxy_upstream_t;
typedef struct {
int current;
int number;
int max_fails;
int fail_timeout;
/* ngx_mutex_t mutex; */
/* ngx_connection_t *cached; ??? */
ngx_http_proxy_upstream_t u[1];
} ngx_http_proxy_upstreams_t;
typedef struct {
ngx_str_t host;
ngx_str_t uri;
ngx_str_t *location;
ngx_str_t host_header;
ngx_str_t port_name;
int port;
} ngx_http_proxy_upstream_url_t;
typedef struct {
ngx_http_proxy_upstreams_t *upstreams;
ngx_http_proxy_upstream_url_t *upstream_url;
int client_request_buffer_size;
int rcvbuf;
int conn_pool_size;
int connect_timeout;
int send_timeout;
int read_timeout;
int header_size;
int large_header;
int block_size;
int max_block_size;
int max_temp_file_size;
int temp_file_write_size;
ngx_path_t *temp_path;
int temp_file_warn;
int retry_500_error;
} ngx_http_proxy_loc_conf_t;
#if 0
/* location /one/ { proxy_pass http://localhost:9000/two/; } */
typedef struct {
/* "/one/" */
/* "http://localhost:9000/two/" */
/* "/two/" */
*upstream_farm;
} ngx_http_proxy_pass_t;
#endif
typedef struct ngx_http_proxy_ctx_s ngx_http_proxy_ctx_t;
struct ngx_http_proxy_ctx_s {
ngx_event_proxy_t *event_proxy;
ngx_chain_t *in_hunks;
ngx_chain_t *last_in_hunk;
ngx_chain_t *shadow_hunks;
ngx_chain_t *out_hunks;
ngx_chain_t *last_out_hunk;
ngx_chain_t *free_hunks;
ngx_chain_t *request_hunks;
ngx_hunk_t *client_request_hunk;
ngx_hunk_t *client_first_part_hunk;
ngx_connection_t *connection;
ngx_http_request_t *request;
ngx_http_proxy_headers_in_t headers_in;
int block_size;
int allocated;
ngx_file_t *temp_file;
off_t temp_offset;
int last_hunk;
ngx_array_t hunks;
int nhunks;
int hunk_n;
ngx_http_proxy_upstream_url_t *upstream_url;
ngx_http_proxy_upstreams_t *upstreams;
int cur_upstream;
int tries;
struct sockaddr *sockaddr;
ngx_http_proxy_loc_conf_t *lcf;
ngx_log_t *log;
int method;
ngx_hunk_t *header_in;
int status;
ngx_str_t status_line;
ngx_str_t full_status_line;
int state;
int status_count;
char *status_start;
char *status_end;
int (*state_write_upstream_handler) (ngx_http_proxy_ctx_t *p);
int (*state_read_upstream_handler) (ngx_http_proxy_ctx_t *p);
int (*state_handler)(ngx_http_proxy_ctx_t *p);
int last_error;
unsigned accel:1;
unsigned cached_connection:1;
};
typedef struct {
char *action;
char *upstream;
char *client;
char *url;
} ngx_http_proxy_log_ctx_t;
extern ngx_module_t ngx_http_proxy_module;
static int ngx_http_proxy_error(ngx_http_request_t *r, ngx_http_proxy_ctx_t *p,
int error);
#endif /* _NGX_HTTP_PROXY_HANDLER_H_INCLUDED_ */
|