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