Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_proxy_module.c @ 5924:58956c644ad0
Typo.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 28 Nov 2014 16:57:23 +0300 |
parents | 29fa5023bd6f |
children | 2d3908516101 |
rev | line source |
---|---|
507 | 1 |
577 | 2 /* |
507 | 3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
507 | 5 */ |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 #include <ngx_http.h> | |
11 | |
12 | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
13 typedef struct ngx_http_proxy_rewrite_s ngx_http_proxy_rewrite_t; |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
14 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
15 typedef ngx_int_t (*ngx_http_proxy_rewrite_pt)(ngx_http_request_t *r, |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
16 ngx_table_elt_t *h, size_t prefix, size_t len, |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
17 ngx_http_proxy_rewrite_t *pr); |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
18 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
19 struct ngx_http_proxy_rewrite_s { |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
20 ngx_http_proxy_rewrite_pt handler; |
507 | 21 |
509 | 22 union { |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
23 ngx_http_complex_value_t complex; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
24 #if (NGX_PCRE) |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
25 ngx_http_regex_t *regex; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
26 #endif |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
27 } pattern; |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
28 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
29 ngx_http_complex_value_t replacement; |
509 | 30 }; |
31 | |
32 | |
33 typedef struct { | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
34 ngx_str_t key_start; |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2285
diff
changeset
|
35 ngx_str_t schema; |
1658 | 36 ngx_str_t host_header; |
37 ngx_str_t port; | |
38 ngx_str_t uri; | |
39 } ngx_http_proxy_vars_t; | |
40 | |
41 | |
42 typedef struct { | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
43 ngx_array_t *flushes; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
44 ngx_array_t *lengths; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
45 ngx_array_t *values; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
46 ngx_hash_t hash; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
47 } ngx_http_proxy_headers_t; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
48 |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
49 |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
50 typedef struct { |
651 | 51 ngx_http_upstream_conf_t upstream; |
52 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
53 ngx_array_t *body_flushes; |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
54 ngx_array_t *body_lengths; |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
55 ngx_array_t *body_values; |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
56 ngx_str_t body_source; |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
57 |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
58 ngx_http_proxy_headers_t headers; |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
59 #if (NGX_HTTP_CACHE) |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
60 ngx_http_proxy_headers_t headers_cache; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
61 #endif |
651 | 62 ngx_array_t *headers_source; |
63 | |
1658 | 64 ngx_array_t *proxy_lengths; |
65 ngx_array_t *proxy_values; | |
66 | |
651 | 67 ngx_array_t *redirects; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
68 ngx_array_t *cookie_domains; |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
69 ngx_array_t *cookie_paths; |
651 | 70 |
71 ngx_str_t method; | |
1658 | 72 ngx_str_t location; |
73 ngx_str_t url; | |
74 | |
2672 | 75 #if (NGX_HTTP_CACHE) |
76 ngx_http_complex_value_t cache_key; | |
77 #endif | |
78 | |
1658 | 79 ngx_http_proxy_vars_t vars; |
651 | 80 |
81 ngx_flag_t redirect; | |
1180
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
82 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
83 ngx_uint_t http_version; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
84 |
1180
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
85 ngx_uint_t headers_hash_max_size; |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
86 ngx_uint_t headers_hash_bucket_size; |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
87 |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
88 #if (NGX_HTTP_SSL) |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
89 ngx_uint_t ssl; |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
90 ngx_uint_t ssl_protocols; |
5390
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
91 ngx_str_t ssl_ciphers; |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
92 ngx_uint_t ssl_verify_depth; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
93 ngx_str_t ssl_trusted_certificate; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
94 ngx_str_t ssl_crl; |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
95 ngx_str_t ssl_certificate; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
96 ngx_str_t ssl_certificate_key; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
97 ngx_array_t *ssl_passwords; |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
98 #endif |
507 | 99 } ngx_http_proxy_loc_conf_t; |
100 | |
101 | |
102 typedef struct { | |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
103 ngx_http_status_t status; |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
104 ngx_http_chunked_t chunked; |
1658 | 105 ngx_http_proxy_vars_t vars; |
4927
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
106 off_t internal_body_length; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
107 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
108 ngx_uint_t head; /* unsigned head:1 */ |
509 | 109 } ngx_http_proxy_ctx_t; |
507 | 110 |
111 | |
1658 | 112 static ngx_int_t ngx_http_proxy_eval(ngx_http_request_t *r, |
113 ngx_http_proxy_ctx_t *ctx, ngx_http_proxy_loc_conf_t *plcf); | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
114 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
115 static ngx_int_t ngx_http_proxy_create_key(ngx_http_request_t *r); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
116 #endif |
507 | 117 static ngx_int_t ngx_http_proxy_create_request(ngx_http_request_t *r); |
118 static ngx_int_t ngx_http_proxy_reinit_request(ngx_http_request_t *r); | |
509 | 119 static ngx_int_t ngx_http_proxy_process_status_line(ngx_http_request_t *r); |
507 | 120 static ngx_int_t ngx_http_proxy_process_header(ngx_http_request_t *r); |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
121 static ngx_int_t ngx_http_proxy_input_filter_init(void *data); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
122 static ngx_int_t ngx_http_proxy_copy_filter(ngx_event_pipe_t *p, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
123 ngx_buf_t *buf); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
124 static ngx_int_t ngx_http_proxy_chunked_filter(ngx_event_pipe_t *p, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
125 ngx_buf_t *buf); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
126 static ngx_int_t ngx_http_proxy_non_buffered_copy_filter(void *data, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
127 ssize_t bytes); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
128 static ngx_int_t ngx_http_proxy_non_buffered_chunked_filter(void *data, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
129 ssize_t bytes); |
507 | 130 static void ngx_http_proxy_abort_request(ngx_http_request_t *r); |
131 static void ngx_http_proxy_finalize_request(ngx_http_request_t *r, | |
132 ngx_int_t rc); | |
133 | |
573 | 134 static ngx_int_t ngx_http_proxy_host_variable(ngx_http_request_t *r, |
135 ngx_http_variable_value_t *v, uintptr_t data); | |
136 static ngx_int_t ngx_http_proxy_port_variable(ngx_http_request_t *r, | |
137 ngx_http_variable_value_t *v, uintptr_t data); | |
138 static ngx_int_t | |
509 | 139 ngx_http_proxy_add_x_forwarded_for_variable(ngx_http_request_t *r, |
573 | 140 ngx_http_variable_value_t *v, uintptr_t data); |
577 | 141 static ngx_int_t |
142 ngx_http_proxy_internal_body_length_variable(ngx_http_request_t *r, | |
143 ngx_http_variable_value_t *v, uintptr_t data); | |
509 | 144 static ngx_int_t ngx_http_proxy_rewrite_redirect(ngx_http_request_t *r, |
145 ngx_table_elt_t *h, size_t prefix); | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
146 static ngx_int_t ngx_http_proxy_rewrite_cookie(ngx_http_request_t *r, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
147 ngx_table_elt_t *h); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
148 static ngx_int_t ngx_http_proxy_rewrite_cookie_value(ngx_http_request_t *r, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
149 ngx_table_elt_t *h, u_char *value, ngx_array_t *rewrites); |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
150 static ngx_int_t ngx_http_proxy_rewrite(ngx_http_request_t *r, |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
151 ngx_table_elt_t *h, size_t prefix, size_t len, ngx_str_t *replacement); |
507 | 152 |
509 | 153 static ngx_int_t ngx_http_proxy_add_variables(ngx_conf_t *cf); |
507 | 154 static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf); |
155 static char *ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, | |
156 void *parent, void *child); | |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
157 static ngx_int_t ngx_http_proxy_init_headers(ngx_conf_t *cf, |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
158 ngx_http_proxy_loc_conf_t *conf, ngx_http_proxy_headers_t *headers, |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
159 ngx_keyval_t *default_headers); |
507 | 160 |
161 static char *ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, | |
162 void *conf); | |
509 | 163 static char *ngx_http_proxy_redirect(ngx_conf_t *cf, ngx_command_t *cmd, |
164 void *conf); | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
165 static char *ngx_http_proxy_cookie_domain(ngx_conf_t *cf, ngx_command_t *cmd, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
166 void *conf); |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
167 static char *ngx_http_proxy_cookie_path(ngx_conf_t *cf, ngx_command_t *cmd, |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
168 void *conf); |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
169 static char *ngx_http_proxy_store(ngx_conf_t *cf, ngx_command_t *cmd, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
170 void *conf); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
171 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
172 static char *ngx_http_proxy_cache(ngx_conf_t *cf, ngx_command_t *cmd, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
173 void *conf); |
2672 | 174 static char *ngx_http_proxy_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, |
175 void *conf); | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
176 #endif |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
177 #if (NGX_HTTP_SSL) |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
178 static char *ngx_http_proxy_ssl_password_file(ngx_conf_t *cf, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
179 ngx_command_t *cmd, void *conf); |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
180 #endif |
507 | 181 |
182 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data); | |
183 | |
4463
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
184 static ngx_int_t ngx_http_proxy_rewrite_regex(ngx_conf_t *cf, |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
185 ngx_http_proxy_rewrite_t *pr, ngx_str_t *regex, ngx_uint_t caseless); |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
186 |
1658 | 187 #if (NGX_HTTP_SSL) |
188 static ngx_int_t ngx_http_proxy_set_ssl(ngx_conf_t *cf, | |
189 ngx_http_proxy_loc_conf_t *plcf); | |
190 #endif | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
191 static void ngx_http_proxy_set_vars(ngx_url_t *u, ngx_http_proxy_vars_t *v); |
1658 | 192 |
509 | 193 |
507 | 194 static ngx_conf_post_t ngx_http_proxy_lowat_post = |
509 | 195 { ngx_http_proxy_lowat_check }; |
196 | |
507 | 197 |
198 static ngx_conf_bitmask_t ngx_http_proxy_next_upstream_masks[] = { | |
199 { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR }, | |
200 { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT }, | |
201 { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER }, | |
202 { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 }, | |
2268
33556140681a
*) ngx_http_upstream_test_next()
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
203 { ngx_string("http_502"), NGX_HTTP_UPSTREAM_FT_HTTP_502 }, |
623 | 204 { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 }, |
2268
33556140681a
*) ngx_http_upstream_test_next()
Igor Sysoev <igor@sysoev.ru>
parents:
2256
diff
changeset
|
205 { ngx_string("http_504"), NGX_HTTP_UPSTREAM_FT_HTTP_504 }, |
5231
05c53652e7b4
Upstream: http_403 support in proxy_next_upstream (and friends).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5211
diff
changeset
|
206 { ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 }, |
507 | 207 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 }, |
2927
55ceaef03d34
proxy_cache_use_stale/fastcgi_cache_use_stale updating
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
208 { ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING }, |
665 | 209 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF }, |
507 | 210 { ngx_null_string, 0 } |
211 }; | |
212 | |
213 | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
214 #if (NGX_HTTP_SSL) |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
215 |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
216 static ngx_conf_bitmask_t ngx_http_proxy_ssl_protocols[] = { |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
217 { ngx_string("SSLv2"), NGX_SSL_SSLv2 }, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
218 { ngx_string("SSLv3"), NGX_SSL_SSLv3 }, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
219 { ngx_string("TLSv1"), NGX_SSL_TLSv1 }, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
220 { ngx_string("TLSv1.1"), NGX_SSL_TLSv1_1 }, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
221 { ngx_string("TLSv1.2"), NGX_SSL_TLSv1_2 }, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
222 { ngx_null_string, 0 } |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
223 }; |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
224 |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
225 #endif |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
226 |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
227 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
228 static ngx_conf_enum_t ngx_http_proxy_http_version[] = { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
229 { ngx_string("1.0"), NGX_HTTP_VERSION_10 }, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
230 { ngx_string("1.1"), NGX_HTTP_VERSION_11 }, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
231 { ngx_null_string, 0 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
232 }; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
233 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
234 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
235 ngx_module_t ngx_http_proxy_module; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
236 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
237 |
507 | 238 static ngx_command_t ngx_http_proxy_commands[] = { |
239 | |
240 { ngx_string("proxy_pass"), | |
843
ebab9490204c
allow proxy_pass inside limit_except
Igor Sysoev <igor@sysoev.ru>
parents:
812
diff
changeset
|
241 NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_HTTP_LMT_CONF|NGX_CONF_TAKE1, |
507 | 242 ngx_http_proxy_pass, |
243 NGX_HTTP_LOC_CONF_OFFSET, | |
244 0, | |
245 NULL }, | |
246 | |
509 | 247 { ngx_string("proxy_redirect"), |
248 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12, | |
249 ngx_http_proxy_redirect, | |
250 NGX_HTTP_LOC_CONF_OFFSET, | |
251 0, | |
252 NULL }, | |
253 | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
254 { ngx_string("proxy_cookie_domain"), |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
255 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
256 ngx_http_proxy_cookie_domain, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
257 NGX_HTTP_LOC_CONF_OFFSET, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
258 0, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
259 NULL }, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
260 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
261 { ngx_string("proxy_cookie_path"), |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
262 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12, |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
263 ngx_http_proxy_cookie_path, |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
264 NGX_HTTP_LOC_CONF_OFFSET, |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
265 0, |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
266 NULL }, |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
267 |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1244
diff
changeset
|
268 { ngx_string("proxy_store"), |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
269 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
270 ngx_http_proxy_store, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
271 NGX_HTTP_LOC_CONF_OFFSET, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
272 0, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
273 NULL }, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
274 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
275 { ngx_string("proxy_store_access"), |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1244
diff
changeset
|
276 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE123, |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1244
diff
changeset
|
277 ngx_conf_set_access_slot, |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1244
diff
changeset
|
278 NGX_HTTP_LOC_CONF_OFFSET, |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
279 offsetof(ngx_http_proxy_loc_conf_t, upstream.store_access), |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1244
diff
changeset
|
280 NULL }, |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1244
diff
changeset
|
281 |
581 | 282 { ngx_string("proxy_buffering"), |
283 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
284 ngx_conf_set_flag_slot, | |
285 NGX_HTTP_LOC_CONF_OFFSET, | |
286 offsetof(ngx_http_proxy_loc_conf_t, upstream.buffering), | |
287 NULL }, | |
288 | |
629 | 289 { ngx_string("proxy_ignore_client_abort"), |
290 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
291 ngx_conf_set_flag_slot, | |
292 NGX_HTTP_LOC_CONF_OFFSET, | |
293 offsetof(ngx_http_proxy_loc_conf_t, upstream.ignore_client_abort), | |
294 NULL }, | |
295 | |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
296 { ngx_string("proxy_bind"), |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
297 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
3399 | 298 ngx_http_upstream_bind_set_slot, |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
299 NGX_HTTP_LOC_CONF_OFFSET, |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
300 offsetof(ngx_http_proxy_loc_conf_t, upstream.local), |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
301 NULL }, |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
302 |
507 | 303 { ngx_string("proxy_connect_timeout"), |
304 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
305 ngx_conf_set_msec_slot, | |
306 NGX_HTTP_LOC_CONF_OFFSET, | |
307 offsetof(ngx_http_proxy_loc_conf_t, upstream.connect_timeout), | |
308 NULL }, | |
309 | |
310 { ngx_string("proxy_send_timeout"), | |
311 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
312 ngx_conf_set_msec_slot, | |
313 NGX_HTTP_LOC_CONF_OFFSET, | |
314 offsetof(ngx_http_proxy_loc_conf_t, upstream.send_timeout), | |
315 NULL }, | |
316 | |
317 { ngx_string("proxy_send_lowat"), | |
318 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
319 ngx_conf_set_size_slot, | |
320 NGX_HTTP_LOC_CONF_OFFSET, | |
321 offsetof(ngx_http_proxy_loc_conf_t, upstream.send_lowat), | |
322 &ngx_http_proxy_lowat_post }, | |
323 | |
657 | 324 { ngx_string("proxy_intercept_errors"), |
325 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
326 ngx_conf_set_flag_slot, | |
327 NGX_HTTP_LOC_CONF_OFFSET, | |
328 offsetof(ngx_http_proxy_loc_conf_t, upstream.intercept_errors), | |
329 NULL }, | |
330 | |
509 | 331 { ngx_string("proxy_set_header"), |
332 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | |
649 | 333 ngx_conf_set_keyval_slot, |
507 | 334 NGX_HTTP_LOC_CONF_OFFSET, |
509 | 335 offsetof(ngx_http_proxy_loc_conf_t, headers_source), |
507 | 336 NULL }, |
337 | |
1180
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
338 { ngx_string("proxy_headers_hash_max_size"), |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
339 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
340 ngx_conf_set_num_slot, |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
341 NGX_HTTP_LOC_CONF_OFFSET, |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
342 offsetof(ngx_http_proxy_loc_conf_t, headers_hash_max_size), |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
343 NULL }, |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
344 |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
345 { ngx_string("proxy_headers_hash_bucket_size"), |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
346 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
347 ngx_conf_set_num_slot, |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
348 NGX_HTTP_LOC_CONF_OFFSET, |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
349 offsetof(ngx_http_proxy_loc_conf_t, headers_hash_bucket_size), |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
350 NULL }, |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
351 |
577 | 352 { ngx_string("proxy_set_body"), |
353 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
354 ngx_conf_set_str_slot, | |
355 NGX_HTTP_LOC_CONF_OFFSET, | |
356 offsetof(ngx_http_proxy_loc_conf_t, body_source), | |
357 NULL }, | |
358 | |
509 | 359 { ngx_string("proxy_method"), |
360 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
561 | 361 ngx_conf_set_str_slot, |
509 | 362 NGX_HTTP_LOC_CONF_OFFSET, |
561 | 363 offsetof(ngx_http_proxy_loc_conf_t, method), |
364 NULL }, | |
509 | 365 |
366 { ngx_string("proxy_pass_request_headers"), | |
507 | 367 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
368 ngx_conf_set_flag_slot, | |
369 NGX_HTTP_LOC_CONF_OFFSET, | |
509 | 370 offsetof(ngx_http_proxy_loc_conf_t, upstream.pass_request_headers), |
507 | 371 NULL }, |
372 | |
509 | 373 { ngx_string("proxy_pass_request_body"), |
507 | 374 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
375 ngx_conf_set_flag_slot, | |
376 NGX_HTTP_LOC_CONF_OFFSET, | |
509 | 377 offsetof(ngx_http_proxy_loc_conf_t, upstream.pass_request_body), |
507 | 378 NULL }, |
379 | |
581 | 380 { ngx_string("proxy_buffer_size"), |
381 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
382 ngx_conf_set_size_slot, | |
383 NGX_HTTP_LOC_CONF_OFFSET, | |
384 offsetof(ngx_http_proxy_loc_conf_t, upstream.buffer_size), | |
385 NULL }, | |
386 | |
507 | 387 { ngx_string("proxy_read_timeout"), |
388 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
389 ngx_conf_set_msec_slot, | |
390 NGX_HTTP_LOC_CONF_OFFSET, | |
391 offsetof(ngx_http_proxy_loc_conf_t, upstream.read_timeout), | |
392 NULL }, | |
393 | |
394 { ngx_string("proxy_buffers"), | |
395 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | |
396 ngx_conf_set_bufs_slot, | |
397 NGX_HTTP_LOC_CONF_OFFSET, | |
398 offsetof(ngx_http_proxy_loc_conf_t, upstream.bufs), | |
399 NULL }, | |
400 | |
401 { ngx_string("proxy_busy_buffers_size"), | |
402 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
403 ngx_conf_set_size_slot, | |
404 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 405 offsetof(ngx_http_proxy_loc_conf_t, upstream.busy_buffers_size_conf), |
507 | 406 NULL }, |
407 | |
5874
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
408 { ngx_string("proxy_force_ranges"), |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
409 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
410 ngx_conf_set_flag_slot, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
411 NGX_HTTP_LOC_CONF_OFFSET, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
412 offsetof(ngx_http_proxy_loc_conf_t, upstream.force_ranges), |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
413 NULL }, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
414 |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
415 { ngx_string("proxy_limit_rate"), |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
416 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
417 ngx_conf_set_size_slot, |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
418 NGX_HTTP_LOC_CONF_OFFSET, |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
419 offsetof(ngx_http_proxy_loc_conf_t, upstream.limit_rate), |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
420 NULL }, |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
421 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
422 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
423 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
424 { ngx_string("proxy_cache"), |
3729 | 425 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
426 ngx_http_proxy_cache, |
2597 | 427 NGX_HTTP_LOC_CONF_OFFSET, |
2596 | 428 0, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
429 NULL }, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
430 |
2672 | 431 { ngx_string("proxy_cache_key"), |
3729 | 432 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
2672 | 433 ngx_http_proxy_cache_key, |
434 NGX_HTTP_LOC_CONF_OFFSET, | |
435 0, | |
436 NULL }, | |
437 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
438 { ngx_string("proxy_cache_path"), |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
439 NGX_HTTP_MAIN_CONF|NGX_CONF_2MORE, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
440 ngx_http_file_cache_set_slot, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
441 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
442 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
443 &ngx_http_proxy_module }, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
444 |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
445 { ngx_string("proxy_cache_bypass"), |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
446 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
447 ngx_http_set_predicate_slot, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
448 NGX_HTTP_LOC_CONF_OFFSET, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
449 offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_bypass), |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
450 NULL }, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
451 |
3526
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
452 { ngx_string("proxy_no_cache"), |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
453 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
3692
045ea40cbfe8
use ngx_http_test_predicates(), ngx_http_set_predicate_slot()
Igor Sysoev <igor@sysoev.ru>
parents:
3670
diff
changeset
|
454 ngx_http_set_predicate_slot, |
3526
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
455 NGX_HTTP_LOC_CONF_OFFSET, |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
456 offsetof(ngx_http_proxy_loc_conf_t, upstream.no_cache), |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
457 NULL }, |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
458 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
459 { ngx_string("proxy_cache_valid"), |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
460 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
461 ngx_http_file_cache_valid_set_slot, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
462 NGX_HTTP_LOC_CONF_OFFSET, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
463 offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_valid), |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
464 NULL }, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
465 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
466 { ngx_string("proxy_cache_min_uses"), |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
467 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
468 ngx_conf_set_num_slot, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
469 NGX_HTTP_LOC_CONF_OFFSET, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
470 offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_min_uses), |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
471 NULL }, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
472 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
473 { ngx_string("proxy_cache_use_stale"), |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
474 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
475 ngx_conf_set_bitmask_slot, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
476 NGX_HTTP_LOC_CONF_OFFSET, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
477 offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_use_stale), |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
478 &ngx_http_proxy_next_upstream_masks }, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
479 |
2875
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
480 { ngx_string("proxy_cache_methods"), |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
481 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
482 ngx_conf_set_bitmask_slot, |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
483 NGX_HTTP_LOC_CONF_OFFSET, |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
484 offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_methods), |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
485 &ngx_http_upstream_cache_method_mask }, |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
486 |
4385
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
487 { ngx_string("proxy_cache_lock"), |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
488 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
489 ngx_conf_set_flag_slot, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
490 NGX_HTTP_LOC_CONF_OFFSET, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
491 offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_lock), |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
492 NULL }, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
493 |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
494 { ngx_string("proxy_cache_lock_timeout"), |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
495 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
496 ngx_conf_set_msec_slot, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
497 NGX_HTTP_LOC_CONF_OFFSET, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
498 offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_lock_timeout), |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
499 NULL }, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
500 |
5905
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
501 { ngx_string("proxy_cache_lock_age"), |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
502 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
503 ngx_conf_set_msec_slot, |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
504 NGX_HTTP_LOC_CONF_OFFSET, |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
505 offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_lock_age), |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
506 NULL }, |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
507 |
5441
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
508 { ngx_string("proxy_cache_revalidate"), |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
509 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
510 ngx_conf_set_flag_slot, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
511 NGX_HTTP_LOC_CONF_OFFSET, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
512 offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_revalidate), |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
513 NULL }, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
514 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
515 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
516 |
507 | 517 { ngx_string("proxy_temp_path"), |
518 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, | |
519 ngx_conf_set_path_slot, | |
520 NGX_HTTP_LOC_CONF_OFFSET, | |
521 offsetof(ngx_http_proxy_loc_conf_t, upstream.temp_path), | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
522 NULL }, |
507 | 523 |
524 { ngx_string("proxy_max_temp_file_size"), | |
525 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
526 ngx_conf_set_size_slot, | |
527 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 528 offsetof(ngx_http_proxy_loc_conf_t, upstream.max_temp_file_size_conf), |
507 | 529 NULL }, |
530 | |
531 { ngx_string("proxy_temp_file_write_size"), | |
532 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
533 ngx_conf_set_size_slot, | |
534 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 535 offsetof(ngx_http_proxy_loc_conf_t, upstream.temp_file_write_size_conf), |
507 | 536 NULL }, |
537 | |
538 { ngx_string("proxy_next_upstream"), | |
547 | 539 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
507 | 540 ngx_conf_set_bitmask_slot, |
541 NGX_HTTP_LOC_CONF_OFFSET, | |
542 offsetof(ngx_http_proxy_loc_conf_t, upstream.next_upstream), | |
543 &ngx_http_proxy_next_upstream_masks }, | |
544 | |
5832
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
545 { ngx_string("proxy_next_upstream_tries"), |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
546 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
547 ngx_conf_set_num_slot, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
548 NGX_HTTP_LOC_CONF_OFFSET, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
549 offsetof(ngx_http_proxy_loc_conf_t, upstream.next_upstream_tries), |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
550 NULL }, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
551 |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
552 { ngx_string("proxy_next_upstream_timeout"), |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
553 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
554 ngx_conf_set_msec_slot, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
555 NGX_HTTP_LOC_CONF_OFFSET, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
556 offsetof(ngx_http_proxy_loc_conf_t, upstream.next_upstream_timeout), |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
557 NULL }, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
558 |
649 | 559 { ngx_string("proxy_pass_header"), |
3729 | 560 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
649 | 561 ngx_conf_set_str_array_slot, |
507 | 562 NGX_HTTP_LOC_CONF_OFFSET, |
649 | 563 offsetof(ngx_http_proxy_loc_conf_t, upstream.pass_headers), |
507 | 564 NULL }, |
565 | |
649 | 566 { ngx_string("proxy_hide_header"), |
3729 | 567 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
649 | 568 ngx_conf_set_str_array_slot, |
507 | 569 NGX_HTTP_LOC_CONF_OFFSET, |
649 | 570 offsetof(ngx_http_proxy_loc_conf_t, upstream.hide_headers), |
507 | 571 NULL }, |
572 | |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
573 { ngx_string("proxy_ignore_headers"), |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
574 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
575 ngx_conf_set_bitmask_slot, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
576 NGX_HTTP_LOC_CONF_OFFSET, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
577 offsetof(ngx_http_proxy_loc_conf_t, upstream.ignore_headers), |
3667
12bd9e26fadb
use shared ngx_http_upstream_ignore_headers_masks[]
Igor Sysoev <igor@sysoev.ru>
parents:
3629
diff
changeset
|
578 &ngx_http_upstream_ignore_headers_masks }, |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
579 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
580 { ngx_string("proxy_http_version"), |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
581 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
582 ngx_conf_set_enum_slot, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
583 NGX_HTTP_LOC_CONF_OFFSET, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
584 offsetof(ngx_http_proxy_loc_conf_t, http_version), |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
585 &ngx_http_proxy_http_version }, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
586 |
2184 | 587 #if (NGX_HTTP_SSL) |
588 | |
589 { ngx_string("proxy_ssl_session_reuse"), | |
590 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
591 ngx_conf_set_flag_slot, | |
592 NGX_HTTP_LOC_CONF_OFFSET, | |
593 offsetof(ngx_http_proxy_loc_conf_t, upstream.ssl_session_reuse), | |
594 NULL }, | |
595 | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
596 { ngx_string("proxy_ssl_protocols"), |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
597 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
598 ngx_conf_set_bitmask_slot, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
599 NGX_HTTP_LOC_CONF_OFFSET, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
600 offsetof(ngx_http_proxy_loc_conf_t, ssl_protocols), |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
601 &ngx_http_proxy_ssl_protocols }, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
602 |
5390
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
603 { ngx_string("proxy_ssl_ciphers"), |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
604 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
605 ngx_conf_set_str_slot, |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
606 NGX_HTTP_LOC_CONF_OFFSET, |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
607 offsetof(ngx_http_proxy_loc_conf_t, ssl_ciphers), |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
608 NULL }, |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
609 |
5660
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
610 { ngx_string("proxy_ssl_name"), |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
611 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
612 ngx_http_set_complex_value_slot, |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
613 NGX_HTTP_LOC_CONF_OFFSET, |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
614 offsetof(ngx_http_proxy_loc_conf_t, upstream.ssl_name), |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
615 NULL }, |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
616 |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
617 { ngx_string("proxy_ssl_server_name"), |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
618 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
619 ngx_conf_set_flag_slot, |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
620 NGX_HTTP_LOC_CONF_OFFSET, |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
621 offsetof(ngx_http_proxy_loc_conf_t, upstream.ssl_server_name), |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
622 NULL }, |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
623 |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
624 { ngx_string("proxy_ssl_verify"), |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
625 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
626 ngx_conf_set_flag_slot, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
627 NGX_HTTP_LOC_CONF_OFFSET, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
628 offsetof(ngx_http_proxy_loc_conf_t, upstream.ssl_verify), |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
629 NULL }, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
630 |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
631 { ngx_string("proxy_ssl_verify_depth"), |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
632 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
633 ngx_conf_set_num_slot, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
634 NGX_HTTP_LOC_CONF_OFFSET, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
635 offsetof(ngx_http_proxy_loc_conf_t, ssl_verify_depth), |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
636 NULL }, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
637 |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
638 { ngx_string("proxy_ssl_trusted_certificate"), |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
639 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
640 ngx_conf_set_str_slot, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
641 NGX_HTTP_LOC_CONF_OFFSET, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
642 offsetof(ngx_http_proxy_loc_conf_t, ssl_trusted_certificate), |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
643 NULL }, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
644 |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
645 { ngx_string("proxy_ssl_crl"), |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
646 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
647 ngx_conf_set_str_slot, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
648 NGX_HTTP_LOC_CONF_OFFSET, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
649 offsetof(ngx_http_proxy_loc_conf_t, ssl_crl), |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
650 NULL }, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
651 |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
652 { ngx_string("proxy_ssl_certificate"), |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
653 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
654 ngx_conf_set_str_slot, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
655 NGX_HTTP_LOC_CONF_OFFSET, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
656 offsetof(ngx_http_proxy_loc_conf_t, ssl_certificate), |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
657 NULL }, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
658 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
659 { ngx_string("proxy_ssl_certificate_key"), |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
660 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
661 ngx_conf_set_str_slot, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
662 NGX_HTTP_LOC_CONF_OFFSET, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
663 offsetof(ngx_http_proxy_loc_conf_t, ssl_certificate_key), |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
664 NULL }, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
665 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
666 { ngx_string("proxy_ssl_password_file"), |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
667 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
668 ngx_http_proxy_ssl_password_file, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
669 NGX_HTTP_LOC_CONF_OFFSET, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
670 0, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
671 NULL }, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
672 |
2184 | 673 #endif |
674 | |
507 | 675 ngx_null_command |
676 }; | |
677 | |
678 | |
667 | 679 static ngx_http_module_t ngx_http_proxy_module_ctx = { |
509 | 680 ngx_http_proxy_add_variables, /* preconfiguration */ |
681 NULL, /* postconfiguration */ | |
507 | 682 |
683 NULL, /* create main configuration */ | |
684 NULL, /* init main configuration */ | |
685 | |
686 NULL, /* create server configuration */ | |
687 NULL, /* merge server configuration */ | |
688 | |
4499
778ef9c3fd2d
Fixed spelling in single-line comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4466
diff
changeset
|
689 ngx_http_proxy_create_loc_conf, /* create location configuration */ |
778ef9c3fd2d
Fixed spelling in single-line comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4466
diff
changeset
|
690 ngx_http_proxy_merge_loc_conf /* merge location configuration */ |
507 | 691 }; |
692 | |
693 | |
694 ngx_module_t ngx_http_proxy_module = { | |
509 | 695 NGX_MODULE_V1, |
507 | 696 &ngx_http_proxy_module_ctx, /* module context */ |
697 ngx_http_proxy_commands, /* module directives */ | |
698 NGX_HTTP_MODULE, /* module type */ | |
541 | 699 NULL, /* init master */ |
509 | 700 NULL, /* init module */ |
541 | 701 NULL, /* init process */ |
702 NULL, /* init thread */ | |
703 NULL, /* exit thread */ | |
704 NULL, /* exit process */ | |
705 NULL, /* exit master */ | |
706 NGX_MODULE_V1_PADDING | |
507 | 707 }; |
708 | |
709 | |
710 static char ngx_http_proxy_version[] = " HTTP/1.0" CRLF; | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
711 static char ngx_http_proxy_version_11[] = " HTTP/1.1" CRLF; |
507 | 712 |
509 | 713 |
649 | 714 static ngx_keyval_t ngx_http_proxy_headers[] = { |
715 { ngx_string("Host"), ngx_string("$proxy_host") }, | |
716 { ngx_string("Connection"), ngx_string("close") }, | |
4927
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
717 { ngx_string("Content-Length"), ngx_string("$proxy_internal_body_length") }, |
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
718 { ngx_string("Transfer-Encoding"), ngx_string("") }, |
649 | 719 { ngx_string("Keep-Alive"), ngx_string("") }, |
2067 | 720 { ngx_string("Expect"), ngx_string("") }, |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
721 { ngx_string("Upgrade"), ngx_string("") }, |
649 | 722 { ngx_null_string, ngx_null_string } |
723 }; | |
724 | |
725 | |
2706
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
726 static ngx_str_t ngx_http_proxy_hide_headers[] = { |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
727 ngx_string("Date"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
728 ngx_string("Server"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
729 ngx_string("X-Pad"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
730 ngx_string("X-Accel-Expires"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
731 ngx_string("X-Accel-Redirect"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
732 ngx_string("X-Accel-Limit-Rate"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
733 ngx_string("X-Accel-Buffering"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
734 ngx_string("X-Accel-Charset"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
735 ngx_null_string |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
736 }; |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
737 |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
738 |
2705
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
739 #if (NGX_HTTP_CACHE) |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
740 |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
741 static ngx_keyval_t ngx_http_proxy_cache_headers[] = { |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
742 { ngx_string("Host"), ngx_string("$proxy_host") }, |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
743 { ngx_string("Connection"), ngx_string("close") }, |
4927
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
744 { ngx_string("Content-Length"), ngx_string("$proxy_internal_body_length") }, |
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
745 { ngx_string("Transfer-Encoding"), ngx_string("") }, |
2705
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
746 { ngx_string("Keep-Alive"), ngx_string("") }, |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
747 { ngx_string("Expect"), ngx_string("") }, |
4276
a0f18c78db3b
Fixed Upgrade header clearing with proxy_cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4275
diff
changeset
|
748 { ngx_string("Upgrade"), ngx_string("") }, |
5441
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
749 { ngx_string("If-Modified-Since"), |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
750 ngx_string("$upstream_cache_last_modified") }, |
2705
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
751 { ngx_string("If-Unmodified-Since"), ngx_string("") }, |
5738
c95d7882dfc9
Upstream: cache revalidation using If-None-Match.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5685
diff
changeset
|
752 { ngx_string("If-None-Match"), ngx_string("$upstream_cache_etag") }, |
2705
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
753 { ngx_string("If-Match"), ngx_string("") }, |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
754 { ngx_string("Range"), ngx_string("") }, |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
755 { ngx_string("If-Range"), ngx_string("") }, |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
756 { ngx_null_string, ngx_null_string } |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
757 }; |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
758 |
2706
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
759 #endif |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
760 |
509 | 761 |
762 static ngx_http_variable_t ngx_http_proxy_vars[] = { | |
763 | |
637 | 764 { ngx_string("proxy_host"), NULL, ngx_http_proxy_host_variable, 0, |
1925
6fd26b0e1009
non cacheable $proxy_host and $proxy_port
Igor Sysoev <igor@sysoev.ru>
parents:
1912
diff
changeset
|
765 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, |
509 | 766 |
637 | 767 { ngx_string("proxy_port"), NULL, ngx_http_proxy_port_variable, 0, |
1925
6fd26b0e1009
non cacheable $proxy_host and $proxy_port
Igor Sysoev <igor@sysoev.ru>
parents:
1912
diff
changeset
|
768 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, |
509 | 769 |
637 | 770 { ngx_string("proxy_add_x_forwarded_for"), NULL, |
583 | 771 ngx_http_proxy_add_x_forwarded_for_variable, 0, NGX_HTTP_VAR_NOHASH, 0 }, |
509 | 772 |
773 #if 0 | |
637 | 774 { ngx_string("proxy_add_via"), NULL, NULL, 0, NGX_HTTP_VAR_NOHASH, 0 }, |
509 | 775 #endif |
776 | |
637 | 777 { ngx_string("proxy_internal_body_length"), NULL, |
5203
bfb99b75833b
Proxy: $proxy_internal_body_length fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5188
diff
changeset
|
778 ngx_http_proxy_internal_body_length_variable, 0, |
bfb99b75833b
Proxy: $proxy_internal_body_length fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5188
diff
changeset
|
779 NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, |
577 | 780 |
637 | 781 { ngx_null_string, NULL, NULL, 0, 0, 0 } |
509 | 782 }; |
507 | 783 |
784 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
785 static ngx_path_init_t ngx_http_proxy_temp_path = { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
786 ngx_string(NGX_HTTP_PROXY_TEMP_PATH), { 1, 2, 0 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
787 }; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
788 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
789 |
507 | 790 static ngx_int_t |
791 ngx_http_proxy_handler(ngx_http_request_t *r) | |
577 | 792 { |
507 | 793 ngx_int_t rc; |
794 ngx_http_upstream_t *u; | |
1658 | 795 ngx_http_proxy_ctx_t *ctx; |
507 | 796 ngx_http_proxy_loc_conf_t *plcf; |
577 | 797 |
3006
95972b9e790b
ngx_http_upstream_create() to cleanup the previous upstream after
Igor Sysoev <igor@sysoev.ru>
parents:
2989
diff
changeset
|
798 if (ngx_http_upstream_create(r) != NGX_OK) { |
507 | 799 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
800 } | |
577 | 801 |
1658 | 802 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_ctx_t)); |
803 if (ctx == NULL) { | |
804 return NGX_ERROR; | |
805 } | |
806 | |
807 ngx_http_set_ctx(r, ctx, ngx_http_proxy_module); | |
808 | |
809 plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module); | |
810 | |
3006
95972b9e790b
ngx_http_upstream_create() to cleanup the previous upstream after
Igor Sysoev <igor@sysoev.ru>
parents:
2989
diff
changeset
|
811 u = r->upstream; |
95972b9e790b
ngx_http_upstream_create() to cleanup the previous upstream after
Igor Sysoev <igor@sysoev.ru>
parents:
2989
diff
changeset
|
812 |
3733 | 813 if (plcf->proxy_lengths == NULL) { |
1658 | 814 ctx->vars = plcf->vars; |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2285
diff
changeset
|
815 u->schema = plcf->vars.schema; |
1658 | 816 #if (NGX_HTTP_SSL) |
817 u->ssl = (plcf->upstream.ssl != NULL); | |
818 #endif | |
819 | |
820 } else { | |
821 if (ngx_http_proxy_eval(r, ctx, plcf) != NGX_OK) { | |
822 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
823 } | |
824 } | |
825 | |
507 | 826 u->output.tag = (ngx_buf_tag_t) &ngx_http_proxy_module; |
827 | |
828 u->conf = &plcf->upstream; | |
829 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
830 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
831 u->create_key = ngx_http_proxy_create_key; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
832 #endif |
507 | 833 u->create_request = ngx_http_proxy_create_request; |
834 u->reinit_request = ngx_http_proxy_reinit_request; | |
509 | 835 u->process_header = ngx_http_proxy_process_status_line; |
507 | 836 u->abort_request = ngx_http_proxy_abort_request; |
837 u->finalize_request = ngx_http_proxy_finalize_request; | |
3477
fb0b7450c2e8
reset a parsing state to parse correctly an upstream response,
Igor Sysoev <igor@sysoev.ru>
parents:
3471
diff
changeset
|
838 r->state = 0; |
507 | 839 |
509 | 840 if (plcf->redirects) { |
841 u->rewrite_redirect = ngx_http_proxy_rewrite_redirect; | |
842 } | |
843 | |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
844 if (plcf->cookie_domains || plcf->cookie_paths) { |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
845 u->rewrite_cookie = ngx_http_proxy_rewrite_cookie; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
846 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
847 |
649 | 848 u->buffering = plcf->upstream.buffering; |
849 | |
850 u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t)); | |
851 if (u->pipe == NULL) { | |
852 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
581 | 853 } |
507 | 854 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
855 u->pipe->input_filter = ngx_http_proxy_copy_filter; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
856 u->pipe->input_ctx = r; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
857 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
858 u->input_filter_init = ngx_http_proxy_input_filter_init; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
859 u->input_filter = ngx_http_proxy_non_buffered_copy_filter; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
860 u->input_filter_ctx = r; |
649 | 861 |
509 | 862 u->accel = 1; |
577 | 863 |
507 | 864 rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init); |
865 | |
866 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | |
867 return rc; | |
868 } | |
869 | |
870 return NGX_DONE; | |
871 } | |
872 | |
873 | |
874 static ngx_int_t | |
1658 | 875 ngx_http_proxy_eval(ngx_http_request_t *r, ngx_http_proxy_ctx_t *ctx, |
876 ngx_http_proxy_loc_conf_t *plcf) | |
877 { | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
878 u_char *p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
879 size_t add; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
880 u_short port; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
881 ngx_str_t proxy; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
882 ngx_url_t url; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
883 ngx_http_upstream_t *u; |
1658 | 884 |
885 if (ngx_http_script_run(r, &proxy, plcf->proxy_lengths->elts, 0, | |
886 plcf->proxy_values->elts) | |
887 == NULL) | |
888 { | |
889 return NGX_ERROR; | |
890 } | |
891 | |
3977
2527cdb8d31f
test length of proxy_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
3976
diff
changeset
|
892 if (proxy.len > 7 |
2527cdb8d31f
test length of proxy_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
3976
diff
changeset
|
893 && ngx_strncasecmp(proxy.data, (u_char *) "http://", 7) == 0) |
2527cdb8d31f
test length of proxy_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
3976
diff
changeset
|
894 { |
1658 | 895 add = 7; |
896 port = 80; | |
897 | |
898 #if (NGX_HTTP_SSL) | |
899 | |
3977
2527cdb8d31f
test length of proxy_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
3976
diff
changeset
|
900 } else if (proxy.len > 8 |
2527cdb8d31f
test length of proxy_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
3976
diff
changeset
|
901 && ngx_strncasecmp(proxy.data, (u_char *) "https://", 8) == 0) |
2527cdb8d31f
test length of proxy_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
3976
diff
changeset
|
902 { |
1658 | 903 add = 8; |
904 port = 443; | |
905 r->upstream->ssl = 1; | |
906 | |
907 #endif | |
908 | |
909 } else { | |
910 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
911 "invalid URL prefix in \"%V\"", &proxy); | |
912 return NGX_ERROR; | |
913 } | |
914 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
915 u = r->upstream; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
916 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
917 u->schema.len = add; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
918 u->schema.data = proxy.data; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
919 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
920 ngx_memzero(&url, sizeof(ngx_url_t)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
921 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
922 url.url.len = proxy.len - add; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
923 url.url.data = proxy.data + add; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
924 url.default_port = port; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
925 url.uri_part = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
926 url.no_resolve = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
927 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
928 if (ngx_parse_url(r->pool, &url) != NGX_OK) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
929 if (url.err) { |
1658 | 930 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
931 "%s in upstream \"%V\"", url.err, &url.url); |
1658 | 932 } |
933 | |
934 return NGX_ERROR; | |
935 } | |
936 | |
3323
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
937 if (url.uri.len) { |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
938 if (url.uri.data[0] == '?') { |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
939 p = ngx_pnalloc(r->pool, url.uri.len + 1); |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
940 if (p == NULL) { |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
941 return NGX_ERROR; |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
942 } |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
943 |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
944 *p++ = '/'; |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
945 ngx_memcpy(p, url.uri.data, url.uri.len); |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
946 |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
947 url.uri.len++; |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
948 url.uri.data = p - 1; |
2284
c3035feb6638
fix case proxy_pass URL is evaluted to http://host?args
Igor Sysoev <igor@sysoev.ru>
parents:
2268
diff
changeset
|
949 } |
c3035feb6638
fix case proxy_pass URL is evaluted to http://host?args
Igor Sysoev <igor@sysoev.ru>
parents:
2268
diff
changeset
|
950 } |
c3035feb6638
fix case proxy_pass URL is evaluted to http://host?args
Igor Sysoev <igor@sysoev.ru>
parents:
2268
diff
changeset
|
951 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
952 ctx->vars.key_start = u->schema; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
953 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
954 ngx_http_proxy_set_vars(&url, &ctx->vars); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
955 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
956 u->resolved = ngx_pcalloc(r->pool, sizeof(ngx_http_upstream_resolved_t)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
957 if (u->resolved == NULL) { |
1658 | 958 return NGX_ERROR; |
959 } | |
960 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
961 if (url.addrs && url.addrs[0].sockaddr) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
962 u->resolved->sockaddr = url.addrs[0].sockaddr; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
963 u->resolved->socklen = url.addrs[0].socklen; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
964 u->resolved->naddrs = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
965 u->resolved->host = url.addrs[0].name; |
2422
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2391
diff
changeset
|
966 |
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2391
diff
changeset
|
967 } else { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
968 u->resolved->host = url.host; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
969 u->resolved->port = (in_port_t) (url.no_port ? port : url.port); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
970 u->resolved->no_port = url.no_port; |
2422
7af1e5fe102c
variable support for unix sockets in fastcgi_pass and proxy_pass
Igor Sysoev <igor@sysoev.ru>
parents:
2391
diff
changeset
|
971 } |
1658 | 972 |
973 return NGX_OK; | |
974 } | |
975 | |
976 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
977 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
978 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
979 static ngx_int_t |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
980 ngx_http_proxy_create_key(ngx_http_request_t *r) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
981 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
982 size_t len, loc_len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
983 u_char *p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
984 uintptr_t escape; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
985 ngx_str_t *key; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
986 ngx_http_upstream_t *u; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
987 ngx_http_proxy_ctx_t *ctx; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
988 ngx_http_proxy_loc_conf_t *plcf; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
989 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
990 u = r->upstream; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
991 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
992 plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
993 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
994 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
995 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
996 key = ngx_array_push(&r->cache->keys); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
997 if (key == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
998 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
999 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1000 |
4947
4251e72b8bb4
Allow the complex value to be defined as an empty string.
Ruslan Ermilov <ru@nginx.com>
parents:
4927
diff
changeset
|
1001 if (plcf->cache_key.value.data) { |
2672 | 1002 |
1003 if (ngx_http_complex_value(r, &plcf->cache_key, key) != NGX_OK) { | |
1004 return NGX_ERROR; | |
1005 } | |
1006 | |
1007 return NGX_OK; | |
1008 } | |
1009 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1010 *key = ctx->vars.key_start; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1011 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1012 key = ngx_array_push(&r->cache->keys); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1013 if (key == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1014 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1015 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1016 |
4377
726a1ca9b52b
Proxy: made proxy_pass with variables more consistent.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4336
diff
changeset
|
1017 if (plcf->proxy_lengths && ctx->vars.uri.len) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1018 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1019 *key = ctx->vars.uri; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1020 u->uri = ctx->vars.uri; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1021 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1022 return NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1023 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1024 } else if (ctx->vars.uri.len == 0 && r->valid_unparsed_uri && r == r->main) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1025 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1026 *key = r->unparsed_uri; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1027 u->uri = r->unparsed_uri; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1028 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1029 return NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1030 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1031 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1032 loc_len = (r->valid_location && ctx->vars.uri.len) ? plcf->location.len : 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1033 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1034 if (r->quoted_uri || r->internal) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1035 escape = 2 * ngx_escape_uri(NULL, r->uri.data + loc_len, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1036 r->uri.len - loc_len, NGX_ESCAPE_URI); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1037 } else { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1038 escape = 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1039 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1040 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1041 len = ctx->vars.uri.len + r->uri.len - loc_len + escape |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1042 + sizeof("?") - 1 + r->args.len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1043 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1044 p = ngx_pnalloc(r->pool, len); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1045 if (p == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1046 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1047 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1048 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1049 key->data = p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1050 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1051 if (r->valid_location) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1052 p = ngx_copy(p, ctx->vars.uri.data, ctx->vars.uri.len); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1053 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1054 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1055 if (escape) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1056 ngx_escape_uri(p, r->uri.data + loc_len, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1057 r->uri.len - loc_len, NGX_ESCAPE_URI); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1058 p += r->uri.len - loc_len + escape; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1059 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1060 } else { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1061 p = ngx_copy(p, r->uri.data + loc_len, r->uri.len - loc_len); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1062 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1063 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1064 if (r->args.len > 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1065 *p++ = '?'; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1066 p = ngx_copy(p, r->args.data, r->args.len); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1067 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1068 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1069 key->len = p - key->data; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1070 u->uri = *key; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1071 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1072 return NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1073 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1074 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1075 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1076 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1077 |
1658 | 1078 static ngx_int_t |
507 | 1079 ngx_http_proxy_create_request(ngx_http_request_t *r) |
1080 { | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1081 size_t len, uri_len, loc_len, body_len; |
509 | 1082 uintptr_t escape; |
1083 ngx_buf_t *b; | |
649 | 1084 ngx_str_t method; |
1085 ngx_uint_t i, unparsed_uri; | |
509 | 1086 ngx_chain_t *cl, *body; |
1087 ngx_list_part_t *part; | |
1088 ngx_table_elt_t *header; | |
1089 ngx_http_upstream_t *u; | |
1658 | 1090 ngx_http_proxy_ctx_t *ctx; |
509 | 1091 ngx_http_script_code_pt code; |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1092 ngx_http_proxy_headers_t *headers; |
509 | 1093 ngx_http_script_engine_t e, le; |
1094 ngx_http_proxy_loc_conf_t *plcf; | |
1095 ngx_http_script_len_code_pt lcode; | |
507 | 1096 |
1097 u = r->upstream; | |
1098 | |
1099 plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module); | |
1100 | |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
1101 #if (NGX_HTTP_CACHE) |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
1102 headers = u->cacheable ? &plcf->headers_cache : &plcf->headers; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
1103 #else |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1104 headers = &plcf->headers; |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
1105 #endif |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1106 |
561 | 1107 if (u->method.len) { |
1108 /* HEAD was changed to GET to cache response */ | |
1109 method = u->method; | |
1110 method.len++; | |
1111 | |
1112 } else if (plcf->method.len) { | |
1113 method = plcf->method; | |
1114 | |
507 | 1115 } else { |
561 | 1116 method = r->method_name; |
1117 method.len++; | |
507 | 1118 } |
1119 | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1120 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1121 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1122 if (method.len == 5 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1123 && ngx_strncasecmp(method.data, (u_char *) "HEAD ", 5) == 0) |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1124 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1125 ctx->head = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1126 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1127 |
1667 | 1128 len = method.len + sizeof(ngx_http_proxy_version) - 1 + sizeof(CRLF) - 1; |
1129 | |
507 | 1130 escape = 0; |
1658 | 1131 loc_len = 0; |
1132 unparsed_uri = 0; | |
1133 | |
4377
726a1ca9b52b
Proxy: made proxy_pass with variables more consistent.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4336
diff
changeset
|
1134 if (plcf->proxy_lengths && ctx->vars.uri.len) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1135 uri_len = ctx->vars.uri.len; |
1658 | 1136 |
1137 } else if (ctx->vars.uri.len == 0 && r->valid_unparsed_uri && r == r->main) | |
1138 { | |
609 | 1139 unparsed_uri = 1; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1140 uri_len = r->unparsed_uri.len; |
507 | 1141 |
1142 } else { | |
1658 | 1143 loc_len = (r->valid_location && ctx->vars.uri.len) ? |
1144 plcf->location.len : 0; | |
1145 | |
3615 | 1146 if (r->quoted_uri || r->space_in_uri || r->internal) { |
509 | 1147 escape = 2 * ngx_escape_uri(NULL, r->uri.data + loc_len, |
1148 r->uri.len - loc_len, NGX_ESCAPE_URI); | |
507 | 1149 } |
1150 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1151 uri_len = ctx->vars.uri.len + r->uri.len - loc_len + escape |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1152 + sizeof("?") - 1 + r->args.len; |
507 | 1153 } |
1154 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1155 if (uri_len == 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1156 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1157 "zero length URI to proxy"); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1158 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1159 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1160 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1161 len += uri_len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1162 |
5211
ecd762770729
Proxy: clear script engine used to calculate lengths.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5203
diff
changeset
|
1163 ngx_memzero(&le, sizeof(ngx_http_script_engine_t)); |
ecd762770729
Proxy: clear script engine used to calculate lengths.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5203
diff
changeset
|
1164 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1165 ngx_http_script_flush_no_cacheable_variables(r, plcf->body_flushes); |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1166 ngx_http_script_flush_no_cacheable_variables(r, headers->flushes); |
573 | 1167 |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
1168 if (plcf->body_lengths) { |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
1169 le.ip = plcf->body_lengths->elts; |
577 | 1170 le.request = r; |
1171 le.flushed = 1; | |
1172 body_len = 0; | |
1173 | |
1174 while (*(uintptr_t *) le.ip) { | |
1175 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
1176 body_len += lcode(&le); | |
1177 } | |
1178 | |
1658 | 1179 ctx->internal_body_length = body_len; |
577 | 1180 len += body_len; |
4927
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
1181 |
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
1182 } else { |
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
1183 ctx->internal_body_length = r->headers_in.content_length_n; |
577 | 1184 } |
1185 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1186 le.ip = headers->lengths->elts; |
509 | 1187 le.request = r; |
573 | 1188 le.flushed = 1; |
507 | 1189 |
509 | 1190 while (*(uintptr_t *) le.ip) { |
1191 while (*(uintptr_t *) le.ip) { | |
1192 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
1193 len += lcode(&le); | |
1194 } | |
1195 le.ip += sizeof(uintptr_t); | |
507 | 1196 } |
1197 | |
1198 | |
509 | 1199 if (plcf->upstream.pass_request_headers) { |
1200 part = &r->headers_in.headers.part; | |
1201 header = part->elts; | |
1202 | |
1203 for (i = 0; /* void */; i++) { | |
507 | 1204 |
509 | 1205 if (i >= part->nelts) { |
1206 if (part->next == NULL) { | |
1207 break; | |
1208 } | |
1209 | |
1210 part = part->next; | |
1211 header = part->elts; | |
577 | 1212 i = 0; |
507 | 1213 } |
1214 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1215 if (ngx_hash_find(&headers->hash, header[i].hash, |
649 | 1216 header[i].lowcase_key, header[i].key.len)) |
509 | 1217 { |
1218 continue; | |
1219 } | |
1220 | |
1221 len += header[i].key.len + sizeof(": ") - 1 | |
1222 + header[i].value.len + sizeof(CRLF) - 1; | |
507 | 1223 } |
509 | 1224 } |
507 | 1225 |
1226 | |
1227 b = ngx_create_temp_buf(r->pool, len); | |
1228 if (b == NULL) { | |
1229 return NGX_ERROR; | |
1230 } | |
1231 | |
1232 cl = ngx_alloc_chain_link(r->pool); | |
1233 if (cl == NULL) { | |
1234 return NGX_ERROR; | |
1235 } | |
1236 | |
1237 cl->buf = b; | |
1238 | |
1239 | |
1240 /* the request line */ | |
1241 | |
573 | 1242 b->last = ngx_copy(b->last, method.data, method.len); |
507 | 1243 |
555 | 1244 u->uri.data = b->last; |
1245 | |
4377
726a1ca9b52b
Proxy: made proxy_pass with variables more consistent.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4336
diff
changeset
|
1246 if (plcf->proxy_lengths && ctx->vars.uri.len) { |
1658 | 1247 b->last = ngx_copy(b->last, ctx->vars.uri.data, ctx->vars.uri.len); |
1248 | |
1249 } else if (unparsed_uri) { | |
573 | 1250 b->last = ngx_copy(b->last, r->unparsed_uri.data, r->unparsed_uri.len); |
1251 | |
507 | 1252 } else { |
555 | 1253 if (r->valid_location) { |
1658 | 1254 b->last = ngx_copy(b->last, ctx->vars.uri.data, ctx->vars.uri.len); |
555 | 1255 } |
551 | 1256 |
507 | 1257 if (escape) { |
509 | 1258 ngx_escape_uri(b->last, r->uri.data + loc_len, |
1259 r->uri.len - loc_len, NGX_ESCAPE_URI); | |
1260 b->last += r->uri.len - loc_len + escape; | |
507 | 1261 |
577 | 1262 } else { |
573 | 1263 b->last = ngx_copy(b->last, r->uri.data + loc_len, |
1264 r->uri.len - loc_len); | |
507 | 1265 } |
1266 | |
1267 if (r->args.len > 0) { | |
1268 *b->last++ = '?'; | |
573 | 1269 b->last = ngx_copy(b->last, r->args.data, r->args.len); |
507 | 1270 } |
1271 } | |
1272 | |
555 | 1273 u->uri.len = b->last - u->uri.data; |
1274 | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1275 if (plcf->http_version == NGX_HTTP_VERSION_11) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1276 b->last = ngx_cpymem(b->last, ngx_http_proxy_version_11, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1277 sizeof(ngx_http_proxy_version_11) - 1); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1278 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1279 } else { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1280 b->last = ngx_cpymem(b->last, ngx_http_proxy_version, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1281 sizeof(ngx_http_proxy_version) - 1); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1282 } |
507 | 1283 |
577 | 1284 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); |
507 | 1285 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1286 e.ip = headers->values->elts; |
507 | 1287 e.pos = b->last; |
509 | 1288 e.request = r; |
573 | 1289 e.flushed = 1; |
507 | 1290 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1291 le.ip = headers->lengths->elts; |
509 | 1292 |
1293 while (*(uintptr_t *) le.ip) { | |
1294 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
515 | 1295 |
1296 /* skip the header line name length */ | |
1297 (void) lcode(&le); | |
509 | 1298 |
1299 if (*(ngx_http_script_len_code_pt *) le.ip) { | |
1300 | |
1301 for (len = 0; *(uintptr_t *) le.ip; len += lcode(&le)) { | |
1302 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
1303 } | |
1304 | |
1305 e.skip = (len == sizeof(CRLF) - 1) ? 1 : 0; | |
1306 | |
1307 } else { | |
1308 e.skip = 0; | |
1309 } | |
1310 | |
1311 le.ip += sizeof(uintptr_t); | |
1312 | |
1313 while (*(uintptr_t *) e.ip) { | |
1314 code = *(ngx_http_script_code_pt *) e.ip; | |
1315 code((ngx_http_script_engine_t *) &e); | |
577 | 1316 } |
509 | 1317 e.ip += sizeof(uintptr_t); |
507 | 1318 } |
1319 | |
1320 b->last = e.pos; | |
1321 | |
1322 | |
509 | 1323 if (plcf->upstream.pass_request_headers) { |
1324 part = &r->headers_in.headers.part; | |
1325 header = part->elts; | |
577 | 1326 |
509 | 1327 for (i = 0; /* void */; i++) { |
507 | 1328 |
509 | 1329 if (i >= part->nelts) { |
1330 if (part->next == NULL) { | |
1331 break; | |
1332 } | |
1333 | |
1334 part = part->next; | |
1335 header = part->elts; | |
577 | 1336 i = 0; |
507 | 1337 } |
1338 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1339 if (ngx_hash_find(&headers->hash, header[i].hash, |
649 | 1340 header[i].lowcase_key, header[i].key.len)) |
509 | 1341 { |
1342 continue; | |
1343 } | |
507 | 1344 |
573 | 1345 b->last = ngx_copy(b->last, header[i].key.data, header[i].key.len); |
507 | 1346 |
509 | 1347 *b->last++ = ':'; *b->last++ = ' '; |
507 | 1348 |
573 | 1349 b->last = ngx_copy(b->last, header[i].value.data, |
1350 header[i].value.len); | |
507 | 1351 |
509 | 1352 *b->last++ = CR; *b->last++ = LF; |
507 | 1353 |
509 | 1354 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1355 "http proxy header: \"%V: %V\"", | |
1356 &header[i].key, &header[i].value); | |
1357 } | |
507 | 1358 } |
1359 | |
577 | 1360 |
507 | 1361 /* add "\r\n" at the header end */ |
1362 *b->last++ = CR; *b->last++ = LF; | |
1363 | |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
1364 if (plcf->body_values) { |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
1365 e.ip = plcf->body_values->elts; |
577 | 1366 e.pos = b->last; |
1367 | |
1368 while (*(uintptr_t *) e.ip) { | |
1369 code = *(ngx_http_script_code_pt *) e.ip; | |
1370 code((ngx_http_script_engine_t *) &e); | |
1371 } | |
579 | 1372 |
1373 b->last = e.pos; | |
577 | 1374 } |
1375 | |
1774 | 1376 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
5685
0cbefdcf82a6
Style: use %N instead of '\n' where appropriate.
Ruslan Ermilov <ru@nginx.com>
parents:
5676
diff
changeset
|
1377 "http proxy header:%N\"%*s\"", |
1774 | 1378 (size_t) (b->last - b->pos), b->pos); |
507 | 1379 |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
1380 if (plcf->body_values == NULL && plcf->upstream.pass_request_body) { |
509 | 1381 |
1382 body = u->request_bufs; | |
1383 u->request_bufs = cl; | |
1384 | |
1385 while (body) { | |
1386 b = ngx_alloc_buf(r->pool); | |
1387 if (b == NULL) { | |
1388 return NGX_ERROR; | |
1389 } | |
1390 | |
1391 ngx_memcpy(b, body->buf, sizeof(ngx_buf_t)); | |
1392 | |
1393 cl->next = ngx_alloc_chain_link(r->pool); | |
1394 if (cl->next == NULL) { | |
1395 return NGX_ERROR; | |
1396 } | |
1397 | |
1398 cl = cl->next; | |
1399 cl->buf = b; | |
1400 | |
1401 body = body->next; | |
1402 } | |
1403 | |
1404 } else { | |
1405 u->request_bufs = cl; | |
1406 } | |
1407 | |
4009
3183165283cc
Fixing proxy_set_body and proxy_pass_request_body with SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3977
diff
changeset
|
1408 b->flush = 1; |
509 | 1409 cl->next = NULL; |
1410 | |
507 | 1411 return NGX_OK; |
1412 } | |
1413 | |
1414 | |
1415 static ngx_int_t | |
1416 ngx_http_proxy_reinit_request(ngx_http_request_t *r) | |
1417 { | |
1658 | 1418 ngx_http_proxy_ctx_t *ctx; |
1419 | |
1420 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
1421 | |
1422 if (ctx == NULL) { | |
509 | 1423 return NGX_OK; |
1424 } | |
1425 | |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1426 ctx->status.code = 0; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1427 ctx->status.count = 0; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1428 ctx->status.start = NULL; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1429 ctx->status.end = NULL; |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
1430 ctx->chunked.state = 0; |
509 | 1431 |
1432 r->upstream->process_header = ngx_http_proxy_process_status_line; | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1433 r->upstream->pipe->input_filter = ngx_http_proxy_copy_filter; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1434 r->upstream->input_filter = ngx_http_proxy_non_buffered_copy_filter; |
3477
fb0b7450c2e8
reset a parsing state to parse correctly an upstream response,
Igor Sysoev <igor@sysoev.ru>
parents:
3471
diff
changeset
|
1435 r->state = 0; |
509 | 1436 |
1437 return NGX_OK; | |
1438 } | |
1439 | |
1440 | |
1441 static ngx_int_t | |
1442 ngx_http_proxy_process_status_line(ngx_http_request_t *r) | |
1443 { | |
3628 | 1444 size_t len; |
509 | 1445 ngx_int_t rc; |
1446 ngx_http_upstream_t *u; | |
1658 | 1447 ngx_http_proxy_ctx_t *ctx; |
1448 | |
1449 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
1450 | |
1451 if (ctx == NULL) { | |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1688
diff
changeset
|
1452 return NGX_ERROR; |
509 | 1453 } |
1454 | |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1455 u = r->upstream; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1456 |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1457 rc = ngx_http_parse_status_line(r, &u->buffer, &ctx->status); |
509 | 1458 |
1459 if (rc == NGX_AGAIN) { | |
1460 return rc; | |
1461 } | |
1462 | |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1463 if (rc == NGX_ERROR) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1464 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1465 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1466 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1467 if (r->cache) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1468 r->http_version = NGX_HTTP_VERSION_9; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1469 return NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1470 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1471 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1472 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1473 |
509 | 1474 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
577 | 1475 "upstream sent no valid HTTP/1.0 header"); |
509 | 1476 |
619 | 1477 #if 0 |
509 | 1478 if (u->accel) { |
1479 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1480 } | |
619 | 1481 #endif |
509 | 1482 |
1483 r->http_version = NGX_HTTP_VERSION_9; | |
1616 | 1484 u->state->status = NGX_HTTP_OK; |
4125
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4009
diff
changeset
|
1485 u->headers_in.connection_close = 1; |
577 | 1486 |
509 | 1487 return NGX_OK; |
1488 } | |
1489 | |
5575
d15822784cf9
Upstream: fix $upstream_status variable.
Piotr Sikora <piotr@cloudflare.com>
parents:
5466
diff
changeset
|
1490 if (u->state && u->state->status == 0) { |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1491 u->state->status = ctx->status.code; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1492 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1493 |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1494 u->headers_in.status_n = ctx->status.code; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1495 |
3628 | 1496 len = ctx->status.end - ctx->status.start; |
1497 u->headers_in.status_line.len = len; | |
1498 | |
1499 u->headers_in.status_line.data = ngx_pnalloc(r->pool, len); | |
529 | 1500 if (u->headers_in.status_line.data == NULL) { |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1688
diff
changeset
|
1501 return NGX_ERROR; |
509 | 1502 } |
573 | 1503 |
3628 | 1504 ngx_memcpy(u->headers_in.status_line.data, ctx->status.start, len); |
509 | 1505 |
1506 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1507 "http proxy status %ui \"%V\"", | |
936 | 1508 u->headers_in.status_n, &u->headers_in.status_line); |
509 | 1509 |
4125
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4009
diff
changeset
|
1510 if (ctx->status.http_version < NGX_HTTP_VERSION_11) { |
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4009
diff
changeset
|
1511 u->headers_in.connection_close = 1; |
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4009
diff
changeset
|
1512 } |
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4009
diff
changeset
|
1513 |
509 | 1514 u->process_header = ngx_http_proxy_process_header; |
1515 | |
1516 return ngx_http_proxy_process_header(r); | |
1517 } | |
1518 | |
1519 | |
1520 static ngx_int_t | |
507 | 1521 ngx_http_proxy_process_header(ngx_http_request_t *r) |
1522 { | |
509 | 1523 ngx_int_t rc; |
1524 ngx_table_elt_t *h; | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1525 ngx_http_upstream_t *u; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1526 ngx_http_proxy_ctx_t *ctx; |
509 | 1527 ngx_http_upstream_header_t *hh; |
1528 ngx_http_upstream_main_conf_t *umcf; | |
1529 | |
1530 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); | |
1531 | |
2024 | 1532 for ( ;; ) { |
509 | 1533 |
2256 | 1534 rc = ngx_http_parse_header_line(r, &r->upstream->buffer, 1); |
509 | 1535 |
1536 if (rc == NGX_OK) { | |
1537 | |
1538 /* a header line has been parsed successfully */ | |
507 | 1539 |
509 | 1540 h = ngx_list_push(&r->upstream->headers_in.headers); |
1541 if (h == NULL) { | |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1688
diff
changeset
|
1542 return NGX_ERROR; |
509 | 1543 } |
1544 | |
1545 h->hash = r->header_hash; | |
1546 | |
1547 h->key.len = r->header_name_end - r->header_name_start; | |
1548 h->value.len = r->header_end - r->header_start; | |
1549 | |
2049 | 1550 h->key.data = ngx_pnalloc(r->pool, |
649 | 1551 h->key.len + 1 + h->value.len + 1 + h->key.len); |
509 | 1552 if (h->key.data == NULL) { |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1688
diff
changeset
|
1553 return NGX_ERROR; |
509 | 1554 } |
1555 | |
1556 h->value.data = h->key.data + h->key.len + 1; | |
649 | 1557 h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1; |
507 | 1558 |
4529
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1559 ngx_memcpy(h->key.data, r->header_name_start, h->key.len); |
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1560 h->key.data[h->key.len] = '\0'; |
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1561 ngx_memcpy(h->value.data, r->header_start, h->value.len); |
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1562 h->value.data[h->value.len] = '\0'; |
509 | 1563 |
649 | 1564 if (h->key.len == r->lowcase_index) { |
1565 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
1566 | |
1567 } else { | |
2135 | 1568 ngx_strlow(h->lowcase_key, h->key.data, h->key.len); |
509 | 1569 } |
1570 | |
649 | 1571 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash, |
1572 h->lowcase_key, h->key.len); | |
1573 | |
1574 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { | |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1688
diff
changeset
|
1575 return NGX_ERROR; |
649 | 1576 } |
1577 | |
509 | 1578 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1579 "http proxy header: \"%V: %V\"", | |
1580 &h->key, &h->value); | |
1581 | |
1582 continue; | |
1583 } | |
1584 | |
1585 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { | |
1586 | |
1587 /* a whole header has been parsed successfully */ | |
1588 | |
1589 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1590 "http proxy header done"); | |
1591 | |
649 | 1592 /* |
1593 * if no "Server" and "Date" in header line, | |
1594 * then add the special empty headers | |
1595 */ | |
1596 | |
1597 if (r->upstream->headers_in.server == NULL) { | |
1598 h = ngx_list_push(&r->upstream->headers_in.headers); | |
1599 if (h == NULL) { | |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1688
diff
changeset
|
1600 return NGX_ERROR; |
649 | 1601 } |
1602 | |
1603 h->hash = ngx_hash(ngx_hash(ngx_hash(ngx_hash( | |
1604 ngx_hash('s', 'e'), 'r'), 'v'), 'e'), 'r'); | |
1605 | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
1606 ngx_str_set(&h->key, "Server"); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
1607 ngx_str_null(&h->value); |
649 | 1608 h->lowcase_key = (u_char *) "server"; |
1609 } | |
1610 | |
1611 if (r->upstream->headers_in.date == NULL) { | |
1612 h = ngx_list_push(&r->upstream->headers_in.headers); | |
1613 if (h == NULL) { | |
1699
976db8c6fb64
return NGX_ERROR instead of NGX_HTTP_INTERNAL_SERVER_ERROR in u->parse_header()
Igor Sysoev <igor@sysoev.ru>
parents:
1688
diff
changeset
|
1614 return NGX_ERROR; |
649 | 1615 } |
1616 | |
1617 h->hash = ngx_hash(ngx_hash(ngx_hash('d', 'a'), 't'), 'e'); | |
1618 | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
1619 ngx_str_set(&h->key, "Date"); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
1620 ngx_str_null(&h->value); |
649 | 1621 h->lowcase_key = (u_char *) "date"; |
1622 } | |
1623 | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1624 /* clear content length if response is chunked */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1625 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1626 u = r->upstream; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1627 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1628 if (u->headers_in.chunked) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1629 u->headers_in.content_length_n = -1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1630 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1631 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1632 /* |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1633 * set u->keepalive if response has no body; this allows to keep |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1634 * connections alive in case of r->header_only or X-Accel-Redirect |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1635 */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1636 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1637 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1638 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1639 if (u->headers_in.status_n == NGX_HTTP_NO_CONTENT |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1640 || u->headers_in.status_n == NGX_HTTP_NOT_MODIFIED |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1641 || ctx->head |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1642 || (!u->headers_in.chunked |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1643 && u->headers_in.content_length_n == 0)) |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1644 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1645 u->keepalive = !u->headers_in.connection_close; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1646 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1647 |
5072
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
1648 if (u->headers_in.status_n == NGX_HTTP_SWITCHING_PROTOCOLS) { |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
1649 u->keepalive = 0; |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
1650 |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
1651 if (r->headers_in.upgrade) { |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
1652 u->upgrade = 1; |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
1653 } |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
1654 } |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
1655 |
509 | 1656 return NGX_OK; |
1657 } | |
1658 | |
521 | 1659 if (rc == NGX_AGAIN) { |
1660 return NGX_AGAIN; | |
1661 } | |
1662 | |
509 | 1663 /* there was error while a header line parsing */ |
1664 | |
1665 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
619 | 1666 "upstream sent invalid header"); |
509 | 1667 |
1668 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1669 } | |
507 | 1670 } |
1671 | |
1672 | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1673 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1674 ngx_http_proxy_input_filter_init(void *data) |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1675 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1676 ngx_http_request_t *r = data; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1677 ngx_http_upstream_t *u; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1678 ngx_http_proxy_ctx_t *ctx; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1679 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1680 u = r->upstream; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1681 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1682 |
4602
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1683 if (ctx == NULL) { |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1684 return NGX_ERROR; |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1685 } |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1686 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1687 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1688 "http proxy filter init s:%d h:%d c:%d l:%O", |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1689 u->headers_in.status_n, ctx->head, u->headers_in.chunked, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1690 u->headers_in.content_length_n); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1691 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1692 /* as per RFC2616, 4.4 Message Length */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1693 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1694 if (u->headers_in.status_n == NGX_HTTP_NO_CONTENT |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1695 || u->headers_in.status_n == NGX_HTTP_NOT_MODIFIED |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1696 || ctx->head) |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1697 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1698 /* 1xx, 204, and 304 and replies to HEAD requests */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1699 /* no 1xx since we don't send Expect and Upgrade */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1700 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1701 u->pipe->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1702 u->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1703 u->keepalive = !u->headers_in.connection_close; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1704 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1705 } else if (u->headers_in.chunked) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1706 /* chunked */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1707 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1708 u->pipe->input_filter = ngx_http_proxy_chunked_filter; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1709 u->pipe->length = 3; /* "0" LF LF */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1710 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1711 u->input_filter = ngx_http_proxy_non_buffered_chunked_filter; |
5301
a50e26148d21
Upstream: added check if a response is complete.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5231
diff
changeset
|
1712 u->length = 1; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1713 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1714 } else if (u->headers_in.content_length_n == 0) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1715 /* empty body: special case as filter won't be called */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1716 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1717 u->pipe->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1718 u->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1719 u->keepalive = !u->headers_in.connection_close; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1720 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1721 } else { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1722 /* content length or connection close */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1723 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1724 u->pipe->length = u->headers_in.content_length_n; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1725 u->length = u->headers_in.content_length_n; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1726 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1727 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1728 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1729 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1730 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1731 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1732 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1733 ngx_http_proxy_copy_filter(ngx_event_pipe_t *p, ngx_buf_t *buf) |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1734 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1735 ngx_buf_t *b; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1736 ngx_chain_t *cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1737 ngx_http_request_t *r; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1738 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1739 if (buf->pos == buf->last) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1740 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1741 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1742 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
1743 cl = ngx_chain_get_free_buf(p->pool, &p->free); |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
1744 if (cl == NULL) { |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
1745 return NGX_ERROR; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1746 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1747 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
1748 b = cl->buf; |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
1749 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1750 ngx_memcpy(b, buf, sizeof(ngx_buf_t)); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1751 b->shadow = buf; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1752 b->tag = p->tag; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1753 b->last_shadow = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1754 b->recycled = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1755 buf->shadow = b; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1756 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1757 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1758 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1759 if (p->in) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1760 *p->last_in = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1761 } else { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1762 p->in = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1763 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1764 p->last_in = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1765 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1766 if (p->length == -1) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1767 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1768 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1769 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1770 p->length -= b->last - b->pos; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1771 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1772 if (p->length == 0) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1773 r = p->input_ctx; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1774 p->upstream_done = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1775 r->upstream->keepalive = !r->upstream->headers_in.connection_close; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1776 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1777 } else if (p->length < 0) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1778 r = p->input_ctx; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1779 p->upstream_done = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1780 |
4145
f321e9750c8c
Proxy: logging levels tuned, double logging fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4144
diff
changeset
|
1781 ngx_log_error(NGX_LOG_WARN, r->connection->log, 0, |
4962
13a5202b6b4b
Proxy: better error message about unexpected data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4947
diff
changeset
|
1782 "upstream sent more data than specified in " |
13a5202b6b4b
Proxy: better error message about unexpected data.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4947
diff
changeset
|
1783 "\"Content-Length\" header"); |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1784 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1785 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1786 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1787 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1788 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1789 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1790 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1791 ngx_http_proxy_chunked_filter(ngx_event_pipe_t *p, ngx_buf_t *buf) |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1792 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1793 ngx_int_t rc; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1794 ngx_buf_t *b, **prev; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1795 ngx_chain_t *cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1796 ngx_http_request_t *r; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1797 ngx_http_proxy_ctx_t *ctx; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1798 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1799 if (buf->pos == buf->last) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1800 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1801 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1802 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1803 r = p->input_ctx; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1804 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1805 |
4602
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1806 if (ctx == NULL) { |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1807 return NGX_ERROR; |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1808 } |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1809 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1810 b = NULL; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1811 prev = &buf->shadow; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1812 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1813 for ( ;; ) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1814 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
1815 rc = ngx_http_parse_chunked(r, buf, &ctx->chunked); |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1816 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1817 if (rc == NGX_OK) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1818 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1819 /* a chunk has been parsed successfully */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1820 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
1821 cl = ngx_chain_get_free_buf(p->pool, &p->free); |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
1822 if (cl == NULL) { |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
1823 return NGX_ERROR; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1824 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1825 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
1826 b = cl->buf; |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
1827 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1828 ngx_memzero(b, sizeof(ngx_buf_t)); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1829 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1830 b->pos = buf->pos; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1831 b->start = buf->start; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1832 b->end = buf->end; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1833 b->tag = p->tag; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1834 b->temporary = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1835 b->recycled = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1836 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1837 *prev = b; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1838 prev = &b->shadow; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1839 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1840 if (p->in) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1841 *p->last_in = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1842 } else { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1843 p->in = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1844 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1845 p->last_in = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1846 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1847 /* STUB */ b->num = buf->num; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1848 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1849 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1850 "input buf #%d %p", b->num, b->pos); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1851 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
1852 if (buf->last - buf->pos >= ctx->chunked.size) { |
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
1853 |
5359
2fda9065d0f4
Win32: Borland C compatibility fixes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5301
diff
changeset
|
1854 buf->pos += (size_t) ctx->chunked.size; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1855 b->last = buf->pos; |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
1856 ctx->chunked.size = 0; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1857 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1858 continue; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1859 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1860 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
1861 ctx->chunked.size -= buf->last - buf->pos; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1862 buf->pos = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1863 b->last = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1864 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1865 continue; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1866 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1867 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1868 if (rc == NGX_DONE) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1869 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1870 /* a whole response has been parsed successfully */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1871 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1872 p->upstream_done = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1873 r->upstream->keepalive = !r->upstream->headers_in.connection_close; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1874 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1875 break; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1876 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1877 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1878 if (rc == NGX_AGAIN) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1879 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1880 /* set p->length, minimal amount of data we want to see */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1881 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
1882 p->length = ctx->chunked.length; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1883 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1884 break; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1885 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1886 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1887 /* invalid response */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1888 |
4145
f321e9750c8c
Proxy: logging levels tuned, double logging fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4144
diff
changeset
|
1889 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1890 "upstream sent invalid chunked response"); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1891 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1892 return NGX_ERROR; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1893 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1894 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1895 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1896 "http proxy chunked state %d, length %d", |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
1897 ctx->chunked.state, p->length); |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1898 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1899 if (b) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1900 b->shadow = buf; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1901 b->last_shadow = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1902 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1903 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1904 "input buf %p %z", b->pos, b->last - b->pos); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1905 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1906 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1907 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1908 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1909 /* there is no data record in the buf, add it to free chain */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1910 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1911 if (ngx_event_pipe_add_free_buf(p, buf) != NGX_OK) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1912 return NGX_ERROR; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1913 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1914 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1915 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1916 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1917 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1918 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1919 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1920 ngx_http_proxy_non_buffered_copy_filter(void *data, ssize_t bytes) |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1921 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1922 ngx_http_request_t *r = data; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1923 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1924 ngx_buf_t *b; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1925 ngx_chain_t *cl, **ll; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1926 ngx_http_upstream_t *u; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1927 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1928 u = r->upstream; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1929 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1930 for (cl = u->out_bufs, ll = &u->out_bufs; cl; cl = cl->next) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1931 ll = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1932 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1933 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1934 cl = ngx_chain_get_free_buf(r->pool, &u->free_bufs); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1935 if (cl == NULL) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1936 return NGX_ERROR; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1937 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1938 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1939 *ll = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1940 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1941 cl->buf->flush = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1942 cl->buf->memory = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1943 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1944 b = &u->buffer; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1945 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1946 cl->buf->pos = b->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1947 b->last += bytes; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1948 cl->buf->last = b->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1949 cl->buf->tag = u->output.tag; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1950 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1951 if (u->length == -1) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1952 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1953 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1954 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1955 u->length -= bytes; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1956 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1957 if (u->length == 0) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1958 u->keepalive = !u->headers_in.connection_close; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1959 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1960 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1961 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1962 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1963 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1964 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1965 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1966 ngx_http_proxy_non_buffered_chunked_filter(void *data, ssize_t bytes) |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1967 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1968 ngx_http_request_t *r = data; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1969 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1970 ngx_int_t rc; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1971 ngx_buf_t *b, *buf; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1972 ngx_chain_t *cl, **ll; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1973 ngx_http_upstream_t *u; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1974 ngx_http_proxy_ctx_t *ctx; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1975 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1976 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); |
4602
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1977 |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1978 if (ctx == NULL) { |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1979 return NGX_ERROR; |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1980 } |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
1981 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1982 u = r->upstream; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1983 buf = &u->buffer; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1984 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1985 buf->pos = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1986 buf->last += bytes; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1987 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1988 for (cl = u->out_bufs, ll = &u->out_bufs; cl; cl = cl->next) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1989 ll = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1990 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1991 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1992 for ( ;; ) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1993 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
1994 rc = ngx_http_parse_chunked(r, buf, &ctx->chunked); |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1995 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1996 if (rc == NGX_OK) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1997 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1998 /* a chunk has been parsed successfully */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1999 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2000 cl = ngx_chain_get_free_buf(r->pool, &u->free_bufs); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2001 if (cl == NULL) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2002 return NGX_ERROR; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2003 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2004 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2005 *ll = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2006 ll = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2007 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2008 b = cl->buf; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2009 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2010 b->flush = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2011 b->memory = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2012 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2013 b->pos = buf->pos; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2014 b->tag = u->output.tag; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2015 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2016 if (buf->last - buf->pos >= ctx->chunked.size) { |
5359
2fda9065d0f4
Win32: Borland C compatibility fixes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5301
diff
changeset
|
2017 buf->pos += (size_t) ctx->chunked.size; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2018 b->last = buf->pos; |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2019 ctx->chunked.size = 0; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2020 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2021 } else { |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2022 ctx->chunked.size -= buf->last - buf->pos; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2023 buf->pos = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2024 b->last = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2025 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2026 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2027 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2028 "http proxy out buf %p %z", |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2029 b->pos, b->last - b->pos); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2030 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2031 continue; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2032 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2033 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2034 if (rc == NGX_DONE) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2035 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2036 /* a whole response has been parsed successfully */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2037 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2038 u->keepalive = !u->headers_in.connection_close; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2039 u->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2040 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2041 break; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2042 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2043 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2044 if (rc == NGX_AGAIN) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2045 break; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2046 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2047 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2048 /* invalid response */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2049 |
4145
f321e9750c8c
Proxy: logging levels tuned, double logging fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4144
diff
changeset
|
2050 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2051 "upstream sent invalid chunked response"); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2052 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2053 return NGX_ERROR; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2054 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2055 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2056 /* provide continuous buffer for subrequests in memory */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2057 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2058 if (r->subrequest_in_memory) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2059 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2060 cl = u->out_bufs; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2061 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2062 if (cl) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2063 buf->pos = cl->buf->pos; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2064 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2065 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2066 buf->last = buf->pos; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2067 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2068 for (cl = u->out_bufs; cl; cl = cl->next) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2069 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2070 "http proxy in memory %p-%p %uz", |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2071 cl->buf->pos, cl->buf->last, ngx_buf_size(cl->buf)); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2072 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2073 if (buf->last == cl->buf->pos) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2074 buf->last = cl->buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2075 continue; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2076 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2077 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2078 buf->last = ngx_movemem(buf->last, cl->buf->pos, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2079 cl->buf->last - cl->buf->pos); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2080 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2081 cl->buf->pos = buf->last - (cl->buf->last - cl->buf->pos); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2082 cl->buf->last = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2083 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2084 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2085 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2086 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2087 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2088 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2089 |
507 | 2090 static void |
2091 ngx_http_proxy_abort_request(ngx_http_request_t *r) | |
2092 { | |
2093 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2094 "abort http proxy request"); | |
577 | 2095 |
507 | 2096 return; |
2097 } | |
2098 | |
2099 | |
2100 static void | |
2101 ngx_http_proxy_finalize_request(ngx_http_request_t *r, ngx_int_t rc) | |
577 | 2102 { |
507 | 2103 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2104 "finalize http proxy request"); | |
2105 | |
2106 return; | |
2107 } | |
2108 | |
2109 | |
573 | 2110 static ngx_int_t |
2111 ngx_http_proxy_host_variable(ngx_http_request_t *r, | |
2112 ngx_http_variable_value_t *v, uintptr_t data) | |
507 | 2113 { |
1658 | 2114 ngx_http_proxy_ctx_t *ctx; |
2115 | |
2116 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
2117 | |
2118 if (ctx == NULL) { | |
2119 v->not_found = 1; | |
2120 return NGX_OK; | |
2121 } | |
2122 | |
2123 v->len = ctx->vars.host_header.len; | |
577 | 2124 v->valid = 1; |
1565 | 2125 v->no_cacheable = 0; |
573 | 2126 v->not_found = 0; |
1658 | 2127 v->data = ctx->vars.host_header.data; |
507 | 2128 |
573 | 2129 return NGX_OK; |
507 | 2130 } |
2131 | |
2132 | |
573 | 2133 static ngx_int_t |
2134 ngx_http_proxy_port_variable(ngx_http_request_t *r, | |
2135 ngx_http_variable_value_t *v, uintptr_t data) | |
507 | 2136 { |
1658 | 2137 ngx_http_proxy_ctx_t *ctx; |
2138 | |
2139 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
2140 | |
2141 if (ctx == NULL) { | |
2142 v->not_found = 1; | |
2143 return NGX_OK; | |
2144 } | |
2145 | |
2146 v->len = ctx->vars.port.len; | |
577 | 2147 v->valid = 1; |
1565 | 2148 v->no_cacheable = 0; |
573 | 2149 v->not_found = 0; |
1658 | 2150 v->data = ctx->vars.port.data; |
509 | 2151 |
573 | 2152 return NGX_OK; |
509 | 2153 } |
2154 | |
2155 | |
573 | 2156 static ngx_int_t |
509 | 2157 ngx_http_proxy_add_x_forwarded_for_variable(ngx_http_request_t *r, |
573 | 2158 ngx_http_variable_value_t *v, uintptr_t data) |
509 | 2159 { |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2160 size_t len; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2161 u_char *p; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2162 ngx_uint_t i, n; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2163 ngx_table_elt_t **h; |
509 | 2164 |
577 | 2165 v->valid = 1; |
1565 | 2166 v->no_cacheable = 0; |
573 | 2167 v->not_found = 0; |
509 | 2168 |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2169 n = r->headers_in.x_forwarded_for.nelts; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2170 h = r->headers_in.x_forwarded_for.elts; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2171 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2172 len = 0; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2173 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2174 for (i = 0; i < n; i++) { |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2175 len += h[i]->value.len + sizeof(", ") - 1; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2176 } |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2177 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2178 if (len == 0) { |
573 | 2179 v->len = r->connection->addr_text.len; |
2180 v->data = r->connection->addr_text.data; | |
2181 return NGX_OK; | |
509 | 2182 } |
2183 | |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2184 len += r->connection->addr_text.len; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2185 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2186 p = ngx_pnalloc(r->pool, len); |
509 | 2187 if (p == NULL) { |
573 | 2188 return NGX_ERROR; |
509 | 2189 } |
2190 | |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2191 v->len = len; |
573 | 2192 v->data = p; |
509 | 2193 |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2194 for (i = 0; i < n; i++) { |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2195 p = ngx_copy(p, h[i]->value.data, h[i]->value.len); |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2196 *p++ = ','; *p++ = ' '; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2197 } |
509 | 2198 |
2199 ngx_memcpy(p, r->connection->addr_text.data, r->connection->addr_text.len); | |
2200 | |
573 | 2201 return NGX_OK; |
509 | 2202 } |
2203 | |
2204 | |
2205 static ngx_int_t | |
577 | 2206 ngx_http_proxy_internal_body_length_variable(ngx_http_request_t *r, |
2207 ngx_http_variable_value_t *v, uintptr_t data) | |
2208 { | |
1658 | 2209 ngx_http_proxy_ctx_t *ctx; |
2210 | |
2211 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
2212 | |
4927
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
2213 if (ctx == NULL || ctx->internal_body_length < 0) { |
577 | 2214 v->not_found = 1; |
2215 return NGX_OK; | |
2216 } | |
2217 | |
2218 v->valid = 1; | |
1565 | 2219 v->no_cacheable = 0; |
577 | 2220 v->not_found = 0; |
2221 | |
5188
886800caf360
Proxy: allocate $proxy_internal_body_length from request pool.
Ruslan Ermilov <ru@nginx.com>
parents:
5084
diff
changeset
|
2222 v->data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN); |
577 | 2223 |
2224 if (v->data == NULL) { | |
2225 return NGX_ERROR; | |
2226 } | |
2227 | |
4927
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
2228 v->len = ngx_sprintf(v->data, "%O", ctx->internal_body_length) - v->data; |
577 | 2229 |
2230 return NGX_OK; | |
2231 } | |
2232 | |
2233 | |
2234 static ngx_int_t | |
509 | 2235 ngx_http_proxy_rewrite_redirect(ngx_http_request_t *r, ngx_table_elt_t *h, |
2236 size_t prefix) | |
2237 { | |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2238 size_t len; |
509 | 2239 ngx_int_t rc; |
2240 ngx_uint_t i; | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2241 ngx_http_proxy_rewrite_t *pr; |
509 | 2242 ngx_http_proxy_loc_conf_t *plcf; |
2243 | |
2244 plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module); | |
2245 | |
2246 pr = plcf->redirects->elts; | |
2247 | |
2248 if (pr == NULL) { | |
2249 return NGX_DECLINED; | |
2250 } | |
2251 | |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2252 len = h->value.len - prefix; |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2253 |
509 | 2254 for (i = 0; i < plcf->redirects->nelts; i++) { |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2255 rc = pr[i].handler(r, h, prefix, len, &pr[i]); |
509 | 2256 |
2257 if (rc != NGX_DECLINED) { | |
2258 return rc; | |
2259 } | |
2260 } | |
2261 | |
2262 return NGX_DECLINED; | |
2263 } | |
2264 | |
2265 | |
2266 static ngx_int_t | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2267 ngx_http_proxy_rewrite_cookie(ngx_http_request_t *r, ngx_table_elt_t *h) |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2268 { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2269 size_t prefix; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2270 u_char *p; |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2271 ngx_int_t rc, rv; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2272 ngx_http_proxy_loc_conf_t *plcf; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2273 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2274 p = (u_char *) ngx_strchr(h->value.data, ';'); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2275 if (p == NULL) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2276 return NGX_DECLINED; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2277 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2278 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2279 prefix = p + 1 - h->value.data; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2280 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2281 rv = NGX_DECLINED; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2282 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2283 plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2284 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2285 if (plcf->cookie_domains) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2286 p = ngx_strcasestrn(h->value.data + prefix, "domain=", 7 - 1); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2287 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2288 if (p) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2289 rc = ngx_http_proxy_rewrite_cookie_value(r, h, p + 7, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2290 plcf->cookie_domains); |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2291 if (rc == NGX_ERROR) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2292 return NGX_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2293 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2294 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2295 if (rc != NGX_DECLINED) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2296 rv = rc; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2297 } |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2298 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2299 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2300 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2301 if (plcf->cookie_paths) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2302 p = ngx_strcasestrn(h->value.data + prefix, "path=", 5 - 1); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2303 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2304 if (p) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2305 rc = ngx_http_proxy_rewrite_cookie_value(r, h, p + 5, |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2306 plcf->cookie_paths); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2307 if (rc == NGX_ERROR) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2308 return NGX_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2309 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2310 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2311 if (rc != NGX_DECLINED) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2312 rv = rc; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2313 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2314 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2315 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2316 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2317 return rv; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2318 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2319 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2320 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2321 static ngx_int_t |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2322 ngx_http_proxy_rewrite_cookie_value(ngx_http_request_t *r, ngx_table_elt_t *h, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2323 u_char *value, ngx_array_t *rewrites) |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2324 { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2325 size_t len, prefix; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2326 u_char *p; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2327 ngx_int_t rc; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2328 ngx_uint_t i; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2329 ngx_http_proxy_rewrite_t *pr; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2330 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2331 prefix = value - h->value.data; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2332 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2333 p = (u_char *) ngx_strchr(value, ';'); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2334 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2335 len = p ? (size_t) (p - value) : (h->value.len - prefix); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2336 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2337 pr = rewrites->elts; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2338 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2339 for (i = 0; i < rewrites->nelts; i++) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2340 rc = pr[i].handler(r, h, prefix, len, &pr[i]); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2341 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2342 if (rc != NGX_DECLINED) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2343 return rc; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2344 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2345 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2346 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2347 return NGX_DECLINED; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2348 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2349 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2350 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2351 static ngx_int_t |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2352 ngx_http_proxy_rewrite_complex_handler(ngx_http_request_t *r, |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2353 ngx_table_elt_t *h, size_t prefix, size_t len, ngx_http_proxy_rewrite_t *pr) |
509 | 2354 { |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2355 ngx_str_t pattern, replacement; |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2356 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2357 if (ngx_http_complex_value(r, &pr->pattern.complex, &pattern) != NGX_OK) { |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2358 return NGX_ERROR; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2359 } |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2360 |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2361 if (pattern.len > len |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2362 || ngx_rstrncmp(h->value.data + prefix, pattern.data, |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2363 pattern.len) != 0) |
509 | 2364 { |
2365 return NGX_DECLINED; | |
2366 } | |
2367 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2368 if (ngx_http_complex_value(r, &pr->replacement, &replacement) != NGX_OK) { |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2369 return NGX_ERROR; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2370 } |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2371 |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2372 return ngx_http_proxy_rewrite(r, h, prefix, pattern.len, &replacement); |
509 | 2373 } |
2374 | |
2375 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2376 #if (NGX_PCRE) |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2377 |
509 | 2378 static ngx_int_t |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2379 ngx_http_proxy_rewrite_regex_handler(ngx_http_request_t *r, ngx_table_elt_t *h, |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2380 size_t prefix, size_t len, ngx_http_proxy_rewrite_t *pr) |
509 | 2381 { |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2382 ngx_str_t pattern, replacement; |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2383 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2384 pattern.len = len; |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2385 pattern.data = h->value.data + prefix; |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2386 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2387 if (ngx_http_regex_exec(r, pr->pattern.regex, &pattern) != NGX_OK) { |
509 | 2388 return NGX_DECLINED; |
2389 } | |
2390 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2391 if (ngx_http_complex_value(r, &pr->replacement, &replacement) != NGX_OK) { |
509 | 2392 return NGX_ERROR; |
2393 } | |
2394 | |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2395 if (prefix == 0 && h->value.len == len) { |
4398
3d51ba7f347b
Fixed: proxy_redirect with regex might broke Refresh header.
Valentin Bartenev <vbart@nginx.com>
parents:
4385
diff
changeset
|
2396 h->value = replacement; |
3d51ba7f347b
Fixed: proxy_redirect with regex might broke Refresh header.
Valentin Bartenev <vbart@nginx.com>
parents:
4385
diff
changeset
|
2397 return NGX_OK; |
3d51ba7f347b
Fixed: proxy_redirect with regex might broke Refresh header.
Valentin Bartenev <vbart@nginx.com>
parents:
4385
diff
changeset
|
2398 } |
3d51ba7f347b
Fixed: proxy_redirect with regex might broke Refresh header.
Valentin Bartenev <vbart@nginx.com>
parents:
4385
diff
changeset
|
2399 |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2400 return ngx_http_proxy_rewrite(r, h, prefix, len, &replacement); |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2401 } |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2402 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2403 #endif |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2404 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2405 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2406 static ngx_int_t |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2407 ngx_http_proxy_rewrite_domain_handler(ngx_http_request_t *r, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2408 ngx_table_elt_t *h, size_t prefix, size_t len, ngx_http_proxy_rewrite_t *pr) |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2409 { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2410 u_char *p; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2411 ngx_str_t pattern, replacement; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2412 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2413 if (ngx_http_complex_value(r, &pr->pattern.complex, &pattern) != NGX_OK) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2414 return NGX_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2415 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2416 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2417 p = h->value.data + prefix; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2418 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2419 if (p[0] == '.') { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2420 p++; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2421 prefix++; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2422 len--; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2423 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2424 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2425 if (pattern.len != len || ngx_rstrncasecmp(pattern.data, p, len) != 0) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2426 return NGX_DECLINED; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2427 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2428 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2429 if (ngx_http_complex_value(r, &pr->replacement, &replacement) != NGX_OK) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2430 return NGX_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2431 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2432 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2433 return ngx_http_proxy_rewrite(r, h, prefix, len, &replacement); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2434 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2435 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2436 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2437 static ngx_int_t |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2438 ngx_http_proxy_rewrite(ngx_http_request_t *r, ngx_table_elt_t *h, size_t prefix, |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2439 size_t len, ngx_str_t *replacement) |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2440 { |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2441 u_char *p, *data; |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2442 size_t new_len; |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2443 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2444 new_len = replacement->len + h->value.len - len; |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2445 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2446 if (replacement->len > len) { |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2447 |
5676
fbfdf8017748
Proxy: fixed possible uninitialized memory access.
Valentin Bartenev <vbart@nginx.com>
parents:
5661
diff
changeset
|
2448 data = ngx_pnalloc(r->pool, new_len + 1); |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2449 if (data == NULL) { |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2450 return NGX_ERROR; |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2451 } |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2452 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2453 p = ngx_copy(data, h->value.data, prefix); |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2454 p = ngx_copy(p, replacement->data, replacement->len); |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2455 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2456 ngx_memcpy(p, h->value.data + prefix + len, |
5676
fbfdf8017748
Proxy: fixed possible uninitialized memory access.
Valentin Bartenev <vbart@nginx.com>
parents:
5661
diff
changeset
|
2457 h->value.len - len - prefix + 1); |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2458 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2459 h->value.data = data; |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2460 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2461 } else { |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2462 p = ngx_copy(h->value.data + prefix, replacement->data, |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2463 replacement->len); |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2464 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2465 ngx_memmove(p, h->value.data + prefix + len, |
5676
fbfdf8017748
Proxy: fixed possible uninitialized memory access.
Valentin Bartenev <vbart@nginx.com>
parents:
5661
diff
changeset
|
2466 h->value.len - len - prefix + 1); |
4398
3d51ba7f347b
Fixed: proxy_redirect with regex might broke Refresh header.
Valentin Bartenev <vbart@nginx.com>
parents:
4385
diff
changeset
|
2467 } |
3d51ba7f347b
Fixed: proxy_redirect with regex might broke Refresh header.
Valentin Bartenev <vbart@nginx.com>
parents:
4385
diff
changeset
|
2468 |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2469 h->value.len = new_len; |
509 | 2470 |
2471 return NGX_OK; | |
2472 } | |
2473 | |
2474 | |
2475 static ngx_int_t | |
2476 ngx_http_proxy_add_variables(ngx_conf_t *cf) | |
2477 { | |
2478 ngx_http_variable_t *var, *v; | |
2479 | |
2480 for (v = ngx_http_proxy_vars; v->name.len; v++) { | |
2481 var = ngx_http_add_variable(cf, &v->name, v->flags); | |
2482 if (var == NULL) { | |
2483 return NGX_ERROR; | |
2484 } | |
2485 | |
637 | 2486 var->get_handler = v->get_handler; |
509 | 2487 var->data = v->data; |
2488 } | |
2489 | |
2490 return NGX_OK; | |
507 | 2491 } |
2492 | |
2493 | |
2494 static void * | |
2495 ngx_http_proxy_create_loc_conf(ngx_conf_t *cf) | |
2496 { | |
2497 ngx_http_proxy_loc_conf_t *conf; | |
2498 | |
2499 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_proxy_loc_conf_t)); | |
2500 if (conf == NULL) { | |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
2895
diff
changeset
|
2501 return NULL; |
507 | 2502 } |
2503 | |
2504 /* | |
2505 * set by ngx_pcalloc(): | |
2506 * | |
2507 * conf->upstream.bufs.num = 0; | |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
2508 * conf->upstream.ignore_headers = 0; |
507 | 2509 * conf->upstream.next_upstream = 0; |
2875
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2510 * conf->upstream.cache_use_stale = 0; |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2511 * conf->upstream.cache_methods = 0; |
507 | 2512 * conf->upstream.temp_path = NULL; |
649 | 2513 * conf->upstream.hide_headers_hash = { NULL, 0 }; |
509 | 2514 * conf->upstream.uri = { 0, NULL }; |
2515 * conf->upstream.location = NULL; | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2516 * conf->upstream.store_lengths = NULL; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2517 * conf->upstream.store_values = NULL; |
5660
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
2518 * conf->upstream.ssl_name = NULL; |
509 | 2519 * |
5012
bbdb172f0927
Proxy: fixed proxy_method to always add space.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
2520 * conf->method = { 0, NULL }; |
509 | 2521 * conf->headers_source = NULL; |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
2522 * conf->headers.lengths = NULL; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
2523 * conf->headers.values = NULL; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
2524 * conf->headers.hash = { NULL, 0 }; |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
2525 * conf->headers_cache.lengths = NULL; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
2526 * conf->headers_cache.values = NULL; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
2527 * conf->headers_cache.hash = { NULL, 0 }; |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
2528 * conf->body_lengths = NULL; |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
2529 * conf->body_values = NULL; |
577 | 2530 * conf->body_source = { 0, NULL }; |
3470
b982f2dee8cf
fix proxy_redirect name in error message
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
2531 * conf->redirects = NULL; |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
2532 * conf->ssl = 0; |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
2533 * conf->ssl_protocols = 0; |
5390
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
2534 * conf->ssl_ciphers = { 0, NULL }; |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
2535 * conf->ssl_trusted_certificate = { 0, NULL }; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
2536 * conf->ssl_crl = { 0, NULL }; |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
2537 * conf->ssl_certificate = { 0, NULL }; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
2538 * conf->ssl_certificate_key = { 0, NULL }; |
507 | 2539 */ |
577 | 2540 |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2541 conf->upstream.store = NGX_CONF_UNSET; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2542 conf->upstream.store_access = NGX_CONF_UNSET_UINT; |
5832
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
2543 conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT; |
581 | 2544 conf->upstream.buffering = NGX_CONF_UNSET; |
629 | 2545 conf->upstream.ignore_client_abort = NGX_CONF_UNSET; |
5874
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
2546 conf->upstream.force_ranges = NGX_CONF_UNSET; |
581 | 2547 |
5008
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4962
diff
changeset
|
2548 conf->upstream.local = NGX_CONF_UNSET_PTR; |
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4962
diff
changeset
|
2549 |
507 | 2550 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC; |
2551 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC; | |
2552 conf->upstream.read_timeout = NGX_CONF_UNSET_MSEC; | |
5832
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
2553 conf->upstream.next_upstream_timeout = NGX_CONF_UNSET_MSEC; |
507 | 2554 |
2555 conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; | |
581 | 2556 conf->upstream.buffer_size = NGX_CONF_UNSET_SIZE; |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
2557 conf->upstream.limit_rate = NGX_CONF_UNSET_SIZE; |
529 | 2558 |
2559 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; | |
577 | 2560 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; |
529 | 2561 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; |
509 | 2562 |
2563 conf->upstream.pass_request_headers = NGX_CONF_UNSET; | |
2564 conf->upstream.pass_request_body = NGX_CONF_UNSET; | |
561 | 2565 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2566 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2567 conf->upstream.cache = NGX_CONF_UNSET_PTR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2568 conf->upstream.cache_min_uses = NGX_CONF_UNSET_UINT; |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
2569 conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; |
3526
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
2570 conf->upstream.no_cache = NGX_CONF_UNSET_PTR; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2571 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; |
4385
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
2572 conf->upstream.cache_lock = NGX_CONF_UNSET; |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
2573 conf->upstream.cache_lock_timeout = NGX_CONF_UNSET_MSEC; |
5905
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
2574 conf->upstream.cache_lock_age = NGX_CONF_UNSET_MSEC; |
5441
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
2575 conf->upstream.cache_revalidate = NGX_CONF_UNSET; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2576 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2577 |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
2578 conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
2579 conf->upstream.pass_headers = NGX_CONF_UNSET_PTR; |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
2580 |
657 | 2581 conf->upstream.intercept_errors = NGX_CONF_UNSET; |
5660
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
2582 |
2184 | 2583 #if (NGX_HTTP_SSL) |
2584 conf->upstream.ssl_session_reuse = NGX_CONF_UNSET; | |
5660
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
2585 conf->upstream.ssl_server_name = NGX_CONF_UNSET; |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
2586 conf->upstream.ssl_verify = NGX_CONF_UNSET; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
2587 conf->ssl_verify_depth = NGX_CONF_UNSET_UINT; |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
2588 conf->ssl_passwords = NGX_CONF_UNSET_PTR; |
2184 | 2589 #endif |
507 | 2590 |
2591 /* "proxy_cyclic_temp_file" is disabled */ | |
2592 conf->upstream.cyclic_temp_file = 0; | |
2593 | |
509 | 2594 conf->redirect = NGX_CONF_UNSET; |
649 | 2595 conf->upstream.change_buffering = 1; |
507 | 2596 |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2597 conf->cookie_domains = NGX_CONF_UNSET_PTR; |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2598 conf->cookie_paths = NGX_CONF_UNSET_PTR; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2599 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2600 conf->http_version = NGX_CONF_UNSET_UINT; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2601 |
1180
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
2602 conf->headers_hash_max_size = NGX_CONF_UNSET_UINT; |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
2603 conf->headers_hash_bucket_size = NGX_CONF_UNSET_UINT; |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
2604 |
3976
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3862
diff
changeset
|
2605 ngx_str_set(&conf->upstream.module, "proxy"); |
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3862
diff
changeset
|
2606 |
507 | 2607 return conf; |
2608 } | |
2609 | |
2610 | |
2611 static char * | |
2612 ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
2613 { | |
2614 ngx_http_proxy_loc_conf_t *prev = parent; | |
2615 ngx_http_proxy_loc_conf_t *conf = child; | |
2616 | |
3862
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
2617 u_char *p; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2618 size_t size; |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
2619 ngx_int_t rc; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2620 ngx_hash_init_t hash; |
3731
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
2621 ngx_http_core_loc_conf_t *clcf; |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2622 ngx_http_proxy_rewrite_t *pr; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2623 ngx_http_script_compile_t sc; |
509 | 2624 |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2625 if (conf->upstream.store != 0) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2626 ngx_conf_merge_value(conf->upstream.store, |
2894 | 2627 prev->upstream.store, 0); |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2628 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2629 if (conf->upstream.store_lengths == NULL) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2630 conf->upstream.store_lengths = prev->upstream.store_lengths; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2631 conf->upstream.store_values = prev->upstream.store_values; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2632 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2633 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2634 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2635 ngx_conf_merge_uint_value(conf->upstream.store_access, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
2636 prev->upstream.store_access, 0600); |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1244
diff
changeset
|
2637 |
5832
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
2638 ngx_conf_merge_uint_value(conf->upstream.next_upstream_tries, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
2639 prev->upstream.next_upstream_tries, 0); |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
2640 |
581 | 2641 ngx_conf_merge_value(conf->upstream.buffering, |
2642 prev->upstream.buffering, 1); | |
2643 | |
629 | 2644 ngx_conf_merge_value(conf->upstream.ignore_client_abort, |
2645 prev->upstream.ignore_client_abort, 0); | |
2646 | |
5874
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
2647 ngx_conf_merge_value(conf->upstream.force_ranges, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
2648 prev->upstream.force_ranges, 0); |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
2649 |
5008
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4962
diff
changeset
|
2650 ngx_conf_merge_ptr_value(conf->upstream.local, |
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4962
diff
changeset
|
2651 prev->upstream.local, NULL); |
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4962
diff
changeset
|
2652 |
507 | 2653 ngx_conf_merge_msec_value(conf->upstream.connect_timeout, |
2654 prev->upstream.connect_timeout, 60000); | |
2655 | |
2656 ngx_conf_merge_msec_value(conf->upstream.send_timeout, | |
2657 prev->upstream.send_timeout, 60000); | |
2658 | |
2659 ngx_conf_merge_msec_value(conf->upstream.read_timeout, | |
2660 prev->upstream.read_timeout, 60000); | |
2661 | |
5832
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
2662 ngx_conf_merge_msec_value(conf->upstream.next_upstream_timeout, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
2663 prev->upstream.next_upstream_timeout, 0); |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
2664 |
507 | 2665 ngx_conf_merge_size_value(conf->upstream.send_lowat, |
2666 prev->upstream.send_lowat, 0); | |
2667 | |
581 | 2668 ngx_conf_merge_size_value(conf->upstream.buffer_size, |
2669 prev->upstream.buffer_size, | |
507 | 2670 (size_t) ngx_pagesize); |
2671 | |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
2672 ngx_conf_merge_size_value(conf->upstream.limit_rate, |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
2673 prev->upstream.limit_rate, 0); |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
2674 |
507 | 2675 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs, |
2676 8, ngx_pagesize); | |
2677 | |
2678 if (conf->upstream.bufs.num < 2) { | |
577 | 2679 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
507 | 2680 "there must be at least 2 \"proxy_buffers\""); |
2681 return NGX_CONF_ERROR; | |
2682 } | |
577 | 2683 |
507 | 2684 |
581 | 2685 size = conf->upstream.buffer_size; |
577 | 2686 if (size < conf->upstream.bufs.size) { |
507 | 2687 size = conf->upstream.bufs.size; |
2688 } | |
2689 | |
2690 | |
529 | 2691 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf, |
2692 prev->upstream.busy_buffers_size_conf, | |
507 | 2693 NGX_CONF_UNSET_SIZE); |
2694 | |
529 | 2695 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) { |
507 | 2696 conf->upstream.busy_buffers_size = 2 * size; |
529 | 2697 } else { |
2698 conf->upstream.busy_buffers_size = | |
2699 conf->upstream.busy_buffers_size_conf; | |
2700 } | |
577 | 2701 |
529 | 2702 if (conf->upstream.busy_buffers_size < size) { |
507 | 2703 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
2704 "\"proxy_busy_buffers_size\" must be equal to or greater than " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
2705 "the maximum of the value of \"proxy_buffer_size\" and " |
507 | 2706 "one of the \"proxy_buffers\""); |
2707 | |
2708 return NGX_CONF_ERROR; | |
529 | 2709 } |
507 | 2710 |
529 | 2711 if (conf->upstream.busy_buffers_size |
2712 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) | |
507 | 2713 { |
2714 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2715 "\"proxy_busy_buffers_size\" must be less than " | |
2716 "the size of all \"proxy_buffers\" minus one buffer"); | |
2717 | |
2718 return NGX_CONF_ERROR; | |
2719 } | |
529 | 2720 |
507 | 2721 |
529 | 2722 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf, |
2723 prev->upstream.temp_file_write_size_conf, | |
507 | 2724 NGX_CONF_UNSET_SIZE); |
2725 | |
529 | 2726 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) { |
507 | 2727 conf->upstream.temp_file_write_size = 2 * size; |
529 | 2728 } else { |
2729 conf->upstream.temp_file_write_size = | |
2730 conf->upstream.temp_file_write_size_conf; | |
2731 } | |
577 | 2732 |
529 | 2733 if (conf->upstream.temp_file_write_size < size) { |
507 | 2734 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
2735 "\"proxy_temp_file_write_size\" must be equal to or greater " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
2736 "than the maximum of the value of \"proxy_buffer_size\" and " |
507 | 2737 "one of the \"proxy_buffers\""); |
2738 | |
2739 return NGX_CONF_ERROR; | |
2740 } | |
2741 | |
529 | 2742 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf, |
2743 prev->upstream.max_temp_file_size_conf, | |
507 | 2744 NGX_CONF_UNSET_SIZE); |
2745 | |
529 | 2746 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) { |
507 | 2747 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; |
529 | 2748 } else { |
2749 conf->upstream.max_temp_file_size = | |
2750 conf->upstream.max_temp_file_size_conf; | |
2751 } | |
507 | 2752 |
529 | 2753 if (conf->upstream.max_temp_file_size != 0 |
2754 && conf->upstream.max_temp_file_size < size) | |
507 | 2755 { |
2756 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
561 | 2757 "\"proxy_max_temp_file_size\" must be equal to zero to disable " |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
2758 "temporary files usage or must be equal to or greater than " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
2759 "the maximum of the value of \"proxy_buffer_size\" and " |
561 | 2760 "one of the \"proxy_buffers\""); |
507 | 2761 |
2762 return NGX_CONF_ERROR; | |
2763 } | |
2764 | |
529 | 2765 |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
2766 ngx_conf_merge_bitmask_value(conf->upstream.ignore_headers, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
2767 prev->upstream.ignore_headers, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
2768 NGX_CONF_BITMASK_SET); |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
2769 |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
2770 |
507 | 2771 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream, |
2772 prev->upstream.next_upstream, | |
2773 (NGX_CONF_BITMASK_SET | |
2774 |NGX_HTTP_UPSTREAM_FT_ERROR | |
2775 |NGX_HTTP_UPSTREAM_FT_TIMEOUT)); | |
2776 | |
665 | 2777 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { |
2778 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET | |
2779 |NGX_HTTP_UPSTREAM_FT_OFF; | |
2780 } | |
2781 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2782 if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path, |
509 | 2783 prev->upstream.temp_path, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2784 &ngx_http_proxy_temp_path) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2785 != NGX_OK) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2786 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2787 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2788 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2789 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2790 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2791 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2792 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2793 ngx_conf_merge_ptr_value(conf->upstream.cache, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2794 prev->upstream.cache, NULL); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2795 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2796 if (conf->upstream.cache && conf->upstream.cache->data == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2797 ngx_shm_zone_t *shm_zone; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2798 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2799 shm_zone = conf->upstream.cache; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2800 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2801 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2802 "\"proxy_cache\" zone \"%V\" is unknown", |
2716
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2706
diff
changeset
|
2803 &shm_zone->shm.name); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2804 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2805 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2806 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2807 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2808 ngx_conf_merge_uint_value(conf->upstream.cache_min_uses, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2809 prev->upstream.cache_min_uses, 1); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2810 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2811 ngx_conf_merge_bitmask_value(conf->upstream.cache_use_stale, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2812 prev->upstream.cache_use_stale, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2813 (NGX_CONF_BITMASK_SET |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2814 |NGX_HTTP_UPSTREAM_FT_OFF)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2815 |
4401
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
2816 if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_OFF) { |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
2817 conf->upstream.cache_use_stale = NGX_CONF_BITMASK_SET |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
2818 |NGX_HTTP_UPSTREAM_FT_OFF; |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
2819 } |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
2820 |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
2821 if (conf->upstream.cache_use_stale & NGX_HTTP_UPSTREAM_FT_ERROR) { |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
2822 conf->upstream.cache_use_stale |= NGX_HTTP_UPSTREAM_FT_NOLIVE; |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
2823 } |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
2824 |
2875
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2825 if (conf->upstream.cache_methods == 0) { |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2826 conf->upstream.cache_methods = prev->upstream.cache_methods; |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2827 } |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2828 |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2829 conf->upstream.cache_methods |= NGX_HTTP_GET|NGX_HTTP_HEAD; |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
2830 |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
2831 ngx_conf_merge_ptr_value(conf->upstream.cache_bypass, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
2832 prev->upstream.cache_bypass, NULL); |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
2833 |
3526
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
2834 ngx_conf_merge_ptr_value(conf->upstream.no_cache, |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
2835 prev->upstream.no_cache, NULL); |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
2836 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2837 ngx_conf_merge_ptr_value(conf->upstream.cache_valid, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2838 prev->upstream.cache_valid, NULL); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2839 |
2672 | 2840 if (conf->cache_key.value.data == NULL) { |
2841 conf->cache_key = prev->cache_key; | |
2842 } | |
2843 | |
4385
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
2844 ngx_conf_merge_value(conf->upstream.cache_lock, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
2845 prev->upstream.cache_lock, 0); |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
2846 |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
2847 ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
2848 prev->upstream.cache_lock_timeout, 5000); |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
2849 |
5905
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
2850 ngx_conf_merge_msec_value(conf->upstream.cache_lock_age, |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
2851 prev->upstream.cache_lock_age, 5000); |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
2852 |
5441
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
2853 ngx_conf_merge_value(conf->upstream.cache_revalidate, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
2854 prev->upstream.cache_revalidate, 0); |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
2855 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
2856 #endif |
507 | 2857 |
5012
bbdb172f0927
Proxy: fixed proxy_method to always add space.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
2858 ngx_conf_merge_str_value(conf->method, prev->method, ""); |
bbdb172f0927
Proxy: fixed proxy_method to always add space.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
2859 |
bbdb172f0927
Proxy: fixed proxy_method to always add space.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
2860 if (conf->method.len |
bbdb172f0927
Proxy: fixed proxy_method to always add space.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
2861 && conf->method.data[conf->method.len - 1] != ' ') |
bbdb172f0927
Proxy: fixed proxy_method to always add space.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5008
diff
changeset
|
2862 { |
561 | 2863 conf->method.data[conf->method.len] = ' '; |
2864 conf->method.len++; | |
509 | 2865 } |
2866 | |
2867 ngx_conf_merge_value(conf->upstream.pass_request_headers, | |
2868 prev->upstream.pass_request_headers, 1); | |
2869 ngx_conf_merge_value(conf->upstream.pass_request_body, | |
2870 prev->upstream.pass_request_body, 1); | |
2871 | |
657 | 2872 ngx_conf_merge_value(conf->upstream.intercept_errors, |
2873 prev->upstream.intercept_errors, 0); | |
509 | 2874 |
2184 | 2875 #if (NGX_HTTP_SSL) |
5660
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
2876 |
2184 | 2877 ngx_conf_merge_value(conf->upstream.ssl_session_reuse, |
2878 prev->upstream.ssl_session_reuse, 1); | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
2879 |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
2880 ngx_conf_merge_bitmask_value(conf->ssl_protocols, prev->ssl_protocols, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
2881 (NGX_CONF_BITMASK_SET|NGX_SSL_SSLv3 |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
2882 |NGX_SSL_TLSv1|NGX_SSL_TLSv1_1 |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
2883 |NGX_SSL_TLSv1_2)); |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
2884 |
5390
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
2885 ngx_conf_merge_str_value(conf->ssl_ciphers, prev->ssl_ciphers, |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
2886 "DEFAULT"); |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
2887 |
5660
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
2888 if (conf->upstream.ssl_name == NULL) { |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
2889 conf->upstream.ssl_name = prev->upstream.ssl_name; |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
2890 } |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
2891 |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
2892 ngx_conf_merge_value(conf->upstream.ssl_server_name, |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
2893 prev->upstream.ssl_server_name, 0); |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
2894 ngx_conf_merge_value(conf->upstream.ssl_verify, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
2895 prev->upstream.ssl_verify, 0); |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
2896 ngx_conf_merge_uint_value(conf->ssl_verify_depth, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
2897 prev->ssl_verify_depth, 1); |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
2898 ngx_conf_merge_str_value(conf->ssl_trusted_certificate, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
2899 prev->ssl_trusted_certificate, ""); |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
2900 ngx_conf_merge_str_value(conf->ssl_crl, prev->ssl_crl, ""); |
5660
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
2901 |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
2902 ngx_conf_merge_str_value(conf->ssl_certificate, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
2903 prev->ssl_certificate, ""); |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
2904 ngx_conf_merge_str_value(conf->ssl_certificate_key, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
2905 prev->ssl_certificate_key, ""); |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
2906 ngx_conf_merge_ptr_value(conf->ssl_passwords, prev->ssl_passwords, NULL); |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
2907 |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
2908 if (conf->ssl && ngx_http_proxy_set_ssl(cf, conf) != NGX_OK) { |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
2909 return NGX_CONF_ERROR; |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
2910 } |
5660
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
2911 |
2184 | 2912 #endif |
2913 | |
509 | 2914 ngx_conf_merge_value(conf->redirect, prev->redirect, 1); |
2915 | |
2916 if (conf->redirect) { | |
507 | 2917 |
509 | 2918 if (conf->redirects == NULL) { |
2919 conf->redirects = prev->redirects; | |
2920 } | |
2921 | |
1658 | 2922 if (conf->redirects == NULL && conf->url.data) { |
509 | 2923 |
2924 conf->redirects = ngx_array_create(cf->pool, 1, | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2925 sizeof(ngx_http_proxy_rewrite_t)); |
509 | 2926 if (conf->redirects == NULL) { |
2927 return NGX_CONF_ERROR; | |
2928 } | |
2929 | |
2930 pr = ngx_array_push(conf->redirects); | |
2931 if (pr == NULL) { | |
2932 return NGX_CONF_ERROR; | |
2933 } | |
2934 | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2935 ngx_memzero(&pr->pattern.complex, |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2936 sizeof(ngx_http_complex_value_t)); |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2937 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2938 ngx_memzero(&pr->replacement, sizeof(ngx_http_complex_value_t)); |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2939 |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2940 pr->handler = ngx_http_proxy_rewrite_complex_handler; |
1658 | 2941 |
2942 if (conf->vars.uri.len) { | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2943 pr->pattern.complex.value = conf->url; |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2944 pr->replacement.value = conf->location; |
653 | 2945 |
2946 } else { | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2947 pr->pattern.complex.value.len = conf->url.len |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2948 + sizeof("/") - 1; |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2949 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2950 p = ngx_pnalloc(cf->pool, pr->pattern.complex.value.len); |
3862
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
2951 if (p == NULL) { |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
2952 return NGX_CONF_ERROR; |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
2953 } |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
2954 |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
2955 pr->pattern.complex.value.data = p; |
3862
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
2956 |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
2957 p = ngx_cpymem(p, conf->url.data, conf->url.len); |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
2958 *p = '/'; |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
2959 |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
2960 ngx_str_set(&pr->replacement.value, "/"); |
653 | 2961 } |
509 | 2962 } |
2963 } | |
2964 | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2965 ngx_conf_merge_ptr_value(conf->cookie_domains, prev->cookie_domains, NULL); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2966 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2967 ngx_conf_merge_ptr_value(conf->cookie_paths, prev->cookie_paths, NULL); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2968 |
2753
9ba1bee1b1e4
merge SSL context inside "if" block
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
2969 #if (NGX_HTTP_SSL) |
9ba1bee1b1e4
merge SSL context inside "if" block
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
2970 if (conf->upstream.ssl == NULL) { |
9ba1bee1b1e4
merge SSL context inside "if" block
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
2971 conf->upstream.ssl = prev->upstream.ssl; |
9ba1bee1b1e4
merge SSL context inside "if" block
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
2972 } |
9ba1bee1b1e4
merge SSL context inside "if" block
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
2973 #endif |
9ba1bee1b1e4
merge SSL context inside "if" block
Igor Sysoev <igor@sysoev.ru>
parents:
2716
diff
changeset
|
2974 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2975 ngx_conf_merge_uint_value(conf->http_version, prev->http_version, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2976 NGX_HTTP_VERSION_10); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2977 |
1180
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
2978 ngx_conf_merge_uint_value(conf->headers_hash_max_size, |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
2979 prev->headers_hash_max_size, 512); |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
2980 |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
2981 ngx_conf_merge_uint_value(conf->headers_hash_bucket_size, |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
2982 prev->headers_hash_bucket_size, 64); |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
2983 |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
2984 conf->headers_hash_bucket_size = ngx_align(conf->headers_hash_bucket_size, |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
2985 ngx_cacheline_size); |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
2986 |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
2987 hash.max_size = conf->headers_hash_max_size; |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
2988 hash.bucket_size = conf->headers_hash_bucket_size; |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
2989 hash.name = "proxy_headers_hash"; |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
2990 |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
2991 if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream, |
3670
2728c4e4a9ae
do not use a cache headers set to hide
Igor Sysoev <igor@sysoev.ru>
parents:
3667
diff
changeset
|
2992 &prev->upstream, ngx_http_proxy_hide_headers, &hash) |
649 | 2993 != NGX_OK) |
2994 { | |
2995 return NGX_CONF_ERROR; | |
2996 } | |
2997 | |
884 | 2998 if (conf->upstream.upstream == NULL) { |
2999 conf->upstream.upstream = prev->upstream.upstream; | |
1658 | 3000 conf->vars = prev->vars; |
507 | 3001 } |
3002 | |
3734
e3a6785b5be4
*) make code consistent to fastcgi, etc
Igor Sysoev <igor@sysoev.ru>
parents:
3733
diff
changeset
|
3003 if (conf->proxy_lengths == NULL) { |
e3a6785b5be4
*) make code consistent to fastcgi, etc
Igor Sysoev <igor@sysoev.ru>
parents:
3733
diff
changeset
|
3004 conf->proxy_lengths = prev->proxy_lengths; |
e3a6785b5be4
*) make code consistent to fastcgi, etc
Igor Sysoev <igor@sysoev.ru>
parents:
3733
diff
changeset
|
3005 conf->proxy_values = prev->proxy_values; |
e3a6785b5be4
*) make code consistent to fastcgi, etc
Igor Sysoev <igor@sysoev.ru>
parents:
3733
diff
changeset
|
3006 } |
e3a6785b5be4
*) make code consistent to fastcgi, etc
Igor Sysoev <igor@sysoev.ru>
parents:
3733
diff
changeset
|
3007 |
3731
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
3008 if (conf->upstream.upstream || conf->proxy_lengths) { |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
3009 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
3010 if (clcf->handler == NULL && clcf->lmt_excpt) { |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
3011 clcf->handler = ngx_http_proxy_handler; |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
3012 conf->location = prev->location; |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
3013 } |
72cc5b789021
inherit proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass inside
Igor Sysoev <igor@sysoev.ru>
parents:
3729
diff
changeset
|
3014 } |
577 | 3015 |
3016 if (conf->body_source.data == NULL) { | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3017 conf->body_flushes = prev->body_flushes; |
577 | 3018 conf->body_source = prev->body_source; |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3019 conf->body_lengths = prev->body_lengths; |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3020 conf->body_values = prev->body_values; |
577 | 3021 } |
3022 | |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3023 if (conf->body_source.data && conf->body_lengths == NULL) { |
577 | 3024 |
3025 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
3026 | |
3027 sc.cf = cf; | |
3028 sc.source = &conf->body_source; | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3029 sc.flushes = &conf->body_flushes; |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3030 sc.lengths = &conf->body_lengths; |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3031 sc.values = &conf->body_values; |
577 | 3032 sc.complete_lengths = 1; |
3033 sc.complete_values = 1; | |
3034 | |
3035 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
3036 return NGX_CONF_ERROR; | |
3037 } | |
3038 } | |
3039 | |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3040 if (conf->headers_source == NULL) { |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3041 conf->headers = prev->headers; |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3042 #if (NGX_HTTP_CACHE) |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3043 conf->headers_cache = prev->headers_cache; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3044 #endif |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3045 conf->headers_source = prev->headers_source; |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3046 } |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3047 |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3048 rc = ngx_http_proxy_init_headers(cf, conf, &conf->headers, |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3049 ngx_http_proxy_headers); |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3050 if (rc != NGX_OK) { |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3051 return NGX_CONF_ERROR; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3052 } |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3053 |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3054 #if (NGX_HTTP_CACHE) |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3055 |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3056 if (conf->upstream.cache) { |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3057 rc = ngx_http_proxy_init_headers(cf, conf, &conf->headers_cache, |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3058 ngx_http_proxy_cache_headers); |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3059 if (rc != NGX_OK) { |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3060 return NGX_CONF_ERROR; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3061 } |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3062 } |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3063 |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3064 #endif |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3065 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3066 return NGX_CONF_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3067 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3068 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3069 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3070 static ngx_int_t |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3071 ngx_http_proxy_init_headers(ngx_conf_t *cf, ngx_http_proxy_loc_conf_t *conf, |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3072 ngx_http_proxy_headers_t *headers, ngx_keyval_t *default_headers) |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3073 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3074 u_char *p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3075 size_t size; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3076 uintptr_t *code; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3077 ngx_uint_t i; |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3078 ngx_array_t headers_names, headers_merged; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3079 ngx_keyval_t *src, *s, *h; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3080 ngx_hash_key_t *hk; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3081 ngx_hash_init_t hash; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3082 ngx_http_script_compile_t sc; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3083 ngx_http_script_copy_code_t *copy; |
577 | 3084 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3085 if (headers->hash.buckets) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3086 return NGX_OK; |
509 | 3087 } |
3088 | |
3561
20708cffd6dc
use local headers_names array instead of stored in configuration
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
3089 if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t)) |
20708cffd6dc
use local headers_names array instead of stored in configuration
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
3090 != NGX_OK) |
20708cffd6dc
use local headers_names array instead of stored in configuration
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
3091 { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3092 return NGX_ERROR; |
509 | 3093 } |
3094 | |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3095 if (ngx_array_init(&headers_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t)) |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3096 != NGX_OK) |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3097 { |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3098 return NGX_ERROR; |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3099 } |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3100 |
509 | 3101 if (conf->headers_source == NULL) { |
3102 conf->headers_source = ngx_array_create(cf->pool, 4, | |
649 | 3103 sizeof(ngx_keyval_t)); |
509 | 3104 if (conf->headers_source == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3105 return NGX_ERROR; |
509 | 3106 } |
3107 } | |
507 | 3108 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3109 headers->lengths = ngx_array_create(cf->pool, 64, 1); |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3110 if (headers->lengths == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3111 return NGX_ERROR; |
509 | 3112 } |
3113 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3114 headers->values = ngx_array_create(cf->pool, 512, 1); |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3115 if (headers->values == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3116 return NGX_ERROR; |
509 | 3117 } |
3118 | |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3119 src = conf->headers_source->elts; |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3120 for (i = 0; i < conf->headers_source->nelts; i++) { |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3121 |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3122 s = ngx_array_push(&headers_merged); |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3123 if (s == NULL) { |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3124 return NGX_ERROR; |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3125 } |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3126 |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3127 *s = src[i]; |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3128 } |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3129 |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3130 h = default_headers; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3131 |
2705
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
3132 while (h->key.len) { |
509 | 3133 |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3134 src = headers_merged.elts; |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3135 for (i = 0; i < headers_merged.nelts; i++) { |
509 | 3136 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { |
3137 goto next; | |
507 | 3138 } |
3139 } | |
3140 | |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3141 s = ngx_array_push(&headers_merged); |
509 | 3142 if (s == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3143 return NGX_ERROR; |
507 | 3144 } |
3145 | |
509 | 3146 *s = *h; |
507 | 3147 |
509 | 3148 next: |
507 | 3149 |
2705
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
3150 h++; |
509 | 3151 } |
507 | 3152 |
577 | 3153 |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3154 src = headers_merged.elts; |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3155 for (i = 0; i < headers_merged.nelts; i++) { |
507 | 3156 |
3561
20708cffd6dc
use local headers_names array instead of stored in configuration
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
3157 hk = ngx_array_push(&headers_names); |
649 | 3158 if (hk == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3159 return NGX_ERROR; |
507 | 3160 } |
3161 | |
649 | 3162 hk->key = src[i].key; |
3163 hk->key_hash = ngx_hash_key_lc(src[i].key.data, src[i].key.len); | |
3164 hk->value = (void *) 1; | |
509 | 3165 |
519 | 3166 if (src[i].value.len == 0) { |
3167 continue; | |
3168 } | |
3169 | |
509 | 3170 if (ngx_http_script_variables_count(&src[i].value) == 0) { |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3171 copy = ngx_array_push_n(headers->lengths, |
509 | 3172 sizeof(ngx_http_script_copy_code_t)); |
3173 if (copy == NULL) { | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3174 return NGX_ERROR; |
509 | 3175 } |
3176 | |
3177 copy->code = (ngx_http_script_code_pt) | |
3178 ngx_http_script_copy_len_code; | |
3179 copy->len = src[i].key.len + sizeof(": ") - 1 | |
3180 + src[i].value.len + sizeof(CRLF) - 1; | |
507 | 3181 |
3182 | |
509 | 3183 size = (sizeof(ngx_http_script_copy_code_t) |
3184 + src[i].key.len + sizeof(": ") - 1 | |
3185 + src[i].value.len + sizeof(CRLF) - 1 | |
3186 + sizeof(uintptr_t) - 1) | |
3187 & ~(sizeof(uintptr_t) - 1); | |
3188 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3189 copy = ngx_array_push_n(headers->values, size); |
509 | 3190 if (copy == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3191 return NGX_ERROR; |
509 | 3192 } |
3193 | |
3194 copy->code = ngx_http_script_copy_code; | |
3195 copy->len = src[i].key.len + sizeof(": ") - 1 | |
3196 + src[i].value.len + sizeof(CRLF) - 1; | |
3197 | |
3198 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t); | |
3199 | |
3200 p = ngx_cpymem(p, src[i].key.data, src[i].key.len); | |
3201 *p++ = ':'; *p++ = ' '; | |
3202 p = ngx_cpymem(p, src[i].value.data, src[i].value.len); | |
3203 *p++ = CR; *p = LF; | |
3204 | |
3205 } else { | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3206 copy = ngx_array_push_n(headers->lengths, |
509 | 3207 sizeof(ngx_http_script_copy_code_t)); |
3208 if (copy == NULL) { | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3209 return NGX_ERROR; |
509 | 3210 } |
3211 | |
3212 copy->code = (ngx_http_script_code_pt) | |
3213 ngx_http_script_copy_len_code; | |
3214 copy->len = src[i].key.len + sizeof(": ") - 1; | |
507 | 3215 |
3216 | |
509 | 3217 size = (sizeof(ngx_http_script_copy_code_t) |
3218 + src[i].key.len + sizeof(": ") - 1 + sizeof(uintptr_t) - 1) | |
3219 & ~(sizeof(uintptr_t) - 1); | |
3220 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3221 copy = ngx_array_push_n(headers->values, size); |
509 | 3222 if (copy == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3223 return NGX_ERROR; |
509 | 3224 } |
3225 | |
3226 copy->code = ngx_http_script_copy_code; | |
3227 copy->len = src[i].key.len + sizeof(": ") - 1; | |
3228 | |
3229 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t); | |
3230 p = ngx_cpymem(p, src[i].key.data, src[i].key.len); | |
3231 *p++ = ':'; *p = ' '; | |
3232 | |
3233 | |
3234 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
3235 | |
3236 sc.cf = cf; | |
3237 sc.source = &src[i].value; | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3238 sc.flushes = &headers->flushes; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3239 sc.lengths = &headers->lengths; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3240 sc.values = &headers->values; |
509 | 3241 |
3242 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3243 return NGX_ERROR; |
509 | 3244 } |
3245 | |
3246 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3247 copy = ngx_array_push_n(headers->lengths, |
509 | 3248 sizeof(ngx_http_script_copy_code_t)); |
3249 if (copy == NULL) { | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3250 return NGX_ERROR; |
509 | 3251 } |
3252 | |
3253 copy->code = (ngx_http_script_code_pt) | |
3254 ngx_http_script_copy_len_code; | |
3255 copy->len = sizeof(CRLF) - 1; | |
3256 | |
3257 | |
3258 size = (sizeof(ngx_http_script_copy_code_t) | |
3259 + sizeof(CRLF) - 1 + sizeof(uintptr_t) - 1) | |
3260 & ~(sizeof(uintptr_t) - 1); | |
3261 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3262 copy = ngx_array_push_n(headers->values, size); |
509 | 3263 if (copy == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3264 return NGX_ERROR; |
509 | 3265 } |
3266 | |
3267 copy->code = ngx_http_script_copy_code; | |
3268 copy->len = sizeof(CRLF) - 1; | |
3269 | |
3270 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t); | |
3271 *p++ = CR; *p = LF; | |
507 | 3272 } |
3273 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3274 code = ngx_array_push_n(headers->lengths, sizeof(uintptr_t)); |
509 | 3275 if (code == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3276 return NGX_ERROR; |
507 | 3277 } |
3278 | |
509 | 3279 *code = (uintptr_t) NULL; |
3280 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3281 code = ngx_array_push_n(headers->values, sizeof(uintptr_t)); |
509 | 3282 if (code == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3283 return NGX_ERROR; |
509 | 3284 } |
3285 | |
3286 *code = (uintptr_t) NULL; | |
507 | 3287 } |
3288 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3289 code = ngx_array_push_n(headers->lengths, sizeof(uintptr_t)); |
509 | 3290 if (code == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3291 return NGX_ERROR; |
507 | 3292 } |
3293 | |
509 | 3294 *code = (uintptr_t) NULL; |
507 | 3295 |
3296 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3297 hash.hash = &headers->hash; |
649 | 3298 hash.key = ngx_hash_key_lc; |
1180
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
3299 hash.max_size = conf->headers_hash_max_size; |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
3300 hash.bucket_size = conf->headers_hash_bucket_size; |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
3301 hash.name = "proxy_headers_hash"; |
649 | 3302 hash.pool = cf->pool; |
3303 hash.temp_pool = NULL; | |
3304 | |
3561
20708cffd6dc
use local headers_names array instead of stored in configuration
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
3305 return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts); |
507 | 3306 } |
3307 | |
3308 | |
3309 static char * | |
3310 ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
3311 { | |
509 | 3312 ngx_http_proxy_loc_conf_t *plcf = conf; |
507 | 3313 |
1658 | 3314 size_t add; |
3315 u_short port; | |
3316 ngx_str_t *value, *url; | |
3317 ngx_url_t u; | |
3318 ngx_uint_t n; | |
3319 ngx_http_core_loc_conf_t *clcf; | |
3320 ngx_http_script_compile_t sc; | |
507 | 3321 |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2285
diff
changeset
|
3322 if (plcf->upstream.upstream || plcf->proxy_lengths) { |
555 | 3323 return "is duplicate"; |
3324 } | |
3325 | |
1658 | 3326 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); |
3327 | |
2989
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2949
diff
changeset
|
3328 clcf->handler = ngx_http_proxy_handler; |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2949
diff
changeset
|
3329 |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2949
diff
changeset
|
3330 if (clcf->name.data[clcf->name.len - 1] == '/') { |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2949
diff
changeset
|
3331 clcf->auto_redirect = 1; |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2949
diff
changeset
|
3332 } |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2949
diff
changeset
|
3333 |
507 | 3334 value = cf->args->elts; |
3335 | |
3336 url = &value[1]; | |
3337 | |
1658 | 3338 n = ngx_http_script_variables_count(url); |
3339 | |
3340 if (n) { | |
3341 | |
3342 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
3343 | |
3344 sc.cf = cf; | |
3345 sc.source = url; | |
3346 sc.lengths = &plcf->proxy_lengths; | |
3347 sc.values = &plcf->proxy_values; | |
3348 sc.variables = n; | |
3349 sc.complete_lengths = 1; | |
3350 sc.complete_values = 1; | |
1679
ca317d9b5c09
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1671
diff
changeset
|
3351 |
1658 | 3352 if (ngx_http_script_compile(&sc) != NGX_OK) { |
3353 return NGX_CONF_ERROR; | |
3354 } | |
3355 | |
3356 #if (NGX_HTTP_SSL) | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3357 plcf->ssl = 1; |
1658 | 3358 #endif |
3359 | |
3360 return NGX_CONF_OK; | |
3361 } | |
3362 | |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
969
diff
changeset
|
3363 if (ngx_strncasecmp(url->data, (u_char *) "http://", 7) == 0) { |
577 | 3364 add = 7; |
591 | 3365 port = 80; |
577 | 3366 |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
969
diff
changeset
|
3367 } else if (ngx_strncasecmp(url->data, (u_char *) "https://", 8) == 0) { |
577 | 3368 |
3369 #if (NGX_HTTP_SSL) | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3370 plcf->ssl = 1; |
577 | 3371 |
3372 add = 8; | |
591 | 3373 port = 443; |
577 | 3374 #else |
3375 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
3376 "https protocol requires SSL support"); | |
3377 return NGX_CONF_ERROR; | |
3378 #endif | |
3379 | |
3380 } else { | |
507 | 3381 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid URL prefix"); |
3382 return NGX_CONF_ERROR; | |
3383 } | |
3384 | |
651 | 3385 ngx_memzero(&u, sizeof(ngx_url_t)); |
3386 | |
3387 u.url.len = url->len - add; | |
3388 u.url.data = url->data + add; | |
906 | 3389 u.default_port = port; |
3390 u.uri_part = 1; | |
884 | 3391 u.no_resolve = 1; |
3392 | |
3393 plcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0); | |
3394 if (plcf->upstream.upstream == NULL) { | |
507 | 3395 return NGX_CONF_ERROR; |
3396 } | |
3397 | |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2285
diff
changeset
|
3398 plcf->vars.schema.len = add; |
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2285
diff
changeset
|
3399 plcf->vars.schema.data = url->data; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3400 plcf->vars.key_start = plcf->vars.schema; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3401 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3402 ngx_http_proxy_set_vars(&u, &plcf->vars); |
507 | 3403 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3404 plcf->location = clcf->name; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3405 |
1353 | 3406 if (clcf->named |
507 | 3407 #if (NGX_PCRE) |
1353 | 3408 || clcf->regex |
3409 #endif | |
3410 || clcf->noname) | |
3411 { | |
1658 | 3412 if (plcf->vars.uri.len) { |
573 | 3413 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
3414 "\"proxy_pass\" cannot have URI part in " |
843
ebab9490204c
allow proxy_pass inside limit_except
Igor Sysoev <igor@sysoev.ru>
parents:
812
diff
changeset
|
3415 "location given by regular expression, " |
1353 | 3416 "or inside named location, " |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
3417 "or inside \"if\" statement, " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
3418 "or inside \"limit_except\" block"); |
573 | 3419 return NGX_CONF_ERROR; |
3420 } | |
3421 | |
1658 | 3422 plcf->location.len = 0; |
555 | 3423 } |
3424 | |
1658 | 3425 plcf->url = *url; |
509 | 3426 |
507 | 3427 return NGX_CONF_OK; |
3428 } | |
3429 | |
3430 | |
3431 static char * | |
509 | 3432 ngx_http_proxy_redirect(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
507 | 3433 { |
509 | 3434 ngx_http_proxy_loc_conf_t *plcf = conf; |
3435 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3436 u_char *p; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3437 ngx_str_t *value; |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3438 ngx_http_proxy_rewrite_t *pr; |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3439 ngx_http_compile_complex_value_t ccv; |
509 | 3440 |
3441 if (plcf->redirect == 0) { | |
3442 return NGX_CONF_OK; | |
3443 } | |
3444 | |
4422
b1a9d725ab69
Fixed proxy_redirect off inheritance.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
3445 plcf->redirect = 1; |
b1a9d725ab69
Fixed proxy_redirect off inheritance.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
3446 |
509 | 3447 value = cf->args->elts; |
3448 | |
2784
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3449 if (cf->args->nelts == 2) { |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3450 if (ngx_strcmp(value[1].data, "off") == 0) { |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3451 plcf->redirect = 0; |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3452 plcf->redirects = NULL; |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3453 return NGX_CONF_OK; |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3454 } |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3455 |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3456 if (ngx_strcmp(value[1].data, "false") == 0) { |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3457 ngx_conf_log_error(NGX_LOG_ERR, cf, 0, |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3458 "invalid parameter \"false\", use \"off\" instead"); |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3459 plcf->redirect = 0; |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3460 plcf->redirects = NULL; |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3461 return NGX_CONF_OK; |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3462 } |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3463 |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3464 if (ngx_strcmp(value[1].data, "default") != 0) { |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3465 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3466 "invalid parameter \"%V\"", &value[1]); |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3467 return NGX_CONF_ERROR; |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3468 } |
509 | 3469 } |
3470 | |
3471 if (plcf->redirects == NULL) { | |
3472 plcf->redirects = ngx_array_create(cf->pool, 1, | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3473 sizeof(ngx_http_proxy_rewrite_t)); |
509 | 3474 if (plcf->redirects == NULL) { |
3475 return NGX_CONF_ERROR; | |
3476 } | |
3477 } | |
3478 | |
3479 pr = ngx_array_push(plcf->redirects); | |
3480 if (pr == NULL) { | |
3481 return NGX_CONF_ERROR; | |
3482 } | |
3483 | |
2784
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
3484 if (ngx_strcmp(value[1].data, "default") == 0) { |
3471
d8c56e7851b8
"proxy_redirect default" may not be used if a proxy_pass uses variables
Igor Sysoev <igor@sysoev.ru>
parents:
3470
diff
changeset
|
3485 if (plcf->proxy_lengths) { |
d8c56e7851b8
"proxy_redirect default" may not be used if a proxy_pass uses variables
Igor Sysoev <igor@sysoev.ru>
parents:
3470
diff
changeset
|
3486 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
3487 "\"proxy_redirect default\" cannot be used " |
3471
d8c56e7851b8
"proxy_redirect default" may not be used if a proxy_pass uses variables
Igor Sysoev <igor@sysoev.ru>
parents:
3470
diff
changeset
|
3488 "with \"proxy_pass\" directive with variables"); |
d8c56e7851b8
"proxy_redirect default" may not be used if a proxy_pass uses variables
Igor Sysoev <igor@sysoev.ru>
parents:
3470
diff
changeset
|
3489 return NGX_CONF_ERROR; |
d8c56e7851b8
"proxy_redirect default" may not be used if a proxy_pass uses variables
Igor Sysoev <igor@sysoev.ru>
parents:
3470
diff
changeset
|
3490 } |
d8c56e7851b8
"proxy_redirect default" may not be used if a proxy_pass uses variables
Igor Sysoev <igor@sysoev.ru>
parents:
3470
diff
changeset
|
3491 |
1658 | 3492 if (plcf->url.data == NULL) { |
509 | 3493 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
3494 "\"proxy_redirect default\" should be placed " |
509 | 3495 "after the \"proxy_pass\" directive"); |
3496 return NGX_CONF_ERROR; | |
3497 } | |
3498 | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3499 pr->handler = ngx_http_proxy_rewrite_complex_handler; |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3500 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3501 ngx_memzero(&pr->pattern.complex, sizeof(ngx_http_complex_value_t)); |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3502 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3503 ngx_memzero(&pr->replacement, sizeof(ngx_http_complex_value_t)); |
1658 | 3504 |
3505 if (plcf->vars.uri.len) { | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3506 pr->pattern.complex.value = plcf->url; |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3507 pr->replacement.value = plcf->location; |
653 | 3508 |
3509 } else { | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3510 pr->pattern.complex.value.len = plcf->url.len + sizeof("/") - 1; |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3511 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3512 p = ngx_pnalloc(cf->pool, pr->pattern.complex.value.len); |
3862
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3513 if (p == NULL) { |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3514 return NGX_CONF_ERROR; |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3515 } |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3516 |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3517 pr->pattern.complex.value.data = p; |
3862
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3518 |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3519 p = ngx_cpymem(p, plcf->url.data, plcf->url.len); |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3520 *p = '/'; |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3521 |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3522 ngx_str_set(&pr->replacement.value, "/"); |
653 | 3523 } |
509 | 3524 |
3525 return NGX_CONF_OK; | |
3526 } | |
3527 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3528 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3529 if (value[1].data[0] == '~') { |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3530 value[1].len--; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3531 value[1].data++; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3532 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3533 if (value[1].data[0] == '*') { |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3534 value[1].len--; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3535 value[1].data++; |
4463
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3536 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3537 if (ngx_http_proxy_rewrite_regex(cf, pr, &value[1], 1) != NGX_OK) { |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3538 return NGX_CONF_ERROR; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3539 } |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3540 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3541 } else { |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3542 if (ngx_http_proxy_rewrite_regex(cf, pr, &value[1], 0) != NGX_OK) { |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3543 return NGX_CONF_ERROR; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3544 } |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3545 } |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3546 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3547 } else { |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3548 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3549 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3550 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3551 ccv.cf = cf; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3552 ccv.value = &value[1]; |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3553 ccv.complex_value = &pr->pattern.complex; |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3554 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3555 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3556 return NGX_CONF_ERROR; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3557 } |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3558 |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3559 pr->handler = ngx_http_proxy_rewrite_complex_handler; |
509 | 3560 } |
3561 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3562 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3563 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3564 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3565 ccv.cf = cf; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3566 ccv.value = &value[2]; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3567 ccv.complex_value = &pr->replacement; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3568 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3569 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { |
509 | 3570 return NGX_CONF_ERROR; |
3571 } | |
3572 | |
507 | 3573 return NGX_CONF_OK; |
3574 } | |
3575 | |
3576 | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3577 static char * |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3578 ngx_http_proxy_cookie_domain(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3579 { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3580 ngx_http_proxy_loc_conf_t *plcf = conf; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3581 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3582 ngx_str_t *value; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3583 ngx_http_proxy_rewrite_t *pr; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3584 ngx_http_compile_complex_value_t ccv; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3585 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3586 if (plcf->cookie_domains == NULL) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3587 return NGX_CONF_OK; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3588 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3589 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3590 value = cf->args->elts; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3591 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3592 if (cf->args->nelts == 2) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3593 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3594 if (ngx_strcmp(value[1].data, "off") == 0) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3595 plcf->cookie_domains = NULL; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3596 return NGX_CONF_OK; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3597 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3598 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3599 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3600 "invalid parameter \"%V\"", &value[1]); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3601 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3602 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3603 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3604 if (plcf->cookie_domains == NGX_CONF_UNSET_PTR) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3605 plcf->cookie_domains = ngx_array_create(cf->pool, 1, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3606 sizeof(ngx_http_proxy_rewrite_t)); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3607 if (plcf->cookie_domains == NULL) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3608 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3609 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3610 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3611 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3612 pr = ngx_array_push(plcf->cookie_domains); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3613 if (pr == NULL) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3614 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3615 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3616 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3617 if (value[1].data[0] == '~') { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3618 value[1].len--; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3619 value[1].data++; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3620 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3621 if (ngx_http_proxy_rewrite_regex(cf, pr, &value[1], 1) != NGX_OK) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3622 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3623 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3624 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3625 } else { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3626 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3627 if (value[1].data[0] == '.') { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3628 value[1].len--; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3629 value[1].data++; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3630 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3631 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3632 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3633 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3634 ccv.cf = cf; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3635 ccv.value = &value[1]; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3636 ccv.complex_value = &pr->pattern.complex; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3637 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3638 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3639 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3640 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3641 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3642 pr->handler = ngx_http_proxy_rewrite_domain_handler; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3643 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3644 if (value[2].data[0] == '.') { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3645 value[2].len--; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3646 value[2].data++; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3647 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3648 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3649 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3650 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3651 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3652 ccv.cf = cf; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3653 ccv.value = &value[2]; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3654 ccv.complex_value = &pr->replacement; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3655 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3656 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3657 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3658 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3659 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3660 return NGX_CONF_OK; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3661 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3662 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3663 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3664 static char * |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3665 ngx_http_proxy_cookie_path(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3666 { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3667 ngx_http_proxy_loc_conf_t *plcf = conf; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3668 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3669 ngx_str_t *value; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3670 ngx_http_proxy_rewrite_t *pr; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3671 ngx_http_compile_complex_value_t ccv; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3672 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3673 if (plcf->cookie_paths == NULL) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3674 return NGX_CONF_OK; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3675 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3676 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3677 value = cf->args->elts; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3678 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3679 if (cf->args->nelts == 2) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3680 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3681 if (ngx_strcmp(value[1].data, "off") == 0) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3682 plcf->cookie_paths = NULL; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3683 return NGX_CONF_OK; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3684 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3685 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3686 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3687 "invalid parameter \"%V\"", &value[1]); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3688 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3689 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3690 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3691 if (plcf->cookie_paths == NGX_CONF_UNSET_PTR) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3692 plcf->cookie_paths = ngx_array_create(cf->pool, 1, |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3693 sizeof(ngx_http_proxy_rewrite_t)); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3694 if (plcf->cookie_paths == NULL) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3695 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3696 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3697 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3698 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3699 pr = ngx_array_push(plcf->cookie_paths); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3700 if (pr == NULL) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3701 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3702 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3703 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3704 if (value[1].data[0] == '~') { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3705 value[1].len--; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3706 value[1].data++; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3707 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3708 if (value[1].data[0] == '*') { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3709 value[1].len--; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3710 value[1].data++; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3711 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3712 if (ngx_http_proxy_rewrite_regex(cf, pr, &value[1], 1) != NGX_OK) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3713 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3714 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3715 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3716 } else { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3717 if (ngx_http_proxy_rewrite_regex(cf, pr, &value[1], 0) != NGX_OK) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3718 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3719 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3720 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3721 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3722 } else { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3723 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3724 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3725 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3726 ccv.cf = cf; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3727 ccv.value = &value[1]; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3728 ccv.complex_value = &pr->pattern.complex; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3729 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3730 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3731 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3732 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3733 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3734 pr->handler = ngx_http_proxy_rewrite_complex_handler; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3735 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3736 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3737 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3738 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3739 ccv.cf = cf; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3740 ccv.value = &value[2]; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3741 ccv.complex_value = &pr->replacement; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3742 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3743 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3744 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3745 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3746 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3747 return NGX_CONF_OK; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3748 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3749 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3750 |
4463
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3751 static ngx_int_t |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3752 ngx_http_proxy_rewrite_regex(ngx_conf_t *cf, ngx_http_proxy_rewrite_t *pr, |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3753 ngx_str_t *regex, ngx_uint_t caseless) |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3754 { |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3755 #if (NGX_PCRE) |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3756 u_char errstr[NGX_MAX_CONF_ERRSTR]; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3757 ngx_regex_compile_t rc; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3758 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3759 ngx_memzero(&rc, sizeof(ngx_regex_compile_t)); |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3760 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3761 rc.pattern = *regex; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3762 rc.err.len = NGX_MAX_CONF_ERRSTR; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3763 rc.err.data = errstr; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3764 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3765 if (caseless) { |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3766 rc.options = NGX_REGEX_CASELESS; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3767 } |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3768 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3769 pr->pattern.regex = ngx_http_regex_compile(cf, &rc); |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3770 if (pr->pattern.regex == NULL) { |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3771 return NGX_ERROR; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3772 } |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3773 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3774 pr->handler = ngx_http_proxy_rewrite_regex_handler; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3775 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3776 return NGX_OK; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3777 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3778 #else |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3779 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3780 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3781 "using regex \"%V\" requires PCRE library", regex); |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3782 return NGX_ERROR; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3783 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3784 #endif |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3785 } |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3786 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
3787 |
507 | 3788 static char * |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3789 ngx_http_proxy_store(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3790 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3791 ngx_http_proxy_loc_conf_t *plcf = conf; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3792 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3793 ngx_str_t *value; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3794 ngx_http_script_compile_t sc; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3795 |
2894 | 3796 if (plcf->upstream.store != NGX_CONF_UNSET |
3797 || plcf->upstream.store_lengths) | |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3798 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3799 return "is duplicate"; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3800 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3801 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3802 value = cf->args->elts; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3803 |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3804 if (ngx_strcmp(value[1].data, "off") == 0) { |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3805 plcf->upstream.store = 0; |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3806 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3807 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3808 |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3809 #if (NGX_HTTP_CACHE) |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3810 |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3811 if (plcf->upstream.cache != NGX_CONF_UNSET_PTR |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3812 && plcf->upstream.cache != NULL) |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3813 { |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3814 return "is incompatible with \"proxy_cache\""; |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3815 } |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3816 |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3817 #endif |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3818 |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3819 if (ngx_strcmp(value[1].data, "on") == 0) { |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3820 plcf->upstream.store = 1; |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3821 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3822 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3823 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3824 /* include the terminating '\0' into script */ |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3825 value[1].len++; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3826 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3827 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3828 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3829 sc.cf = cf; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3830 sc.source = &value[1]; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3831 sc.lengths = &plcf->upstream.store_lengths; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3832 sc.values = &plcf->upstream.store_values; |
1563
022ec9420f80
style fix: remove double semicolons
Igor Sysoev <igor@sysoev.ru>
parents:
1488
diff
changeset
|
3833 sc.variables = ngx_http_script_variables_count(&value[1]); |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3834 sc.complete_lengths = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3835 sc.complete_values = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3836 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3837 if (ngx_http_script_compile(&sc) != NGX_OK) { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3838 return NGX_CONF_ERROR; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3839 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3840 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3841 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3842 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3843 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3844 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3845 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3846 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3847 static char * |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3848 ngx_http_proxy_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3849 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3850 ngx_http_proxy_loc_conf_t *plcf = conf; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3851 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3852 ngx_str_t *value; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3853 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3854 value = cf->args->elts; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3855 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3856 if (plcf->upstream.cache != NGX_CONF_UNSET_PTR) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3857 return "is duplicate"; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3858 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3859 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3860 if (ngx_strcmp(value[1].data, "off") == 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3861 plcf->upstream.cache = NULL; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3862 return NGX_CONF_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3863 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3864 |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3865 if (plcf->upstream.store > 0 || plcf->upstream.store_lengths) { |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3866 return "is incompatible with \"proxy_store\""; |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3867 } |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
3868 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3869 plcf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3870 &ngx_http_proxy_module); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3871 if (plcf->upstream.cache == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3872 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3873 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3874 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3875 return NGX_CONF_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3876 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3877 |
2672 | 3878 |
3879 static char * | |
3880 ngx_http_proxy_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
3881 { | |
3882 ngx_http_proxy_loc_conf_t *plcf = conf; | |
3883 | |
3884 ngx_str_t *value; | |
3885 ngx_http_compile_complex_value_t ccv; | |
3886 | |
3887 value = cf->args->elts; | |
3888 | |
4947
4251e72b8bb4
Allow the complex value to be defined as an empty string.
Ruslan Ermilov <ru@nginx.com>
parents:
4927
diff
changeset
|
3889 if (plcf->cache_key.value.data) { |
2672 | 3890 return "is duplicate"; |
3891 } | |
3892 | |
3893 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
3894 | |
3895 ccv.cf = cf; | |
3896 ccv.value = &value[1]; | |
3897 ccv.complex_value = &plcf->cache_key; | |
3898 | |
3899 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
3900 return NGX_CONF_ERROR; | |
3901 } | |
3902 | |
3903 return NGX_CONF_OK; | |
3904 } | |
3905 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3906 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3907 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3908 |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3909 #if (NGX_HTTP_SSL) |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3910 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3911 static char * |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3912 ngx_http_proxy_ssl_password_file(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3913 { |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3914 ngx_http_proxy_loc_conf_t *plcf = conf; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3915 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3916 ngx_str_t *value; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3917 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3918 if (plcf->ssl_passwords != NGX_CONF_UNSET_PTR) { |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3919 return "is duplicate"; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3920 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3921 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3922 value = cf->args->elts; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3923 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3924 plcf->ssl_passwords = ngx_ssl_read_password_file(cf, &value[1]); |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3925 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3926 if (plcf->ssl_passwords == NULL) { |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3927 return NGX_CONF_ERROR; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3928 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3929 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3930 return NGX_CONF_OK; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3931 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3932 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3933 #endif |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3934 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3935 |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3936 static char * |
507 | 3937 ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data) |
3938 { | |
3939 #if (NGX_FREEBSD) | |
3940 ssize_t *np = data; | |
3941 | |
673 | 3942 if ((u_long) *np >= ngx_freebsd_net_inet_tcp_sendspace) { |
507 | 3943 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3944 "\"proxy_send_lowat\" must be less than %d " | |
3945 "(sysctl net.inet.tcp.sendspace)", | |
3946 ngx_freebsd_net_inet_tcp_sendspace); | |
3947 | |
3948 return NGX_CONF_ERROR; | |
3949 } | |
3950 | |
3951 #elif !(NGX_HAVE_SO_SNDLOWAT) | |
3952 ssize_t *np = data; | |
3953 | |
3954 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
3955 "\"proxy_send_lowat\" is not supported, ignored"); | |
3956 | |
3957 *np = 0; | |
3958 | |
3959 #endif | |
3960 | |
3961 return NGX_CONF_OK; | |
3962 } | |
884 | 3963 |
3964 | |
1658 | 3965 #if (NGX_HTTP_SSL) |
3966 | |
3967 static ngx_int_t | |
3968 ngx_http_proxy_set_ssl(ngx_conf_t *cf, ngx_http_proxy_loc_conf_t *plcf) | |
3969 { | |
3970 ngx_pool_cleanup_t *cln; | |
3971 | |
3972 plcf->upstream.ssl = ngx_pcalloc(cf->pool, sizeof(ngx_ssl_t)); | |
3973 if (plcf->upstream.ssl == NULL) { | |
3974 return NGX_ERROR; | |
3975 } | |
3976 | |
3977 plcf->upstream.ssl->log = cf->log; | |
3978 | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3979 if (ngx_ssl_create(plcf->upstream.ssl, plcf->ssl_protocols, NULL) |
1658 | 3980 != NGX_OK) |
3981 { | |
3982 return NGX_ERROR; | |
3983 } | |
3984 | |
5659
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
3985 cln = ngx_pool_cleanup_add(cf->pool, 0); |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
3986 if (cln == NULL) { |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
3987 return NGX_ERROR; |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
3988 } |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
3989 |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
3990 cln->handler = ngx_ssl_cleanup_ctx; |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
3991 cln->data = plcf->upstream.ssl; |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
3992 |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3993 if (plcf->ssl_certificate.len) { |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3994 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3995 if (plcf->ssl_certificate_key.len == 0) { |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3996 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3997 "no \"proxy_ssl_certificate_key\" is defined " |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3998 "for certificate \"%V\"", &plcf->ssl_certificate); |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3999 return NGX_ERROR; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4000 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4001 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4002 if (ngx_ssl_certificate(cf, plcf->upstream.ssl, &plcf->ssl_certificate, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4003 &plcf->ssl_certificate_key, plcf->ssl_passwords) |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4004 != NGX_OK) |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4005 { |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4006 return NGX_ERROR; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4007 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4008 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4009 |
5390
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
4010 if (SSL_CTX_set_cipher_list(plcf->upstream.ssl->ctx, |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
4011 (const char *) plcf->ssl_ciphers.data) |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
4012 == 0) |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
4013 { |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
4014 ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0, |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
4015 "SSL_CTX_set_cipher_list(\"%V\") failed", |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
4016 &plcf->ssl_ciphers); |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
4017 return NGX_ERROR; |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
4018 } |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
4019 |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4020 if (plcf->upstream.ssl_verify) { |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4021 if (plcf->ssl_trusted_certificate.len == 0) { |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4022 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4023 "no proxy_ssl_trusted_certificate for proxy_ssl_verify"); |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4024 return NGX_ERROR; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4025 } |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4026 |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4027 if (ngx_ssl_trusted_certificate(cf, plcf->upstream.ssl, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4028 &plcf->ssl_trusted_certificate, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4029 plcf->ssl_verify_depth) |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4030 != NGX_OK) |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4031 { |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4032 return NGX_ERROR; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4033 } |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4034 |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4035 if (ngx_ssl_crl(cf, plcf->upstream.ssl, &plcf->ssl_crl) != NGX_OK) { |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4036 return NGX_ERROR; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4037 } |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4038 } |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
4039 |
1658 | 4040 return NGX_OK; |
4041 } | |
4042 | |
4043 #endif | |
4044 | |
4045 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4046 static void |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4047 ngx_http_proxy_set_vars(ngx_url_t *u, ngx_http_proxy_vars_t *v) |
1658 | 4048 { |
2203
8e5bf1bc87e2
*) refactor ngx_parse_inet_url()
Igor Sysoev <igor@sysoev.ru>
parents:
2184
diff
changeset
|
4049 if (u->family != AF_UNIX) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4050 |
1658 | 4051 if (u->no_port || u->port == u->default_port) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4052 |
1658 | 4053 v->host_header = u->host; |
4054 | |
4055 if (u->default_port == 80) { | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
4056 ngx_str_set(&v->port, "80"); |
1658 | 4057 |
4058 } else { | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
4059 ngx_str_set(&v->port, "443"); |
1658 | 4060 } |
4061 | |
4062 } else { | |
1671
8075179cae21
ngx_parse_url() saves port text, this allows to use it in proxy host header
Igor Sysoev <igor@sysoev.ru>
parents:
1667
diff
changeset
|
4063 v->host_header.len = u->host.len + 1 + u->port_text.len; |
8075179cae21
ngx_parse_url() saves port text, this allows to use it in proxy host header
Igor Sysoev <igor@sysoev.ru>
parents:
1667
diff
changeset
|
4064 v->host_header.data = u->host.data; |
8075179cae21
ngx_parse_url() saves port text, this allows to use it in proxy host header
Igor Sysoev <igor@sysoev.ru>
parents:
1667
diff
changeset
|
4065 v->port = u->port_text; |
1658 | 4066 } |
4067 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4068 v->key_start.len += v->host_header.len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4069 |
1658 | 4070 } else { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
4071 ngx_str_set(&v->host_header, "localhost"); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
4072 ngx_str_null(&v->port); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4073 v->key_start.len += sizeof("unix:") - 1 + u->host.len + 1; |
1658 | 4074 } |
4075 | |
4076 v->uri = u->uri; | |
4077 } |