Mercurial > hg > nginx
annotate src/http/modules/ngx_http_proxy_module.c @ 9202:e88cdaa0f1ff
AIO operations now add timers (ticket #2162).
Each AIO (thread IO) operation being run is now accompanied with 1-minute
timer. This timer prevents unexpected shutdown of the worker process while
an AIO operation is running, and logs an alert if the operation is running
for too long.
This fixes "open socket left" alerts during worker processes shutdown
due to pending AIO (or thread IO) operations while corresponding requests
have no timers. In particular, such errors were observed while reading
cache headers (ticket #2162), and with worker_shutdown_timeout.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 29 Jan 2024 10:31:37 +0300 |
parents | d1cf09451ae8 |
children | 51e0dc713784 |
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 | |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
13 #define NGX_HTTP_PROXY_COOKIE_SECURE 0x0001 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
14 #define NGX_HTTP_PROXY_COOKIE_SECURE_ON 0x0002 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
15 #define NGX_HTTP_PROXY_COOKIE_SECURE_OFF 0x0004 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
16 #define NGX_HTTP_PROXY_COOKIE_HTTPONLY 0x0008 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
17 #define NGX_HTTP_PROXY_COOKIE_HTTPONLY_ON 0x0010 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
18 #define NGX_HTTP_PROXY_COOKIE_HTTPONLY_OFF 0x0020 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
19 #define NGX_HTTP_PROXY_COOKIE_SAMESITE 0x0040 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
20 #define NGX_HTTP_PROXY_COOKIE_SAMESITE_STRICT 0x0080 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
21 #define NGX_HTTP_PROXY_COOKIE_SAMESITE_LAX 0x0100 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
22 #define NGX_HTTP_PROXY_COOKIE_SAMESITE_NONE 0x0200 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
23 #define NGX_HTTP_PROXY_COOKIE_SAMESITE_OFF 0x0400 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
24 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
25 |
5951
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
26 typedef struct { |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
27 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
|
28 } 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
|
29 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
30 |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
31 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
|
32 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
33 typedef ngx_int_t (*ngx_http_proxy_rewrite_pt)(ngx_http_request_t *r, |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
34 ngx_str_t *value, size_t prefix, size_t len, |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
35 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
|
36 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
37 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
|
38 ngx_http_proxy_rewrite_pt handler; |
507 | 39 |
509 | 40 union { |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
41 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
|
42 #if (NGX_PCRE) |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
43 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
|
44 #endif |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
45 } pattern; |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
46 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
47 ngx_http_complex_value_t replacement; |
509 | 48 }; |
49 | |
50 | |
51 typedef struct { | |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
52 union { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
53 ngx_http_complex_value_t complex; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
54 #if (NGX_PCRE) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
55 ngx_http_regex_t *regex; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
56 #endif |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
57 } cookie; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
58 |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
59 ngx_array_t flags_values; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
60 ngx_uint_t regex; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
61 } ngx_http_proxy_cookie_flags_t; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
62 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
63 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
64 typedef struct { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
65 ngx_str_t key_start; |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2285
diff
changeset
|
66 ngx_str_t schema; |
1658 | 67 ngx_str_t host_header; |
68 ngx_str_t port; | |
69 ngx_str_t uri; | |
70 } ngx_http_proxy_vars_t; | |
71 | |
72 | |
73 typedef struct { | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
74 ngx_array_t *flushes; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
75 ngx_array_t *lengths; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
76 ngx_array_t *values; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
77 ngx_hash_t hash; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
78 } ngx_http_proxy_headers_t; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
79 |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
80 |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
81 typedef struct { |
651 | 82 ngx_http_upstream_conf_t upstream; |
83 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
84 ngx_array_t *body_flushes; |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
85 ngx_array_t *body_lengths; |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
86 ngx_array_t *body_values; |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
87 ngx_str_t body_source; |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
88 |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
89 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
|
90 #if (NGX_HTTP_CACHE) |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
91 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
|
92 #endif |
651 | 93 ngx_array_t *headers_source; |
94 | |
1658 | 95 ngx_array_t *proxy_lengths; |
96 ngx_array_t *proxy_values; | |
97 | |
651 | 98 ngx_array_t *redirects; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
99 ngx_array_t *cookie_domains; |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
100 ngx_array_t *cookie_paths; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
101 ngx_array_t *cookie_flags; |
651 | 102 |
6781
ca27074f8f0f
Proxy: support variables for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
6747
diff
changeset
|
103 ngx_http_complex_value_t *method; |
1658 | 104 ngx_str_t location; |
105 ngx_str_t url; | |
106 | |
2672 | 107 #if (NGX_HTTP_CACHE) |
108 ngx_http_complex_value_t cache_key; | |
109 #endif | |
110 | |
1658 | 111 ngx_http_proxy_vars_t vars; |
651 | 112 |
113 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
|
114 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
115 ngx_uint_t http_version; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
116 |
1180
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
117 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
|
118 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
|
119 |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
120 #if (NGX_HTTP_SSL) |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
121 ngx_uint_t ssl; |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
122 ngx_uint_t ssl_protocols; |
5390
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
123 ngx_str_t ssl_ciphers; |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
124 ngx_uint_t ssl_verify_depth; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
125 ngx_str_t ssl_trusted_certificate; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
126 ngx_str_t ssl_crl; |
7730
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
127 ngx_array_t *ssl_conf_commands; |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
128 #endif |
507 | 129 } ngx_http_proxy_loc_conf_t; |
130 | |
131 | |
132 typedef struct { | |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
133 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
|
134 ngx_http_chunked_t chunked; |
1658 | 135 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
|
136 off_t internal_body_length; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
137 |
6051
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
138 ngx_chain_t *free; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
139 ngx_chain_t *busy; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
140 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
141 unsigned head:1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
142 unsigned internal_chunked:1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
143 unsigned header_sent:1; |
509 | 144 } ngx_http_proxy_ctx_t; |
507 | 145 |
146 | |
1658 | 147 static ngx_int_t ngx_http_proxy_eval(ngx_http_request_t *r, |
148 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
|
149 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
150 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
|
151 #endif |
507 | 152 static ngx_int_t ngx_http_proxy_create_request(ngx_http_request_t *r); |
153 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
|
154 static ngx_int_t ngx_http_proxy_body_output_filter(void *data, ngx_chain_t *in); |
509 | 155 static ngx_int_t ngx_http_proxy_process_status_line(ngx_http_request_t *r); |
507 | 156 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
|
157 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
|
158 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
|
159 ngx_buf_t *buf); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
160 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
|
161 ngx_buf_t *buf); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
162 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
|
163 ssize_t bytes); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
164 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
|
165 ssize_t bytes); |
507 | 166 static void ngx_http_proxy_abort_request(ngx_http_request_t *r); |
167 static void ngx_http_proxy_finalize_request(ngx_http_request_t *r, | |
168 ngx_int_t rc); | |
169 | |
573 | 170 static ngx_int_t ngx_http_proxy_host_variable(ngx_http_request_t *r, |
171 ngx_http_variable_value_t *v, uintptr_t data); | |
172 static ngx_int_t ngx_http_proxy_port_variable(ngx_http_request_t *r, | |
173 ngx_http_variable_value_t *v, uintptr_t data); | |
174 static ngx_int_t | |
509 | 175 ngx_http_proxy_add_x_forwarded_for_variable(ngx_http_request_t *r, |
573 | 176 ngx_http_variable_value_t *v, uintptr_t data); |
577 | 177 static ngx_int_t |
178 ngx_http_proxy_internal_body_length_variable(ngx_http_request_t *r, | |
179 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
|
180 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
|
181 ngx_http_variable_value_t *v, uintptr_t data); |
509 | 182 static ngx_int_t ngx_http_proxy_rewrite_redirect(ngx_http_request_t *r, |
183 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
|
184 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
|
185 ngx_table_elt_t *h); |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
186 static ngx_int_t ngx_http_proxy_parse_cookie(ngx_str_t *value, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
187 ngx_array_t *attrs); |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
188 static ngx_int_t ngx_http_proxy_rewrite_cookie_value(ngx_http_request_t *r, |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
189 ngx_str_t *value, ngx_array_t *rewrites); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
190 static ngx_int_t ngx_http_proxy_rewrite_cookie_flags(ngx_http_request_t *r, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
191 ngx_array_t *attrs, ngx_array_t *flags); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
192 static ngx_int_t ngx_http_proxy_edit_cookie_flags(ngx_http_request_t *r, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
193 ngx_array_t *attrs, ngx_uint_t flags); |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
194 static ngx_int_t ngx_http_proxy_rewrite(ngx_http_request_t *r, |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
195 ngx_str_t *value, size_t prefix, size_t len, ngx_str_t *replacement); |
507 | 196 |
509 | 197 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
|
198 static void *ngx_http_proxy_create_main_conf(ngx_conf_t *cf); |
507 | 199 static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf); |
200 static char *ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, | |
201 void *parent, void *child); | |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
202 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
|
203 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
|
204 ngx_keyval_t *default_headers); |
507 | 205 |
206 static char *ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, | |
207 void *conf); | |
509 | 208 static char *ngx_http_proxy_redirect(ngx_conf_t *cf, ngx_command_t *cmd, |
209 void *conf); | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
210 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
|
211 void *conf); |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
212 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
|
213 void *conf); |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
214 static char *ngx_http_proxy_cookie_flags(ngx_conf_t *cf, ngx_command_t *cmd, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
215 void *conf); |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
216 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
|
217 void *conf); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
218 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
219 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
|
220 void *conf); |
2672 | 221 static char *ngx_http_proxy_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, |
222 void *conf); | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
223 #endif |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
224 #if (NGX_HTTP_SSL) |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
225 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
|
226 ngx_command_t *cmd, void *conf); |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
227 #endif |
507 | 228 |
229 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data); | |
7730
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
230 #if (NGX_HTTP_SSL) |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
231 static char *ngx_http_proxy_ssl_conf_command_check(ngx_conf_t *cf, void *post, |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
232 void *data); |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
233 #endif |
507 | 234 |
4463
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
235 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
|
236 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
|
237 |
1658 | 238 #if (NGX_HTTP_SSL) |
8053
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
239 static ngx_int_t ngx_http_proxy_merge_ssl(ngx_conf_t *cf, |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
240 ngx_http_proxy_loc_conf_t *conf, ngx_http_proxy_loc_conf_t *prev); |
1658 | 241 static ngx_int_t ngx_http_proxy_set_ssl(ngx_conf_t *cf, |
242 ngx_http_proxy_loc_conf_t *plcf); | |
243 #endif | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
244 static void ngx_http_proxy_set_vars(ngx_url_t *u, ngx_http_proxy_vars_t *v); |
1658 | 245 |
509 | 246 |
507 | 247 static ngx_conf_post_t ngx_http_proxy_lowat_post = |
509 | 248 { ngx_http_proxy_lowat_check }; |
249 | |
507 | 250 |
251 static ngx_conf_bitmask_t ngx_http_proxy_next_upstream_masks[] = { | |
252 { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR }, | |
253 { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT }, | |
254 { 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
|
255 { ngx_string("non_idempotent"), NGX_HTTP_UPSTREAM_FT_NON_IDEMPOTENT }, |
507 | 256 { 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
|
257 { ngx_string("http_502"), NGX_HTTP_UPSTREAM_FT_HTTP_502 }, |
623 | 258 { 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
|
259 { 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
|
260 { ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 }, |
507 | 261 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 }, |
6966
fa56ab75cffc
Upstream: allow recovery from "429 Too Many Requests" response.
Piotr Sikora <piotrsikora@google.com>
parents:
6906
diff
changeset
|
262 { ngx_string("http_429"), NGX_HTTP_UPSTREAM_FT_HTTP_429 }, |
2927
55ceaef03d34
proxy_cache_use_stale/fastcgi_cache_use_stale updating
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
263 { ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING }, |
665 | 264 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF }, |
507 | 265 { ngx_null_string, 0 } |
266 }; | |
267 | |
268 | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
269 #if (NGX_HTTP_SSL) |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
270 |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
271 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
|
272 { ngx_string("SSLv2"), NGX_SSL_SSLv2 }, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
273 { ngx_string("SSLv3"), NGX_SSL_SSLv3 }, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
274 { ngx_string("TLSv1"), NGX_SSL_TLSv1 }, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
275 { 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
|
276 { ngx_string("TLSv1.2"), NGX_SSL_TLSv1_2 }, |
6981
08dc60979133
SSL: added support for TLSv1.3 in ssl_protocols directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6966
diff
changeset
|
277 { ngx_string("TLSv1.3"), NGX_SSL_TLSv1_3 }, |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
278 { ngx_null_string, 0 } |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
279 }; |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
280 |
7730
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
281 static ngx_conf_post_t ngx_http_proxy_ssl_conf_command_post = |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
282 { ngx_http_proxy_ssl_conf_command_check }; |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
283 |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
284 #endif |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
285 |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
286 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
287 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
|
288 { 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
|
289 { 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
|
290 { ngx_null_string, 0 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
291 }; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
292 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
293 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
294 ngx_module_t ngx_http_proxy_module; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
295 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
296 |
507 | 297 static ngx_command_t ngx_http_proxy_commands[] = { |
298 | |
299 { ngx_string("proxy_pass"), | |
843
ebab9490204c
allow proxy_pass inside limit_except
Igor Sysoev <igor@sysoev.ru>
parents:
812
diff
changeset
|
300 NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_HTTP_LMT_CONF|NGX_CONF_TAKE1, |
507 | 301 ngx_http_proxy_pass, |
302 NGX_HTTP_LOC_CONF_OFFSET, | |
303 0, | |
304 NULL }, | |
305 | |
509 | 306 { ngx_string("proxy_redirect"), |
307 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12, | |
308 ngx_http_proxy_redirect, | |
309 NGX_HTTP_LOC_CONF_OFFSET, | |
310 0, | |
311 NULL }, | |
312 | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
313 { ngx_string("proxy_cookie_domain"), |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
314 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
|
315 ngx_http_proxy_cookie_domain, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
316 NGX_HTTP_LOC_CONF_OFFSET, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
317 0, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
318 NULL }, |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
319 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
320 { ngx_string("proxy_cookie_path"), |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
321 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
|
322 ngx_http_proxy_cookie_path, |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
323 NGX_HTTP_LOC_CONF_OFFSET, |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
324 0, |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
325 NULL }, |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
326 |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
327 { ngx_string("proxy_cookie_flags"), |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
328 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
329 ngx_http_proxy_cookie_flags, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
330 NGX_HTTP_LOC_CONF_OFFSET, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
331 0, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
332 NULL }, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
333 |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1244
diff
changeset
|
334 { ngx_string("proxy_store"), |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
335 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
|
336 ngx_http_proxy_store, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
337 NGX_HTTP_LOC_CONF_OFFSET, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
338 0, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
339 NULL }, |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
340 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
341 { ngx_string("proxy_store_access"), |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1244
diff
changeset
|
342 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
|
343 ngx_conf_set_access_slot, |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1244
diff
changeset
|
344 NGX_HTTP_LOC_CONF_OFFSET, |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
345 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
|
346 NULL }, |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1244
diff
changeset
|
347 |
581 | 348 { ngx_string("proxy_buffering"), |
349 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
350 ngx_conf_set_flag_slot, | |
351 NGX_HTTP_LOC_CONF_OFFSET, | |
352 offsetof(ngx_http_proxy_loc_conf_t, upstream.buffering), | |
353 NULL }, | |
354 | |
6050
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
355 { ngx_string("proxy_request_buffering"), |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
356 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
|
357 ngx_conf_set_flag_slot, |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
358 NGX_HTTP_LOC_CONF_OFFSET, |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
359 offsetof(ngx_http_proxy_loc_conf_t, upstream.request_buffering), |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
360 NULL }, |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
361 |
629 | 362 { ngx_string("proxy_ignore_client_abort"), |
363 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
364 ngx_conf_set_flag_slot, | |
365 NGX_HTTP_LOC_CONF_OFFSET, | |
366 offsetof(ngx_http_proxy_loc_conf_t, upstream.ignore_client_abort), | |
367 NULL }, | |
368 | |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
369 { ngx_string("proxy_bind"), |
6530
1d0e03db9f8e
Upstream: the "transparent" parameter of proxy_bind and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6480
diff
changeset
|
370 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12, |
3399 | 371 ngx_http_upstream_bind_set_slot, |
3271
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
372 NGX_HTTP_LOC_CONF_OFFSET, |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
373 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
|
374 NULL }, |
fcd98af88df3
proxy_bind, fastcgi_bind, and memcached_bind
Igor Sysoev <igor@sysoev.ru>
parents:
3006
diff
changeset
|
375 |
7371
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
376 { ngx_string("proxy_socket_keepalive"), |
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
377 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
378 ngx_conf_set_flag_slot, |
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
379 NGX_HTTP_LOC_CONF_OFFSET, |
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
380 offsetof(ngx_http_proxy_loc_conf_t, upstream.socket_keepalive), |
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
381 NULL }, |
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
382 |
507 | 383 { ngx_string("proxy_connect_timeout"), |
384 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
385 ngx_conf_set_msec_slot, | |
386 NGX_HTTP_LOC_CONF_OFFSET, | |
387 offsetof(ngx_http_proxy_loc_conf_t, upstream.connect_timeout), | |
388 NULL }, | |
389 | |
390 { ngx_string("proxy_send_timeout"), | |
391 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
392 ngx_conf_set_msec_slot, | |
393 NGX_HTTP_LOC_CONF_OFFSET, | |
394 offsetof(ngx_http_proxy_loc_conf_t, upstream.send_timeout), | |
395 NULL }, | |
396 | |
397 { ngx_string("proxy_send_lowat"), | |
398 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
399 ngx_conf_set_size_slot, | |
400 NGX_HTTP_LOC_CONF_OFFSET, | |
401 offsetof(ngx_http_proxy_loc_conf_t, upstream.send_lowat), | |
402 &ngx_http_proxy_lowat_post }, | |
403 | |
657 | 404 { ngx_string("proxy_intercept_errors"), |
405 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
406 ngx_conf_set_flag_slot, | |
407 NGX_HTTP_LOC_CONF_OFFSET, | |
408 offsetof(ngx_http_proxy_loc_conf_t, upstream.intercept_errors), | |
409 NULL }, | |
410 | |
509 | 411 { ngx_string("proxy_set_header"), |
412 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | |
649 | 413 ngx_conf_set_keyval_slot, |
507 | 414 NGX_HTTP_LOC_CONF_OFFSET, |
509 | 415 offsetof(ngx_http_proxy_loc_conf_t, headers_source), |
507 | 416 NULL }, |
417 | |
1180
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
418 { 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
|
419 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
|
420 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
|
421 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
|
422 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
|
423 NULL }, |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
424 |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
425 { 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
|
426 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
|
427 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
|
428 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
|
429 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
|
430 NULL }, |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
431 |
577 | 432 { ngx_string("proxy_set_body"), |
433 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
434 ngx_conf_set_str_slot, | |
435 NGX_HTTP_LOC_CONF_OFFSET, | |
436 offsetof(ngx_http_proxy_loc_conf_t, body_source), | |
437 NULL }, | |
438 | |
509 | 439 { ngx_string("proxy_method"), |
440 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
|
441 ngx_http_set_complex_value_slot, |
509 | 442 NGX_HTTP_LOC_CONF_OFFSET, |
561 | 443 offsetof(ngx_http_proxy_loc_conf_t, method), |
444 NULL }, | |
509 | 445 |
446 { ngx_string("proxy_pass_request_headers"), | |
507 | 447 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
448 ngx_conf_set_flag_slot, | |
449 NGX_HTTP_LOC_CONF_OFFSET, | |
509 | 450 offsetof(ngx_http_proxy_loc_conf_t, upstream.pass_request_headers), |
507 | 451 NULL }, |
452 | |
509 | 453 { ngx_string("proxy_pass_request_body"), |
507 | 454 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
455 ngx_conf_set_flag_slot, | |
456 NGX_HTTP_LOC_CONF_OFFSET, | |
509 | 457 offsetof(ngx_http_proxy_loc_conf_t, upstream.pass_request_body), |
507 | 458 NULL }, |
459 | |
581 | 460 { ngx_string("proxy_buffer_size"), |
461 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
462 ngx_conf_set_size_slot, | |
463 NGX_HTTP_LOC_CONF_OFFSET, | |
464 offsetof(ngx_http_proxy_loc_conf_t, upstream.buffer_size), | |
465 NULL }, | |
466 | |
507 | 467 { ngx_string("proxy_read_timeout"), |
468 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
469 ngx_conf_set_msec_slot, | |
470 NGX_HTTP_LOC_CONF_OFFSET, | |
471 offsetof(ngx_http_proxy_loc_conf_t, upstream.read_timeout), | |
472 NULL }, | |
473 | |
474 { ngx_string("proxy_buffers"), | |
475 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | |
476 ngx_conf_set_bufs_slot, | |
477 NGX_HTTP_LOC_CONF_OFFSET, | |
478 offsetof(ngx_http_proxy_loc_conf_t, upstream.bufs), | |
479 NULL }, | |
480 | |
481 { ngx_string("proxy_busy_buffers_size"), | |
482 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
483 ngx_conf_set_size_slot, | |
484 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 485 offsetof(ngx_http_proxy_loc_conf_t, upstream.busy_buffers_size_conf), |
507 | 486 NULL }, |
487 | |
5874
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
488 { ngx_string("proxy_force_ranges"), |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
489 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
|
490 ngx_conf_set_flag_slot, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
491 NGX_HTTP_LOC_CONF_OFFSET, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
492 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
|
493 NULL }, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
494 |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
495 { ngx_string("proxy_limit_rate"), |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
496 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
|
497 ngx_conf_set_size_slot, |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
498 NGX_HTTP_LOC_CONF_OFFSET, |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
499 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
|
500 NULL }, |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
501 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
502 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
503 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
504 { ngx_string("proxy_cache"), |
3729 | 505 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
|
506 ngx_http_proxy_cache, |
2597 | 507 NGX_HTTP_LOC_CONF_OFFSET, |
2596 | 508 0, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
509 NULL }, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
510 |
2672 | 511 { ngx_string("proxy_cache_key"), |
3729 | 512 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
2672 | 513 ngx_http_proxy_cache_key, |
514 NGX_HTTP_LOC_CONF_OFFSET, | |
515 0, | |
516 NULL }, | |
517 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
518 { ngx_string("proxy_cache_path"), |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
519 NGX_HTTP_MAIN_CONF|NGX_CONF_2MORE, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
520 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
|
521 NGX_HTTP_MAIN_CONF_OFFSET, |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
522 offsetof(ngx_http_proxy_main_conf_t, caches), |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
523 &ngx_http_proxy_module }, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
524 |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
525 { 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
|
526 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
|
527 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
|
528 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
|
529 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
|
530 NULL }, |
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
531 |
3526
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
532 { ngx_string("proxy_no_cache"), |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
533 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
|
534 ngx_http_set_predicate_slot, |
3526
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
535 NGX_HTTP_LOC_CONF_OFFSET, |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
536 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
|
537 NULL }, |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
538 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
539 { ngx_string("proxy_cache_valid"), |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
540 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
|
541 ngx_http_file_cache_valid_set_slot, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
542 NGX_HTTP_LOC_CONF_OFFSET, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
543 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
|
544 NULL }, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
545 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
546 { ngx_string("proxy_cache_min_uses"), |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
547 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
|
548 ngx_conf_set_num_slot, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
549 NGX_HTTP_LOC_CONF_OFFSET, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
550 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
|
551 NULL }, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
552 |
6793
0fba3ed4e7eb
Cache: proxy_cache_max_range_offset and friends.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6785
diff
changeset
|
553 { 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
|
554 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
|
555 ngx_conf_set_off_slot, |
0fba3ed4e7eb
Cache: proxy_cache_max_range_offset and friends.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6785
diff
changeset
|
556 NGX_HTTP_LOC_CONF_OFFSET, |
0fba3ed4e7eb
Cache: proxy_cache_max_range_offset and friends.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6785
diff
changeset
|
557 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
|
558 NULL }, |
0fba3ed4e7eb
Cache: proxy_cache_max_range_offset and friends.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6785
diff
changeset
|
559 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
560 { ngx_string("proxy_cache_use_stale"), |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
561 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
|
562 ngx_conf_set_bitmask_slot, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
563 NGX_HTTP_LOC_CONF_OFFSET, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
564 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
|
565 &ngx_http_proxy_next_upstream_masks }, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
566 |
2875
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
567 { ngx_string("proxy_cache_methods"), |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
568 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
|
569 ngx_conf_set_bitmask_slot, |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
570 NGX_HTTP_LOC_CONF_OFFSET, |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
571 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
|
572 &ngx_http_upstream_cache_method_mask }, |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
573 |
4385
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
574 { ngx_string("proxy_cache_lock"), |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
575 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
|
576 ngx_conf_set_flag_slot, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
577 NGX_HTTP_LOC_CONF_OFFSET, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
578 offsetof(ngx_http_proxy_loc_conf_t, upstream.cache_lock), |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
579 NULL }, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
580 |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
581 { ngx_string("proxy_cache_lock_timeout"), |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
582 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
|
583 ngx_conf_set_msec_slot, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
584 NGX_HTTP_LOC_CONF_OFFSET, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
585 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
|
586 NULL }, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
587 |
5905
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
588 { ngx_string("proxy_cache_lock_age"), |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
589 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
|
590 ngx_conf_set_msec_slot, |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
591 NGX_HTTP_LOC_CONF_OFFSET, |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
592 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
|
593 NULL }, |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
594 |
5441
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
595 { ngx_string("proxy_cache_revalidate"), |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
596 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
|
597 ngx_conf_set_flag_slot, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
598 NGX_HTTP_LOC_CONF_OFFSET, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
599 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
|
600 NULL }, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
601 |
6290
4d5ac1a31d44
Upstream: proxy_cache_convert_head directive.
Roman Arutyunyan <arut@nginx.com>
parents:
6157
diff
changeset
|
602 { ngx_string("proxy_cache_convert_head"), |
4d5ac1a31d44
Upstream: proxy_cache_convert_head directive.
Roman Arutyunyan <arut@nginx.com>
parents:
6157
diff
changeset
|
603 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
|
604 ngx_conf_set_flag_slot, |
4d5ac1a31d44
Upstream: proxy_cache_convert_head directive.
Roman Arutyunyan <arut@nginx.com>
parents:
6157
diff
changeset
|
605 NGX_HTTP_LOC_CONF_OFFSET, |
4d5ac1a31d44
Upstream: proxy_cache_convert_head directive.
Roman Arutyunyan <arut@nginx.com>
parents:
6157
diff
changeset
|
606 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
|
607 NULL }, |
4d5ac1a31d44
Upstream: proxy_cache_convert_head directive.
Roman Arutyunyan <arut@nginx.com>
parents:
6157
diff
changeset
|
608 |
6906
1aeaae6e9446
Upstream: proxy_cache_background_update and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6793
diff
changeset
|
609 { ngx_string("proxy_cache_background_update"), |
1aeaae6e9446
Upstream: proxy_cache_background_update and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6793
diff
changeset
|
610 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
|
611 ngx_conf_set_flag_slot, |
1aeaae6e9446
Upstream: proxy_cache_background_update and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6793
diff
changeset
|
612 NGX_HTTP_LOC_CONF_OFFSET, |
1aeaae6e9446
Upstream: proxy_cache_background_update and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6793
diff
changeset
|
613 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
|
614 NULL }, |
1aeaae6e9446
Upstream: proxy_cache_background_update and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6793
diff
changeset
|
615 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
616 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
617 |
507 | 618 { ngx_string("proxy_temp_path"), |
619 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234, | |
620 ngx_conf_set_path_slot, | |
621 NGX_HTTP_LOC_CONF_OFFSET, | |
622 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
|
623 NULL }, |
507 | 624 |
625 { ngx_string("proxy_max_temp_file_size"), | |
626 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
627 ngx_conf_set_size_slot, | |
628 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 629 offsetof(ngx_http_proxy_loc_conf_t, upstream.max_temp_file_size_conf), |
507 | 630 NULL }, |
631 | |
632 { ngx_string("proxy_temp_file_write_size"), | |
633 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
634 ngx_conf_set_size_slot, | |
635 NGX_HTTP_LOC_CONF_OFFSET, | |
529 | 636 offsetof(ngx_http_proxy_loc_conf_t, upstream.temp_file_write_size_conf), |
507 | 637 NULL }, |
638 | |
639 { ngx_string("proxy_next_upstream"), | |
547 | 640 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
507 | 641 ngx_conf_set_bitmask_slot, |
642 NGX_HTTP_LOC_CONF_OFFSET, | |
643 offsetof(ngx_http_proxy_loc_conf_t, upstream.next_upstream), | |
644 &ngx_http_proxy_next_upstream_masks }, | |
645 | |
5832
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
646 { 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
|
647 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
|
648 ngx_conf_set_num_slot, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
649 NGX_HTTP_LOC_CONF_OFFSET, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
650 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
|
651 NULL }, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
652 |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
653 { 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
|
654 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
|
655 ngx_conf_set_msec_slot, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
656 NGX_HTTP_LOC_CONF_OFFSET, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
657 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
|
658 NULL }, |
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
659 |
649 | 660 { ngx_string("proxy_pass_header"), |
3729 | 661 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
649 | 662 ngx_conf_set_str_array_slot, |
507 | 663 NGX_HTTP_LOC_CONF_OFFSET, |
649 | 664 offsetof(ngx_http_proxy_loc_conf_t, upstream.pass_headers), |
507 | 665 NULL }, |
666 | |
649 | 667 { ngx_string("proxy_hide_header"), |
3729 | 668 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
649 | 669 ngx_conf_set_str_array_slot, |
507 | 670 NGX_HTTP_LOC_CONF_OFFSET, |
649 | 671 offsetof(ngx_http_proxy_loc_conf_t, upstream.hide_headers), |
507 | 672 NULL }, |
673 | |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
674 { ngx_string("proxy_ignore_headers"), |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
675 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
|
676 ngx_conf_set_bitmask_slot, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
677 NGX_HTTP_LOC_CONF_OFFSET, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
678 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
|
679 &ngx_http_upstream_ignore_headers_masks }, |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
680 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
681 { ngx_string("proxy_http_version"), |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
682 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
|
683 ngx_conf_set_enum_slot, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
684 NGX_HTTP_LOC_CONF_OFFSET, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
685 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
|
686 &ngx_http_proxy_http_version }, |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
687 |
2184 | 688 #if (NGX_HTTP_SSL) |
689 | |
690 { ngx_string("proxy_ssl_session_reuse"), | |
691 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
692 ngx_conf_set_flag_slot, | |
693 NGX_HTTP_LOC_CONF_OFFSET, | |
694 offsetof(ngx_http_proxy_loc_conf_t, upstream.ssl_session_reuse), | |
695 NULL }, | |
696 | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
697 { ngx_string("proxy_ssl_protocols"), |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
698 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
|
699 ngx_conf_set_bitmask_slot, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
700 NGX_HTTP_LOC_CONF_OFFSET, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
701 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
|
702 &ngx_http_proxy_ssl_protocols }, |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
703 |
5390
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
704 { ngx_string("proxy_ssl_ciphers"), |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
705 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
|
706 ngx_conf_set_str_slot, |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
707 NGX_HTTP_LOC_CONF_OFFSET, |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
708 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
|
709 NULL }, |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
710 |
5660
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
711 { 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
|
712 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
|
713 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
|
714 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
|
715 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
|
716 NULL }, |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
717 |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
718 { 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
|
719 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
|
720 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
|
721 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
|
722 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
|
723 NULL }, |
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
724 |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
725 { ngx_string("proxy_ssl_verify"), |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
726 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
|
727 ngx_conf_set_flag_slot, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
728 NGX_HTTP_LOC_CONF_OFFSET, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
729 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
|
730 NULL }, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
731 |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
732 { ngx_string("proxy_ssl_verify_depth"), |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
733 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
|
734 ngx_conf_set_num_slot, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
735 NGX_HTTP_LOC_CONF_OFFSET, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
736 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
|
737 NULL }, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
738 |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
739 { ngx_string("proxy_ssl_trusted_certificate"), |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
740 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
|
741 ngx_conf_set_str_slot, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
742 NGX_HTTP_LOC_CONF_OFFSET, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
743 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
|
744 NULL }, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
745 |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
746 { ngx_string("proxy_ssl_crl"), |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
747 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
|
748 ngx_conf_set_str_slot, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
749 NGX_HTTP_LOC_CONF_OFFSET, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
750 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
|
751 NULL }, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
752 |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
753 { ngx_string("proxy_ssl_certificate"), |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
754 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
755 ngx_http_set_complex_value_zero_slot, |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
756 NGX_HTTP_LOC_CONF_OFFSET, |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
757 offsetof(ngx_http_proxy_loc_conf_t, upstream.ssl_certificate), |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
758 NULL }, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
759 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
760 { ngx_string("proxy_ssl_certificate_key"), |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
761 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
762 ngx_http_set_complex_value_zero_slot, |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
763 NGX_HTTP_LOC_CONF_OFFSET, |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
764 offsetof(ngx_http_proxy_loc_conf_t, upstream.ssl_certificate_key), |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
765 NULL }, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
766 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
767 { ngx_string("proxy_ssl_password_file"), |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
768 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
|
769 ngx_http_proxy_ssl_password_file, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
770 NGX_HTTP_LOC_CONF_OFFSET, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
771 0, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
772 NULL }, |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
773 |
7730
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
774 { ngx_string("proxy_ssl_conf_command"), |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
775 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
776 ngx_conf_set_keyval_slot, |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
777 NGX_HTTP_LOC_CONF_OFFSET, |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
778 offsetof(ngx_http_proxy_loc_conf_t, ssl_conf_commands), |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
779 &ngx_http_proxy_ssl_conf_command_post }, |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
780 |
2184 | 781 #endif |
782 | |
507 | 783 ngx_null_command |
784 }; | |
785 | |
786 | |
667 | 787 static ngx_http_module_t ngx_http_proxy_module_ctx = { |
509 | 788 ngx_http_proxy_add_variables, /* preconfiguration */ |
789 NULL, /* postconfiguration */ | |
507 | 790 |
5951
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
791 ngx_http_proxy_create_main_conf, /* create main configuration */ |
507 | 792 NULL, /* init main configuration */ |
793 | |
794 NULL, /* create server configuration */ | |
795 NULL, /* merge server configuration */ | |
796 | |
4499
778ef9c3fd2d
Fixed spelling in single-line comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4466
diff
changeset
|
797 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
|
798 ngx_http_proxy_merge_loc_conf /* merge location configuration */ |
507 | 799 }; |
800 | |
801 | |
802 ngx_module_t ngx_http_proxy_module = { | |
509 | 803 NGX_MODULE_V1, |
507 | 804 &ngx_http_proxy_module_ctx, /* module context */ |
805 ngx_http_proxy_commands, /* module directives */ | |
806 NGX_HTTP_MODULE, /* module type */ | |
541 | 807 NULL, /* init master */ |
509 | 808 NULL, /* init module */ |
541 | 809 NULL, /* init process */ |
810 NULL, /* init thread */ | |
811 NULL, /* exit thread */ | |
812 NULL, /* exit process */ | |
813 NULL, /* exit master */ | |
814 NGX_MODULE_V1_PADDING | |
507 | 815 }; |
816 | |
817 | |
818 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
|
819 static char ngx_http_proxy_version_11[] = " HTTP/1.1" CRLF; |
507 | 820 |
509 | 821 |
649 | 822 static ngx_keyval_t ngx_http_proxy_headers[] = { |
823 { ngx_string("Host"), ngx_string("$proxy_host") }, | |
824 { 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
|
825 { 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
|
826 { 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
|
827 { ngx_string("TE"), ngx_string("") }, |
649 | 828 { ngx_string("Keep-Alive"), ngx_string("") }, |
2067 | 829 { ngx_string("Expect"), ngx_string("") }, |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
830 { ngx_string("Upgrade"), ngx_string("") }, |
649 | 831 { ngx_null_string, ngx_null_string } |
832 }; | |
833 | |
834 | |
2706
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
835 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
|
836 ngx_string("Date"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
837 ngx_string("Server"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
838 ngx_string("X-Pad"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
839 ngx_string("X-Accel-Expires"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
840 ngx_string("X-Accel-Redirect"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
841 ngx_string("X-Accel-Limit-Rate"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
842 ngx_string("X-Accel-Buffering"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
843 ngx_string("X-Accel-Charset"), |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
844 ngx_null_string |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
845 }; |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
846 |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
847 |
2705
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
848 #if (NGX_HTTP_CACHE) |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
849 |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
850 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
|
851 { 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
|
852 { 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
|
853 { 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
|
854 { 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
|
855 { ngx_string("TE"), ngx_string("") }, |
2705
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
856 { ngx_string("Keep-Alive"), ngx_string("") }, |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
857 { ngx_string("Expect"), ngx_string("") }, |
4276
a0f18c78db3b
Fixed Upgrade header clearing with proxy_cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4275
diff
changeset
|
858 { ngx_string("Upgrade"), ngx_string("") }, |
5441
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
859 { ngx_string("If-Modified-Since"), |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
860 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
|
861 { 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
|
862 { 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
|
863 { ngx_string("If-Match"), ngx_string("") }, |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
864 { ngx_string("Range"), ngx_string("") }, |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
865 { ngx_string("If-Range"), ngx_string("") }, |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
866 { ngx_null_string, ngx_null_string } |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
867 }; |
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
868 |
2706
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
869 #endif |
f905a6ab0ca8
hide cacheable Set-Cookie and P3P response headers
Igor Sysoev <igor@sysoev.ru>
parents:
2705
diff
changeset
|
870 |
509 | 871 |
872 static ngx_http_variable_t ngx_http_proxy_vars[] = { | |
873 | |
637 | 874 { 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
|
875 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, |
509 | 876 |
637 | 877 { 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
|
878 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, |
509 | 879 |
637 | 880 { ngx_string("proxy_add_x_forwarded_for"), NULL, |
583 | 881 ngx_http_proxy_add_x_forwarded_for_variable, 0, NGX_HTTP_VAR_NOHASH, 0 }, |
509 | 882 |
883 #if 0 | |
637 | 884 { ngx_string("proxy_add_via"), NULL, NULL, 0, NGX_HTTP_VAR_NOHASH, 0 }, |
509 | 885 #endif |
886 | |
637 | 887 { ngx_string("proxy_internal_body_length"), NULL, |
5203
bfb99b75833b
Proxy: $proxy_internal_body_length fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5188
diff
changeset
|
888 ngx_http_proxy_internal_body_length_variable, 0, |
bfb99b75833b
Proxy: $proxy_internal_body_length fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5188
diff
changeset
|
889 NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, |
577 | 890 |
6051
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
891 { ngx_string("proxy_internal_chunked"), NULL, |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
892 ngx_http_proxy_internal_chunked_variable, 0, |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
893 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
|
894 |
7077
2a288909abc6
Variables: macros for null variables.
Ruslan Ermilov <ru@nginx.com>
parents:
7047
diff
changeset
|
895 ngx_http_null_variable |
509 | 896 }; |
507 | 897 |
898 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
899 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
|
900 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
|
901 }; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
902 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
903 |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
904 static ngx_conf_bitmask_t ngx_http_proxy_cookie_flags_masks[] = { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
905 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
906 { ngx_string("secure"), |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
907 NGX_HTTP_PROXY_COOKIE_SECURE|NGX_HTTP_PROXY_COOKIE_SECURE_ON }, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
908 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
909 { ngx_string("nosecure"), |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
910 NGX_HTTP_PROXY_COOKIE_SECURE|NGX_HTTP_PROXY_COOKIE_SECURE_OFF }, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
911 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
912 { ngx_string("httponly"), |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
913 NGX_HTTP_PROXY_COOKIE_HTTPONLY|NGX_HTTP_PROXY_COOKIE_HTTPONLY_ON }, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
914 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
915 { ngx_string("nohttponly"), |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
916 NGX_HTTP_PROXY_COOKIE_HTTPONLY|NGX_HTTP_PROXY_COOKIE_HTTPONLY_OFF }, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
917 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
918 { ngx_string("samesite=strict"), |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
919 NGX_HTTP_PROXY_COOKIE_SAMESITE|NGX_HTTP_PROXY_COOKIE_SAMESITE_STRICT }, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
920 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
921 { ngx_string("samesite=lax"), |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
922 NGX_HTTP_PROXY_COOKIE_SAMESITE|NGX_HTTP_PROXY_COOKIE_SAMESITE_LAX }, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
923 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
924 { ngx_string("samesite=none"), |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
925 NGX_HTTP_PROXY_COOKIE_SAMESITE|NGX_HTTP_PROXY_COOKIE_SAMESITE_NONE }, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
926 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
927 { ngx_string("nosamesite"), |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
928 NGX_HTTP_PROXY_COOKIE_SAMESITE|NGX_HTTP_PROXY_COOKIE_SAMESITE_OFF }, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
929 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
930 { ngx_null_string, 0 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
931 }; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
932 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
933 |
507 | 934 static ngx_int_t |
935 ngx_http_proxy_handler(ngx_http_request_t *r) | |
577 | 936 { |
5951
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
937 ngx_int_t rc; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
938 ngx_http_upstream_t *u; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
939 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
|
940 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
|
941 #if (NGX_HTTP_CACHE) |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
942 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
|
943 #endif |
577 | 944 |
3006
95972b9e790b
ngx_http_upstream_create() to cleanup the previous upstream after
Igor Sysoev <igor@sysoev.ru>
parents:
2989
diff
changeset
|
945 if (ngx_http_upstream_create(r) != NGX_OK) { |
507 | 946 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
947 } | |
577 | 948 |
1658 | 949 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_proxy_ctx_t)); |
950 if (ctx == NULL) { | |
6003
cf2f8d91cf09
Proxy: use an appropriate error on memory allocation failure.
Ruslan Ermilov <ru@nginx.com>
parents:
5951
diff
changeset
|
951 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
1658 | 952 } |
953 | |
954 ngx_http_set_ctx(r, ctx, ngx_http_proxy_module); | |
955 | |
956 plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module); | |
957 | |
3006
95972b9e790b
ngx_http_upstream_create() to cleanup the previous upstream after
Igor Sysoev <igor@sysoev.ru>
parents:
2989
diff
changeset
|
958 u = r->upstream; |
95972b9e790b
ngx_http_upstream_create() to cleanup the previous upstream after
Igor Sysoev <igor@sysoev.ru>
parents:
2989
diff
changeset
|
959 |
3733 | 960 if (plcf->proxy_lengths == NULL) { |
1658 | 961 ctx->vars = plcf->vars; |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2285
diff
changeset
|
962 u->schema = plcf->vars.schema; |
1658 | 963 #if (NGX_HTTP_SSL) |
8053
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
964 u->ssl = plcf->ssl; |
1658 | 965 #endif |
966 | |
967 } else { | |
968 if (ngx_http_proxy_eval(r, ctx, plcf) != NGX_OK) { | |
969 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
970 } | |
971 } | |
972 | |
507 | 973 u->output.tag = (ngx_buf_tag_t) &ngx_http_proxy_module; |
974 | |
975 u->conf = &plcf->upstream; | |
976 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
977 #if (NGX_HTTP_CACHE) |
5951
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
978 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
|
979 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
980 u->caches = &pmcf->caches; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
981 u->create_key = ngx_http_proxy_create_key; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
982 #endif |
5951
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
983 |
507 | 984 u->create_request = ngx_http_proxy_create_request; |
985 u->reinit_request = ngx_http_proxy_reinit_request; | |
509 | 986 u->process_header = ngx_http_proxy_process_status_line; |
507 | 987 u->abort_request = ngx_http_proxy_abort_request; |
988 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
|
989 r->state = 0; |
507 | 990 |
509 | 991 if (plcf->redirects) { |
992 u->rewrite_redirect = ngx_http_proxy_rewrite_redirect; | |
993 } | |
994 | |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
995 if (plcf->cookie_domains || plcf->cookie_paths || plcf->cookie_flags) { |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
996 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
|
997 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
998 |
649 | 999 u->buffering = plcf->upstream.buffering; |
1000 | |
1001 u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t)); | |
1002 if (u->pipe == NULL) { | |
1003 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
581 | 1004 } |
507 | 1005 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1006 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
|
1007 u->pipe->input_ctx = r; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1008 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1009 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
|
1010 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
|
1011 u->input_filter_ctx = r; |
649 | 1012 |
509 | 1013 u->accel = 1; |
577 | 1014 |
6050
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1015 if (!plcf->upstream.request_buffering |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1016 && 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
|
1017 && (!r->headers_in.chunked |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1018 || plcf->http_version == NGX_HTTP_VERSION_11)) |
6050
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1019 { |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1020 r->request_body_no_buffering = 1; |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1021 } |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1022 |
507 | 1023 rc = ngx_http_read_client_request_body(r, ngx_http_upstream_init); |
1024 | |
1025 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | |
1026 return rc; | |
1027 } | |
1028 | |
1029 return NGX_DONE; | |
1030 } | |
1031 | |
1032 | |
1033 static ngx_int_t | |
1658 | 1034 ngx_http_proxy_eval(ngx_http_request_t *r, ngx_http_proxy_ctx_t *ctx, |
1035 ngx_http_proxy_loc_conf_t *plcf) | |
1036 { | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1037 u_char *p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1038 size_t add; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1039 u_short port; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1040 ngx_str_t proxy; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1041 ngx_url_t url; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1042 ngx_http_upstream_t *u; |
1658 | 1043 |
1044 if (ngx_http_script_run(r, &proxy, plcf->proxy_lengths->elts, 0, | |
1045 plcf->proxy_values->elts) | |
1046 == NULL) | |
1047 { | |
1048 return NGX_ERROR; | |
1049 } | |
1050 | |
3977
2527cdb8d31f
test length of proxy_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
3976
diff
changeset
|
1051 if (proxy.len > 7 |
2527cdb8d31f
test length of proxy_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
3976
diff
changeset
|
1052 && 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
|
1053 { |
1658 | 1054 add = 7; |
1055 port = 80; | |
1056 | |
1057 #if (NGX_HTTP_SSL) | |
1058 | |
3977
2527cdb8d31f
test length of proxy_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
3976
diff
changeset
|
1059 } else if (proxy.len > 8 |
2527cdb8d31f
test length of proxy_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
3976
diff
changeset
|
1060 && 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
|
1061 { |
1658 | 1062 add = 8; |
1063 port = 443; | |
1064 r->upstream->ssl = 1; | |
1065 | |
1066 #endif | |
1067 | |
1068 } else { | |
1069 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1070 "invalid URL prefix in \"%V\"", &proxy); | |
1071 return NGX_ERROR; | |
1072 } | |
1073 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1074 u = r->upstream; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1075 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1076 u->schema.len = add; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1077 u->schema.data = proxy.data; |
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 ngx_memzero(&url, sizeof(ngx_url_t)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1080 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1081 url.url.len = proxy.len - add; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1082 url.url.data = proxy.data + add; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1083 url.default_port = port; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1084 url.uri_part = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1085 url.no_resolve = 1; |
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 if (ngx_parse_url(r->pool, &url) != NGX_OK) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1088 if (url.err) { |
1658 | 1089 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
|
1090 "%s in upstream \"%V\"", url.err, &url.url); |
1658 | 1091 } |
1092 | |
1093 return NGX_ERROR; | |
1094 } | |
1095 | |
3323
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
1096 if (url.uri.len) { |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
1097 if (url.uri.data[0] == '?') { |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
1098 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
|
1099 if (p == NULL) { |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
1100 return NGX_ERROR; |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
1101 } |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
1102 |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
1103 *p++ = '/'; |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
1104 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
|
1105 |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
1106 url.uri.len++; |
9421e997c2c4
allow "proxy_pass http://$backend" without URI part
Igor Sysoev <igor@sysoev.ru>
parents:
3271
diff
changeset
|
1107 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
|
1108 } |
c3035feb6638
fix case proxy_pass URL is evaluted to http://host?args
Igor Sysoev <igor@sysoev.ru>
parents:
2268
diff
changeset
|
1109 } |
c3035feb6638
fix case proxy_pass URL is evaluted to http://host?args
Igor Sysoev <igor@sysoev.ru>
parents:
2268
diff
changeset
|
1110 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1111 ctx->vars.key_start = u->schema; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1112 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1113 ngx_http_proxy_set_vars(&url, &ctx->vars); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1114 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1115 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
|
1116 if (u->resolved == NULL) { |
1658 | 1117 return NGX_ERROR; |
1118 } | |
1119 | |
6784
1af120241cde
Upstream: removed unnecessary condition in proxy_eval() and friends.
Ruslan Ermilov <ru@nginx.com>
parents:
6781
diff
changeset
|
1120 if (url.addrs) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1121 u->resolved->sockaddr = url.addrs[0].sockaddr; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1122 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
|
1123 u->resolved->name = url.addrs[0].name; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1124 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
|
1125 } |
1658 | 1126 |
6785
d1d0dd69a419
Upstream: added the ngx_http_upstream_resolved_t.name field.
Ruslan Ermilov <ru@nginx.com>
parents:
6784
diff
changeset
|
1127 u->resolved->host = url.host; |
6303
a93345ee8f52
Upstream: fixed "no port" detection in evaluated upstreams.
Ruslan Ermilov <ru@nginx.com>
parents:
6290
diff
changeset
|
1128 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
|
1129 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
|
1130 |
1658 | 1131 return NGX_OK; |
1132 } | |
1133 | |
1134 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1135 #if (NGX_HTTP_CACHE) |
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 static ngx_int_t |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1138 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
|
1139 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1140 size_t len, loc_len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1141 u_char *p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1142 uintptr_t escape; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1143 ngx_str_t *key; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1144 ngx_http_upstream_t *u; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1145 ngx_http_proxy_ctx_t *ctx; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1146 ngx_http_proxy_loc_conf_t *plcf; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1147 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1148 u = r->upstream; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1149 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1150 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
|
1151 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1152 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
|
1153 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1154 key = ngx_array_push(&r->cache->keys); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1155 if (key == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1156 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1157 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1158 |
4947
4251e72b8bb4
Allow the complex value to be defined as an empty string.
Ruslan Ermilov <ru@nginx.com>
parents:
4927
diff
changeset
|
1159 if (plcf->cache_key.value.data) { |
2672 | 1160 |
1161 if (ngx_http_complex_value(r, &plcf->cache_key, key) != NGX_OK) { | |
1162 return NGX_ERROR; | |
1163 } | |
1164 | |
1165 return NGX_OK; | |
1166 } | |
1167 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1168 *key = ctx->vars.key_start; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1169 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1170 key = ngx_array_push(&r->cache->keys); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1171 if (key == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1172 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1173 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1174 |
4377
726a1ca9b52b
Proxy: made proxy_pass with variables more consistent.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4336
diff
changeset
|
1175 if (plcf->proxy_lengths && ctx->vars.uri.len) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1176 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1177 *key = ctx->vars.uri; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1178 u->uri = ctx->vars.uri; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1179 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1180 return NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1181 |
7167
8530aea9aa50
Proxy: simplified conditions of using unparsed uri.
Roman Arutyunyan <arut@nginx.com>
parents:
7077
diff
changeset
|
1182 } else if (ctx->vars.uri.len == 0 && r->valid_unparsed_uri) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1183 *key = r->unparsed_uri; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1184 u->uri = r->unparsed_uri; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1185 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1186 return NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1187 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1188 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1189 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
|
1190 |
7881
52338ddf9e2f
Disabled spaces in URIs (ticket #196).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7833
diff
changeset
|
1191 if (r->quoted_uri || r->internal) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1192 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
|
1193 r->uri.len - loc_len, NGX_ESCAPE_URI); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1194 } else { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1195 escape = 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1196 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1197 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1198 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
|
1199 + sizeof("?") - 1 + r->args.len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1200 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1201 p = ngx_pnalloc(r->pool, len); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1202 if (p == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1203 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1204 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1205 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1206 key->data = p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1207 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1208 if (r->valid_location) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1209 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
|
1210 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1211 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1212 if (escape) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1213 ngx_escape_uri(p, r->uri.data + loc_len, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1214 r->uri.len - loc_len, NGX_ESCAPE_URI); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1215 p += r->uri.len - loc_len + escape; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1216 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1217 } else { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1218 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
|
1219 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1220 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1221 if (r->args.len > 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1222 *p++ = '?'; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1223 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
|
1224 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1225 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1226 key->len = p - key->data; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1227 u->uri = *key; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1228 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1229 return NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1230 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1231 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1232 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1233 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1234 |
1658 | 1235 static ngx_int_t |
507 | 1236 ngx_http_proxy_create_request(ngx_http_request_t *r) |
1237 { | |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1238 size_t len, uri_len, loc_len, body_len, |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1239 key_len, val_len; |
509 | 1240 uintptr_t escape; |
1241 ngx_buf_t *b; | |
649 | 1242 ngx_str_t method; |
1243 ngx_uint_t i, unparsed_uri; | |
509 | 1244 ngx_chain_t *cl, *body; |
1245 ngx_list_part_t *part; | |
1246 ngx_table_elt_t *header; | |
1247 ngx_http_upstream_t *u; | |
1658 | 1248 ngx_http_proxy_ctx_t *ctx; |
509 | 1249 ngx_http_script_code_pt code; |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1250 ngx_http_proxy_headers_t *headers; |
509 | 1251 ngx_http_script_engine_t e, le; |
1252 ngx_http_proxy_loc_conf_t *plcf; | |
1253 ngx_http_script_len_code_pt lcode; | |
507 | 1254 |
1255 u = r->upstream; | |
1256 | |
1257 plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module); | |
1258 | |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
1259 #if (NGX_HTTP_CACHE) |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
1260 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
|
1261 #else |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1262 headers = &plcf->headers; |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
1263 #endif |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1264 |
561 | 1265 if (u->method.len) { |
1266 /* HEAD was changed to GET to cache response */ | |
1267 method = u->method; | |
1268 | |
6781
ca27074f8f0f
Proxy: support variables for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
6747
diff
changeset
|
1269 } else if (plcf->method) { |
ca27074f8f0f
Proxy: support variables for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
6747
diff
changeset
|
1270 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
|
1271 return NGX_ERROR; |
ca27074f8f0f
Proxy: support variables for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
6747
diff
changeset
|
1272 } |
561 | 1273 |
507 | 1274 } else { |
561 | 1275 method = r->method_name; |
507 | 1276 } |
1277 | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1278 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
|
1279 |
6311
44122bddd9a1
Proxy: improved code readability.
Ruslan Ermilov <ru@nginx.com>
parents:
6303
diff
changeset
|
1280 if (method.len == 4 |
44122bddd9a1
Proxy: improved code readability.
Ruslan Ermilov <ru@nginx.com>
parents:
6303
diff
changeset
|
1281 && 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
|
1282 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1283 ctx->head = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1284 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1285 |
6311
44122bddd9a1
Proxy: improved code readability.
Ruslan Ermilov <ru@nginx.com>
parents:
6303
diff
changeset
|
1286 len = method.len + 1 + sizeof(ngx_http_proxy_version) - 1 |
44122bddd9a1
Proxy: improved code readability.
Ruslan Ermilov <ru@nginx.com>
parents:
6303
diff
changeset
|
1287 + sizeof(CRLF) - 1; |
1667 | 1288 |
507 | 1289 escape = 0; |
1658 | 1290 loc_len = 0; |
1291 unparsed_uri = 0; | |
1292 | |
4377
726a1ca9b52b
Proxy: made proxy_pass with variables more consistent.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4336
diff
changeset
|
1293 if (plcf->proxy_lengths && ctx->vars.uri.len) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1294 uri_len = ctx->vars.uri.len; |
1658 | 1295 |
7167
8530aea9aa50
Proxy: simplified conditions of using unparsed uri.
Roman Arutyunyan <arut@nginx.com>
parents:
7077
diff
changeset
|
1296 } else if (ctx->vars.uri.len == 0 && r->valid_unparsed_uri) { |
609 | 1297 unparsed_uri = 1; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1298 uri_len = r->unparsed_uri.len; |
507 | 1299 |
1300 } else { | |
1658 | 1301 loc_len = (r->valid_location && ctx->vars.uri.len) ? |
1302 plcf->location.len : 0; | |
1303 | |
7881
52338ddf9e2f
Disabled spaces in URIs (ticket #196).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7833
diff
changeset
|
1304 if (r->quoted_uri || r->internal) { |
509 | 1305 escape = 2 * ngx_escape_uri(NULL, r->uri.data + loc_len, |
1306 r->uri.len - loc_len, NGX_ESCAPE_URI); | |
507 | 1307 } |
1308 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1309 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
|
1310 + sizeof("?") - 1 + r->args.len; |
507 | 1311 } |
1312 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1313 if (uri_len == 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1314 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
|
1315 "zero length URI to proxy"); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1316 return NGX_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1317 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1318 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1319 len += uri_len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1320 |
5211
ecd762770729
Proxy: clear script engine used to calculate lengths.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5203
diff
changeset
|
1321 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
|
1322 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1323 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
|
1324 ngx_http_script_flush_no_cacheable_variables(r, headers->flushes); |
573 | 1325 |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
1326 if (plcf->body_lengths) { |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
1327 le.ip = plcf->body_lengths->elts; |
577 | 1328 le.request = r; |
1329 le.flushed = 1; | |
1330 body_len = 0; | |
1331 | |
1332 while (*(uintptr_t *) le.ip) { | |
1333 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
1334 body_len += lcode(&le); | |
1335 } | |
1336 | |
1658 | 1337 ctx->internal_body_length = body_len; |
577 | 1338 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
|
1339 |
6051
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1340 } 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
|
1341 ctx->internal_body_length = -1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1342 ctx->internal_chunked = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1343 |
4927
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
1344 } else { |
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
1345 ctx->internal_body_length = r->headers_in.content_length_n; |
577 | 1346 } |
1347 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1348 le.ip = headers->lengths->elts; |
509 | 1349 le.request = r; |
573 | 1350 le.flushed = 1; |
507 | 1351 |
509 | 1352 while (*(uintptr_t *) le.ip) { |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1353 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1354 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1355 key_len = lcode(&le); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1356 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1357 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
509 | 1358 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
1359 } | |
1360 le.ip += sizeof(uintptr_t); | |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1361 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1362 if (val_len == 0) { |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1363 continue; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1364 } |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1365 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1366 len += key_len + sizeof(": ") - 1 + val_len + sizeof(CRLF) - 1; |
507 | 1367 } |
1368 | |
1369 | |
509 | 1370 if (plcf->upstream.pass_request_headers) { |
1371 part = &r->headers_in.headers.part; | |
1372 header = part->elts; | |
1373 | |
1374 for (i = 0; /* void */; i++) { | |
507 | 1375 |
509 | 1376 if (i >= part->nelts) { |
1377 if (part->next == NULL) { | |
1378 break; | |
1379 } | |
1380 | |
1381 part = part->next; | |
1382 header = part->elts; | |
577 | 1383 i = 0; |
507 | 1384 } |
1385 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1386 if (ngx_hash_find(&headers->hash, header[i].hash, |
649 | 1387 header[i].lowcase_key, header[i].key.len)) |
509 | 1388 { |
1389 continue; | |
1390 } | |
1391 | |
1392 len += header[i].key.len + sizeof(": ") - 1 | |
1393 + header[i].value.len + sizeof(CRLF) - 1; | |
507 | 1394 } |
509 | 1395 } |
507 | 1396 |
1397 | |
1398 b = ngx_create_temp_buf(r->pool, len); | |
1399 if (b == NULL) { | |
1400 return NGX_ERROR; | |
1401 } | |
1402 | |
1403 cl = ngx_alloc_chain_link(r->pool); | |
1404 if (cl == NULL) { | |
1405 return NGX_ERROR; | |
1406 } | |
1407 | |
1408 cl->buf = b; | |
1409 | |
1410 | |
1411 /* the request line */ | |
1412 | |
573 | 1413 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
|
1414 *b->last++ = ' '; |
507 | 1415 |
555 | 1416 u->uri.data = b->last; |
1417 | |
4377
726a1ca9b52b
Proxy: made proxy_pass with variables more consistent.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4336
diff
changeset
|
1418 if (plcf->proxy_lengths && ctx->vars.uri.len) { |
1658 | 1419 b->last = ngx_copy(b->last, ctx->vars.uri.data, ctx->vars.uri.len); |
1420 | |
1421 } else if (unparsed_uri) { | |
573 | 1422 b->last = ngx_copy(b->last, r->unparsed_uri.data, r->unparsed_uri.len); |
1423 | |
507 | 1424 } else { |
555 | 1425 if (r->valid_location) { |
1658 | 1426 b->last = ngx_copy(b->last, ctx->vars.uri.data, ctx->vars.uri.len); |
555 | 1427 } |
551 | 1428 |
507 | 1429 if (escape) { |
509 | 1430 ngx_escape_uri(b->last, r->uri.data + loc_len, |
1431 r->uri.len - loc_len, NGX_ESCAPE_URI); | |
1432 b->last += r->uri.len - loc_len + escape; | |
507 | 1433 |
577 | 1434 } else { |
573 | 1435 b->last = ngx_copy(b->last, r->uri.data + loc_len, |
1436 r->uri.len - loc_len); | |
507 | 1437 } |
1438 | |
1439 if (r->args.len > 0) { | |
1440 *b->last++ = '?'; | |
573 | 1441 b->last = ngx_copy(b->last, r->args.data, r->args.len); |
507 | 1442 } |
1443 } | |
1444 | |
555 | 1445 u->uri.len = b->last - u->uri.data; |
1446 | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1447 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
|
1448 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
|
1449 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
|
1450 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1451 } else { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1452 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
|
1453 sizeof(ngx_http_proxy_version) - 1); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1454 } |
507 | 1455 |
577 | 1456 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); |
507 | 1457 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1458 e.ip = headers->values->elts; |
507 | 1459 e.pos = b->last; |
509 | 1460 e.request = r; |
573 | 1461 e.flushed = 1; |
507 | 1462 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1463 le.ip = headers->lengths->elts; |
509 | 1464 |
1465 while (*(uintptr_t *) le.ip) { | |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1466 |
509 | 1467 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
515 | 1468 (void) lcode(&le); |
509 | 1469 |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1470 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1471 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1472 } |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1473 le.ip += sizeof(uintptr_t); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1474 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1475 if (val_len == 0) { |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1476 e.skip = 1; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1477 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1478 while (*(uintptr_t *) e.ip) { |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1479 code = *(ngx_http_script_code_pt *) e.ip; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1480 code((ngx_http_script_engine_t *) &e); |
509 | 1481 } |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1482 e.ip += sizeof(uintptr_t); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1483 |
509 | 1484 e.skip = 0; |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1485 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1486 continue; |
509 | 1487 } |
1488 | |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1489 code = *(ngx_http_script_code_pt *) e.ip; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1490 code((ngx_http_script_engine_t *) &e); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1491 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1492 *e.pos++ = ':'; *e.pos++ = ' '; |
509 | 1493 |
1494 while (*(uintptr_t *) e.ip) { | |
1495 code = *(ngx_http_script_code_pt *) e.ip; | |
1496 code((ngx_http_script_engine_t *) &e); | |
577 | 1497 } |
509 | 1498 e.ip += sizeof(uintptr_t); |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1499 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1500 *e.pos++ = CR; *e.pos++ = LF; |
507 | 1501 } |
1502 | |
1503 b->last = e.pos; | |
1504 | |
1505 | |
509 | 1506 if (plcf->upstream.pass_request_headers) { |
1507 part = &r->headers_in.headers.part; | |
1508 header = part->elts; | |
577 | 1509 |
509 | 1510 for (i = 0; /* void */; i++) { |
507 | 1511 |
509 | 1512 if (i >= part->nelts) { |
1513 if (part->next == NULL) { | |
1514 break; | |
1515 } | |
1516 | |
1517 part = part->next; | |
1518 header = part->elts; | |
577 | 1519 i = 0; |
507 | 1520 } |
1521 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1522 if (ngx_hash_find(&headers->hash, header[i].hash, |
649 | 1523 header[i].lowcase_key, header[i].key.len)) |
509 | 1524 { |
1525 continue; | |
1526 } | |
507 | 1527 |
573 | 1528 b->last = ngx_copy(b->last, header[i].key.data, header[i].key.len); |
507 | 1529 |
509 | 1530 *b->last++ = ':'; *b->last++ = ' '; |
507 | 1531 |
573 | 1532 b->last = ngx_copy(b->last, header[i].value.data, |
1533 header[i].value.len); | |
507 | 1534 |
509 | 1535 *b->last++ = CR; *b->last++ = LF; |
507 | 1536 |
509 | 1537 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1538 "http proxy header: \"%V: %V\"", | |
1539 &header[i].key, &header[i].value); | |
1540 } | |
507 | 1541 } |
1542 | |
577 | 1543 |
507 | 1544 /* add "\r\n" at the header end */ |
1545 *b->last++ = CR; *b->last++ = LF; | |
1546 | |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
1547 if (plcf->body_values) { |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
1548 e.ip = plcf->body_values->elts; |
577 | 1549 e.pos = b->last; |
6043
613b14b305c7
Proxy: fixed proxy_set_body with proxy_cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6003
diff
changeset
|
1550 e.skip = 0; |
577 | 1551 |
1552 while (*(uintptr_t *) e.ip) { | |
1553 code = *(ngx_http_script_code_pt *) e.ip; | |
1554 code((ngx_http_script_engine_t *) &e); | |
1555 } | |
579 | 1556 |
1557 b->last = e.pos; | |
577 | 1558 } |
1559 | |
1774 | 1560 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
|
1561 "http proxy header:%N\"%*s\"", |
1774 | 1562 (size_t) (b->last - b->pos), b->pos); |
507 | 1563 |
6050
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1564 if (r->request_body_no_buffering) { |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1565 |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1566 u->request_bufs = cl; |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1567 |
6051
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1568 if (ctx->internal_chunked) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1569 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
|
1570 u->output.filter_ctx = r; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1571 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1572 |
6050
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1573 } else if (plcf->body_values == NULL && plcf->upstream.pass_request_body) { |
509 | 1574 |
1575 body = u->request_bufs; | |
1576 u->request_bufs = cl; | |
1577 | |
1578 while (body) { | |
1579 b = ngx_alloc_buf(r->pool); | |
1580 if (b == NULL) { | |
1581 return NGX_ERROR; | |
1582 } | |
1583 | |
1584 ngx_memcpy(b, body->buf, sizeof(ngx_buf_t)); | |
1585 | |
1586 cl->next = ngx_alloc_chain_link(r->pool); | |
1587 if (cl->next == NULL) { | |
1588 return NGX_ERROR; | |
1589 } | |
1590 | |
1591 cl = cl->next; | |
1592 cl->buf = b; | |
1593 | |
1594 body = body->next; | |
1595 } | |
1596 | |
1597 } else { | |
1598 u->request_bufs = cl; | |
1599 } | |
1600 | |
4009
3183165283cc
Fixing proxy_set_body and proxy_pass_request_body with SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3977
diff
changeset
|
1601 b->flush = 1; |
509 | 1602 cl->next = NULL; |
1603 | |
507 | 1604 return NGX_OK; |
1605 } | |
1606 | |
1607 | |
1608 static ngx_int_t | |
1609 ngx_http_proxy_reinit_request(ngx_http_request_t *r) | |
1610 { | |
1658 | 1611 ngx_http_proxy_ctx_t *ctx; |
1612 | |
1613 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
1614 | |
1615 if (ctx == NULL) { | |
509 | 1616 return NGX_OK; |
1617 } | |
1618 | |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1619 ctx->status.code = 0; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1620 ctx->status.count = 0; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1621 ctx->status.start = NULL; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1622 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
|
1623 ctx->chunked.state = 0; |
509 | 1624 |
1625 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
|
1626 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
|
1627 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
|
1628 r->state = 0; |
509 | 1629 |
1630 return NGX_OK; | |
1631 } | |
1632 | |
1633 | |
1634 static ngx_int_t | |
6051
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1635 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
|
1636 { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1637 ngx_http_request_t *r = data; |
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 off_t size; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1640 u_char *chunk; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1641 ngx_int_t rc; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1642 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
|
1643 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
|
1644 ngx_http_proxy_ctx_t *ctx; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1645 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1646 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
|
1647 "proxy output filter"); |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1648 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1649 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
|
1650 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1651 if (in == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1652 out = in; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1653 goto out; |
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 out = NULL; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1657 ll = &out; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1658 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1659 if (!ctx->header_sent) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1660 /* first buffer contains headers, pass it unmodified */ |
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 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
|
1663 "proxy output header"); |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1664 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1665 ctx->header_sent = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1666 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1667 tl = ngx_alloc_chain_link(r->pool); |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1668 if (tl == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1669 return NGX_ERROR; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1670 } |
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 tl->buf = in->buf; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1673 *ll = tl; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1674 ll = &tl->next; |
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 in = in->next; |
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 if (in == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1679 tl->next = NULL; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1680 goto out; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1681 } |
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 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1684 size = 0; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1685 cl = in; |
6056
24ccec3c4a87
Proxy: fixed proxy_request_buffering and chunked with preread body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6051
diff
changeset
|
1686 fl = ll; |
6051
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1687 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1688 for ( ;; ) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1689 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
6480 | 1690 "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
|
1691 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1692 size += ngx_buf_size(cl->buf); |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1693 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1694 if (cl->buf->flush |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1695 || cl->buf->sync |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1696 || ngx_buf_in_memory(cl->buf) |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1697 || cl->buf->in_file) |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1698 { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1699 tl = ngx_alloc_chain_link(r->pool); |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1700 if (tl == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1701 return NGX_ERROR; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1702 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1703 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1704 tl->buf = cl->buf; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1705 *ll = tl; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1706 ll = &tl->next; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1707 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1708 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1709 if (cl->next == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1710 break; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1711 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1712 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1713 cl = cl->next; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1714 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1715 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1716 if (size) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1717 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
|
1718 if (tl == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1719 return NGX_ERROR; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1720 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1721 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1722 b = tl->buf; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1723 chunk = b->start; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1724 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1725 if (chunk == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1726 /* the "0000000000000000" is 64-bit hexadecimal string */ |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1727 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1728 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
|
1729 if (chunk == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1730 return NGX_ERROR; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1731 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1732 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1733 b->start = chunk; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1734 b->end = chunk + sizeof("0000000000000000" CRLF) - 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1735 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1736 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1737 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
|
1738 b->memory = 0; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1739 b->temporary = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1740 b->pos = chunk; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1741 b->last = ngx_sprintf(chunk, "%xO" CRLF, size); |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1742 |
6056
24ccec3c4a87
Proxy: fixed proxy_request_buffering and chunked with preread body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6051
diff
changeset
|
1743 tl->next = *fl; |
24ccec3c4a87
Proxy: fixed proxy_request_buffering and chunked with preread body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6051
diff
changeset
|
1744 *fl = tl; |
6051
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1745 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1746 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1747 if (cl->buf->last_buf) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1748 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
|
1749 if (tl == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1750 return NGX_ERROR; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1751 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1752 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1753 b = tl->buf; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1754 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1755 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
|
1756 b->temporary = 0; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1757 b->memory = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1758 b->last_buf = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1759 b->pos = (u_char *) CRLF "0" CRLF CRLF; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1760 b->last = b->pos + 7; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1761 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1762 cl->buf->last_buf = 0; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1763 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1764 *ll = tl; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1765 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1766 if (size == 0) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1767 b->pos += 2; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1768 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1769 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1770 } else if (size > 0) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1771 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
|
1772 if (tl == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1773 return NGX_ERROR; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1774 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1775 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1776 b = tl->buf; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1777 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1778 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
|
1779 b->temporary = 0; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1780 b->memory = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1781 b->pos = (u_char *) CRLF; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1782 b->last = b->pos + 2; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1783 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1784 *ll = tl; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1785 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1786 } else { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1787 *ll = NULL; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1788 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1789 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1790 out: |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1791 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1792 rc = ngx_chain_writer(&r->upstream->writer, out); |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1793 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1794 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
|
1795 (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
|
1796 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1797 return rc; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1798 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1799 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1800 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1801 static ngx_int_t |
509 | 1802 ngx_http_proxy_process_status_line(ngx_http_request_t *r) |
1803 { | |
3628 | 1804 size_t len; |
509 | 1805 ngx_int_t rc; |
1806 ngx_http_upstream_t *u; | |
1658 | 1807 ngx_http_proxy_ctx_t *ctx; |
1808 | |
1809 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
1810 | |
1811 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
|
1812 return NGX_ERROR; |
509 | 1813 } |
1814 | |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1815 u = r->upstream; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1816 |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1817 rc = ngx_http_parse_status_line(r, &u->buffer, &ctx->status); |
509 | 1818 |
1819 if (rc == NGX_AGAIN) { | |
1820 return rc; | |
1821 } | |
1822 | |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1823 if (rc == NGX_ERROR) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1824 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1825 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1826 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1827 if (r->cache) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1828 r->http_version = NGX_HTTP_VERSION_9; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1829 return NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1830 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1831 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1832 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1833 |
509 | 1834 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
577 | 1835 "upstream sent no valid HTTP/1.0 header"); |
509 | 1836 |
619 | 1837 #if 0 |
509 | 1838 if (u->accel) { |
1839 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1840 } | |
619 | 1841 #endif |
509 | 1842 |
1843 r->http_version = NGX_HTTP_VERSION_9; | |
1616 | 1844 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
|
1845 u->headers_in.connection_close = 1; |
577 | 1846 |
509 | 1847 return NGX_OK; |
1848 } | |
1849 | |
5575
d15822784cf9
Upstream: fix $upstream_status variable.
Piotr Sikora <piotr@cloudflare.com>
parents:
5466
diff
changeset
|
1850 if (u->state && u->state->status == 0) { |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1851 u->state->status = ctx->status.code; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1852 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1853 |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1854 u->headers_in.status_n = ctx->status.code; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1855 |
3628 | 1856 len = ctx->status.end - ctx->status.start; |
1857 u->headers_in.status_line.len = len; | |
1858 | |
1859 u->headers_in.status_line.data = ngx_pnalloc(r->pool, len); | |
529 | 1860 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
|
1861 return NGX_ERROR; |
509 | 1862 } |
573 | 1863 |
3628 | 1864 ngx_memcpy(u->headers_in.status_line.data, ctx->status.start, len); |
509 | 1865 |
1866 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1867 "http proxy status %ui \"%V\"", | |
936 | 1868 u->headers_in.status_n, &u->headers_in.status_line); |
509 | 1869 |
4125
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4009
diff
changeset
|
1870 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
|
1871 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
|
1872 } |
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4009
diff
changeset
|
1873 |
509 | 1874 u->process_header = ngx_http_proxy_process_header; |
1875 | |
1876 return ngx_http_proxy_process_header(r); | |
1877 } | |
1878 | |
1879 | |
1880 static ngx_int_t | |
507 | 1881 ngx_http_proxy_process_header(ngx_http_request_t *r) |
1882 { | |
509 | 1883 ngx_int_t rc; |
1884 ngx_table_elt_t *h; | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1885 ngx_http_upstream_t *u; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1886 ngx_http_proxy_ctx_t *ctx; |
509 | 1887 ngx_http_upstream_header_t *hh; |
1888 ngx_http_upstream_main_conf_t *umcf; | |
1889 | |
1890 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); | |
1891 | |
2024 | 1892 for ( ;; ) { |
509 | 1893 |
2256 | 1894 rc = ngx_http_parse_header_line(r, &r->upstream->buffer, 1); |
509 | 1895 |
1896 if (rc == NGX_OK) { | |
1897 | |
1898 /* a header line has been parsed successfully */ | |
507 | 1899 |
509 | 1900 h = ngx_list_push(&r->upstream->headers_in.headers); |
1901 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
|
1902 return NGX_ERROR; |
509 | 1903 } |
1904 | |
1905 h->hash = r->header_hash; | |
1906 | |
1907 h->key.len = r->header_name_end - r->header_name_start; | |
1908 h->value.len = r->header_end - r->header_start; | |
1909 | |
2049 | 1910 h->key.data = ngx_pnalloc(r->pool, |
649 | 1911 h->key.len + 1 + h->value.len + 1 + h->key.len); |
509 | 1912 if (h->key.data == NULL) { |
7001
08537eab4f23
Upstream: fixed u->headers_in.headers allocation error handling.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6981
diff
changeset
|
1913 h->hash = 0; |
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
|
1914 return NGX_ERROR; |
509 | 1915 } |
1916 | |
1917 h->value.data = h->key.data + h->key.len + 1; | |
649 | 1918 h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1; |
507 | 1919 |
4529
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1920 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
|
1921 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
|
1922 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
|
1923 h->value.data[h->value.len] = '\0'; |
509 | 1924 |
649 | 1925 if (h->key.len == r->lowcase_index) { |
1926 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
1927 | |
1928 } else { | |
2135 | 1929 ngx_strlow(h->lowcase_key, h->key.data, h->key.len); |
509 | 1930 } |
1931 | |
649 | 1932 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash, |
1933 h->lowcase_key, h->key.len); | |
1934 | |
8033
2bf7792c262e
Upstream: header handlers can now return parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8032
diff
changeset
|
1935 if (hh) { |
2bf7792c262e
Upstream: header handlers can now return parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8032
diff
changeset
|
1936 rc = hh->handler(r, h, hh->offset); |
2bf7792c262e
Upstream: header handlers can now return parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8032
diff
changeset
|
1937 |
2bf7792c262e
Upstream: header handlers can now return parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8032
diff
changeset
|
1938 if (rc != NGX_OK) { |
2bf7792c262e
Upstream: header handlers can now return parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8032
diff
changeset
|
1939 return rc; |
2bf7792c262e
Upstream: header handlers can now return parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8032
diff
changeset
|
1940 } |
649 | 1941 } |
1942 | |
509 | 1943 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1944 "http proxy header: \"%V: %V\"", | |
1945 &h->key, &h->value); | |
1946 | |
1947 continue; | |
1948 } | |
1949 | |
1950 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { | |
1951 | |
1952 /* a whole header has been parsed successfully */ | |
1953 | |
1954 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1955 "http proxy header done"); | |
1956 | |
649 | 1957 /* |
1958 * if no "Server" and "Date" in header line, | |
1959 * then add the special empty headers | |
1960 */ | |
1961 | |
1962 if (r->upstream->headers_in.server == NULL) { | |
1963 h = ngx_list_push(&r->upstream->headers_in.headers); | |
1964 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
|
1965 return NGX_ERROR; |
649 | 1966 } |
1967 | |
1968 h->hash = ngx_hash(ngx_hash(ngx_hash(ngx_hash( | |
1969 ngx_hash('s', 'e'), 'r'), 'v'), 'e'), 'r'); | |
1970 | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
1971 ngx_str_set(&h->key, "Server"); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
1972 ngx_str_null(&h->value); |
649 | 1973 h->lowcase_key = (u_char *) "server"; |
8032
2025aae94739
Upstream: all known headers in u->headers_in are linked lists now.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8024
diff
changeset
|
1974 h->next = NULL; |
649 | 1975 } |
1976 | |
1977 if (r->upstream->headers_in.date == NULL) { | |
1978 h = ngx_list_push(&r->upstream->headers_in.headers); | |
1979 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
|
1980 return NGX_ERROR; |
649 | 1981 } |
1982 | |
1983 h->hash = ngx_hash(ngx_hash(ngx_hash('d', 'a'), 't'), 'e'); | |
1984 | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
1985 ngx_str_set(&h->key, "Date"); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
1986 ngx_str_null(&h->value); |
649 | 1987 h->lowcase_key = (u_char *) "date"; |
8032
2025aae94739
Upstream: all known headers in u->headers_in are linked lists now.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8024
diff
changeset
|
1988 h->next = NULL; |
649 | 1989 } |
1990 | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1991 /* 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
|
1992 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1993 u = r->upstream; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1994 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1995 if (u->headers_in.chunked) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1996 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
|
1997 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1998 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1999 /* |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2000 * 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
|
2001 * 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
|
2002 */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2003 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2004 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
|
2005 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2006 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
|
2007 || 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
|
2008 || ctx->head |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2009 || (!u->headers_in.chunked |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2010 && 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
|
2011 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2012 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
|
2013 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2014 |
5072
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
2015 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
|
2016 u->keepalive = 0; |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
2017 |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
2018 if (r->headers_in.upgrade) { |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
2019 u->upgrade = 1; |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
2020 } |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
2021 } |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
2022 |
509 | 2023 return NGX_OK; |
2024 } | |
2025 | |
521 | 2026 if (rc == NGX_AGAIN) { |
2027 return NGX_AGAIN; | |
2028 } | |
2029 | |
7884
b87b7092cedb
Improved logging of invalid headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
2030 /* rc == NGX_HTTP_PARSE_INVALID_HEADER */ |
b87b7092cedb
Improved logging of invalid headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
2031 |
7933
2f443cac3f1e
Upstream: fixed logging level of upstream invalid header errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7931
diff
changeset
|
2032 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
7884
b87b7092cedb
Improved logging of invalid headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
2033 "upstream sent invalid header: \"%*s\\x%02xd...\"", |
b87b7092cedb
Improved logging of invalid headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
2034 r->header_end - r->header_name_start, |
b87b7092cedb
Improved logging of invalid headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
2035 r->header_name_start, *r->header_end); |
509 | 2036 |
2037 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
2038 } | |
507 | 2039 } |
2040 | |
2041 | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2042 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2043 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
|
2044 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2045 ngx_http_request_t *r = data; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2046 ngx_http_upstream_t *u; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2047 ngx_http_proxy_ctx_t *ctx; |
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 u = r->upstream; |
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 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
6480 | 2057 "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
|
2058 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
|
2059 u->headers_in.content_length_n); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2060 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2061 /* 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
|
2062 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2063 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
|
2064 || 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
|
2065 || ctx->head) |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2066 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2067 /* 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
|
2068 /* 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
|
2069 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2070 u->pipe->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2071 u->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2072 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
|
2073 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2074 } else if (u->headers_in.chunked) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2075 /* chunked */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2076 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2077 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
|
2078 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
|
2079 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2080 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
|
2081 u->length = 1; |
4126
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 } 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
|
2084 /* 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
|
2085 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2086 u->pipe->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2087 u->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2088 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
|
2089 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2090 } else { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2091 /* content length or connection close */ |
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 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
|
2094 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
|
2095 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2096 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2097 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2098 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2099 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2100 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2101 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2102 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
|
2103 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2104 ngx_buf_t *b; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2105 ngx_chain_t *cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2106 ngx_http_request_t *r; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2107 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2108 if (buf->pos == buf->last) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2109 return NGX_OK; |
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 |
7675
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2112 if (p->upstream_done) { |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2113 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2114 "http proxy data after close"); |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2115 return NGX_OK; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2116 } |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2117 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2118 if (p->length == 0) { |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2119 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2120 ngx_log_error(NGX_LOG_WARN, p->log, 0, |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2121 "upstream sent more data than specified in " |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2122 "\"Content-Length\" header"); |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2123 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2124 r = p->input_ctx; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2125 r->upstream->keepalive = 0; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2126 p->upstream_done = 1; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2127 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2128 return NGX_OK; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2129 } |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2130 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2131 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
|
2132 if (cl == NULL) { |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2133 return NGX_ERROR; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2134 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2135 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2136 b = cl->buf; |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2137 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2138 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
|
2139 b->shadow = buf; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2140 b->tag = p->tag; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2141 b->last_shadow = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2142 b->recycled = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2143 buf->shadow = b; |
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 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
|
2146 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2147 if (p->in) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2148 *p->last_in = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2149 } else { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2150 p->in = cl; |
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 p->last_in = &cl->next; |
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 if (p->length == -1) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2155 return NGX_OK; |
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 |
7675
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2158 if (b->last - b->pos > p->length) { |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2159 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2160 ngx_log_error(NGX_LOG_WARN, p->log, 0, |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2161 "upstream sent more data than specified in " |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2162 "\"Content-Length\" header"); |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2163 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2164 b->last = b->pos + p->length; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2165 p->upstream_done = 1; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2166 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2167 return NGX_OK; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2168 } |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2169 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2170 p->length -= b->last - b->pos; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2171 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2172 if (p->length == 0) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2173 r = p->input_ctx; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2174 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
|
2175 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2176 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2177 return NGX_OK; |
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 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2181 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2182 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
|
2183 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2184 ngx_int_t rc; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2185 ngx_buf_t *b, **prev; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2186 ngx_chain_t *cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2187 ngx_http_request_t *r; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2188 ngx_http_proxy_ctx_t *ctx; |
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 if (buf->pos == buf->last) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2191 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2192 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2193 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2194 r = p->input_ctx; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2195 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
|
2196 |
4602
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2197 if (ctx == NULL) { |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2198 return NGX_ERROR; |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2199 } |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2200 |
7676
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2201 if (p->upstream_done) { |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2202 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, p->log, 0, |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2203 "http proxy data after close"); |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2204 return NGX_OK; |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2205 } |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2206 |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2207 if (p->length == 0) { |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2208 |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2209 ngx_log_error(NGX_LOG_WARN, p->log, 0, |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2210 "upstream sent data after final chunk"); |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2211 |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2212 r->upstream->keepalive = 0; |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2213 p->upstream_done = 1; |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2214 |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2215 return NGX_OK; |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2216 } |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2217 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2218 b = NULL; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2219 prev = &buf->shadow; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2220 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2221 for ( ;; ) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2222 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2223 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
|
2224 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2225 if (rc == NGX_OK) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2226 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2227 /* a chunk has been parsed successfully */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2228 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2229 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
|
2230 if (cl == NULL) { |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2231 return NGX_ERROR; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2232 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2233 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2234 b = cl->buf; |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2235 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2236 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
|
2237 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2238 b->pos = buf->pos; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2239 b->start = buf->start; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2240 b->end = buf->end; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2241 b->tag = p->tag; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2242 b->temporary = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2243 b->recycled = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2244 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2245 *prev = b; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2246 prev = &b->shadow; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2247 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2248 if (p->in) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2249 *p->last_in = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2250 } else { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2251 p->in = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2252 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2253 p->last_in = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2254 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2255 /* STUB */ b->num = buf->num; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2256 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2257 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
|
2258 "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
|
2259 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2260 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
|
2261 |
5359
2fda9065d0f4
Win32: Borland C compatibility fixes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5301
diff
changeset
|
2262 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
|
2263 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
|
2264 ctx->chunked.size = 0; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2265 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2266 continue; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2267 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2268 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2269 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
|
2270 buf->pos = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2271 b->last = buf->last; |
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 continue; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2274 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2275 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2276 if (rc == NGX_DONE) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2277 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2278 /* 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
|
2279 |
7676
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2280 p->length = 0; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2281 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
|
2282 |
7676
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2283 if (buf->pos != buf->last) { |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2284 ngx_log_error(NGX_LOG_WARN, p->log, 0, |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2285 "upstream sent data after final chunk"); |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2286 r->upstream->keepalive = 0; |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2287 } |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2288 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2289 break; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2290 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2291 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2292 if (rc == NGX_AGAIN) { |
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 /* 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
|
2295 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2296 p->length = ctx->chunked.length; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2297 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2298 break; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2299 } |
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 /* invalid response */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2302 |
7677 | 2303 ngx_log_error(NGX_LOG_ERR, p->log, 0, |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2304 "upstream sent invalid chunked response"); |
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 return NGX_ERROR; |
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 |
7677 | 2309 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, p->log, 0, |
6480 | 2310 "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
|
2311 ctx->chunked.state, p->length); |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2312 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2313 if (b) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2314 b->shadow = buf; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2315 b->last_shadow = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2316 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2317 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
|
2318 "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
|
2319 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2320 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2321 } |
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 /* 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
|
2324 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2325 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
|
2326 return NGX_ERROR; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2327 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2328 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2329 return NGX_OK; |
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 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2333 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2334 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
|
2335 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2336 ngx_http_request_t *r = data; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2337 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2338 ngx_buf_t *b; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2339 ngx_chain_t *cl, **ll; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2340 ngx_http_upstream_t *u; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2341 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2342 u = r->upstream; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2343 |
7760
83c4622053b0
Upstream: fixed zero size buf alerts on extra data (ticket #2117).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7730
diff
changeset
|
2344 if (u->length == 0) { |
83c4622053b0
Upstream: fixed zero size buf alerts on extra data (ticket #2117).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7730
diff
changeset
|
2345 ngx_log_error(NGX_LOG_WARN, r->connection->log, 0, |
83c4622053b0
Upstream: fixed zero size buf alerts on extra data (ticket #2117).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7730
diff
changeset
|
2346 "upstream sent more data than specified in " |
83c4622053b0
Upstream: fixed zero size buf alerts on extra data (ticket #2117).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7730
diff
changeset
|
2347 "\"Content-Length\" header"); |
7931
055b2a847117
Proxy: disabled keepalive on extra data in non-buffered mode.
Awdhesh Mathpal <mathpal@amazon.com>
parents:
7904
diff
changeset
|
2348 u->keepalive = 0; |
7760
83c4622053b0
Upstream: fixed zero size buf alerts on extra data (ticket #2117).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7730
diff
changeset
|
2349 return NGX_OK; |
83c4622053b0
Upstream: fixed zero size buf alerts on extra data (ticket #2117).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7730
diff
changeset
|
2350 } |
83c4622053b0
Upstream: fixed zero size buf alerts on extra data (ticket #2117).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7730
diff
changeset
|
2351 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2352 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
|
2353 ll = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2354 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2355 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2356 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
|
2357 if (cl == NULL) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2358 return NGX_ERROR; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2359 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2360 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2361 *ll = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2362 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2363 cl->buf->flush = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2364 cl->buf->memory = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2365 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2366 b = &u->buffer; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2367 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2368 cl->buf->pos = b->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2369 b->last += bytes; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2370 cl->buf->last = b->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2371 cl->buf->tag = u->output.tag; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2372 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2373 if (u->length == -1) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2374 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2375 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2376 |
7675
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2377 if (bytes > u->length) { |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2378 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2379 ngx_log_error(NGX_LOG_WARN, r->connection->log, 0, |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2380 "upstream sent more data than specified in " |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2381 "\"Content-Length\" header"); |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2382 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2383 cl->buf->last = cl->buf->pos + u->length; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2384 u->length = 0; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2385 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2386 return NGX_OK; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2387 } |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2388 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2389 u->length -= bytes; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2390 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2391 if (u->length == 0) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2392 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
|
2393 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2394 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2395 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2396 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2397 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2398 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2399 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2400 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
|
2401 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2402 ngx_http_request_t *r = data; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2403 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2404 ngx_int_t rc; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2405 ngx_buf_t *b, *buf; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2406 ngx_chain_t *cl, **ll; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2407 ngx_http_upstream_t *u; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2408 ngx_http_proxy_ctx_t *ctx; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2409 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2410 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
|
2411 |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2412 if (ctx == NULL) { |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2413 return NGX_ERROR; |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2414 } |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2415 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2416 u = r->upstream; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2417 buf = &u->buffer; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2418 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2419 buf->pos = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2420 buf->last += bytes; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2421 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2422 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
|
2423 ll = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2424 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2425 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2426 for ( ;; ) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2427 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2428 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
|
2429 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2430 if (rc == NGX_OK) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2431 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2432 /* a chunk has been parsed successfully */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2433 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2434 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
|
2435 if (cl == NULL) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2436 return NGX_ERROR; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2437 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2438 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2439 *ll = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2440 ll = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2441 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2442 b = cl->buf; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2443 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2444 b->flush = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2445 b->memory = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2446 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2447 b->pos = buf->pos; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2448 b->tag = u->output.tag; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2449 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2450 if (buf->last - buf->pos >= ctx->chunked.size) { |
5359
2fda9065d0f4
Win32: Borland C compatibility fixes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5301
diff
changeset
|
2451 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
|
2452 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
|
2453 ctx->chunked.size = 0; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2454 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2455 } else { |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2456 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
|
2457 buf->pos = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2458 b->last = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2459 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2460 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2461 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
|
2462 "http proxy out buf %p %z", |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2463 b->pos, b->last - b->pos); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2464 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2465 continue; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2466 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2467 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2468 if (rc == NGX_DONE) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2469 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2470 /* 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
|
2471 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2472 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
|
2473 u->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2474 |
7676
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2475 if (buf->pos != buf->last) { |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2476 ngx_log_error(NGX_LOG_WARN, r->connection->log, 0, |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2477 "upstream sent data after final chunk"); |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2478 u->keepalive = 0; |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2479 } |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2480 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2481 break; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2482 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2483 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2484 if (rc == NGX_AGAIN) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2485 break; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2486 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2487 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2488 /* invalid response */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2489 |
4145
f321e9750c8c
Proxy: logging levels tuned, double logging fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4144
diff
changeset
|
2490 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
|
2491 "upstream sent invalid chunked response"); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2492 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2493 return NGX_ERROR; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2494 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2495 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2496 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2497 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2498 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2499 |
507 | 2500 static void |
2501 ngx_http_proxy_abort_request(ngx_http_request_t *r) | |
2502 { | |
2503 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2504 "abort http proxy request"); | |
577 | 2505 |
507 | 2506 return; |
2507 } | |
2508 | |
2509 | |
2510 static void | |
2511 ngx_http_proxy_finalize_request(ngx_http_request_t *r, ngx_int_t rc) | |
577 | 2512 { |
507 | 2513 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2514 "finalize http proxy request"); | |
2515 | |
2516 return; | |
2517 } | |
2518 | |
2519 | |
573 | 2520 static ngx_int_t |
2521 ngx_http_proxy_host_variable(ngx_http_request_t *r, | |
2522 ngx_http_variable_value_t *v, uintptr_t data) | |
507 | 2523 { |
1658 | 2524 ngx_http_proxy_ctx_t *ctx; |
2525 | |
2526 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
2527 | |
2528 if (ctx == NULL) { | |
2529 v->not_found = 1; | |
2530 return NGX_OK; | |
2531 } | |
2532 | |
2533 v->len = ctx->vars.host_header.len; | |
577 | 2534 v->valid = 1; |
1565 | 2535 v->no_cacheable = 0; |
573 | 2536 v->not_found = 0; |
1658 | 2537 v->data = ctx->vars.host_header.data; |
507 | 2538 |
573 | 2539 return NGX_OK; |
507 | 2540 } |
2541 | |
2542 | |
573 | 2543 static ngx_int_t |
2544 ngx_http_proxy_port_variable(ngx_http_request_t *r, | |
2545 ngx_http_variable_value_t *v, uintptr_t data) | |
507 | 2546 { |
1658 | 2547 ngx_http_proxy_ctx_t *ctx; |
2548 | |
2549 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
2550 | |
2551 if (ctx == NULL) { | |
2552 v->not_found = 1; | |
2553 return NGX_OK; | |
2554 } | |
2555 | |
2556 v->len = ctx->vars.port.len; | |
577 | 2557 v->valid = 1; |
1565 | 2558 v->no_cacheable = 0; |
573 | 2559 v->not_found = 0; |
1658 | 2560 v->data = ctx->vars.port.data; |
509 | 2561 |
573 | 2562 return NGX_OK; |
509 | 2563 } |
2564 | |
2565 | |
573 | 2566 static ngx_int_t |
509 | 2567 ngx_http_proxy_add_x_forwarded_for_variable(ngx_http_request_t *r, |
573 | 2568 ngx_http_variable_value_t *v, uintptr_t data) |
509 | 2569 { |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2570 size_t len; |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2571 u_char *p; |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2572 ngx_table_elt_t *h, *xfwd; |
509 | 2573 |
577 | 2574 v->valid = 1; |
1565 | 2575 v->no_cacheable = 0; |
573 | 2576 v->not_found = 0; |
509 | 2577 |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2578 xfwd = r->headers_in.x_forwarded_for; |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2579 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2580 len = 0; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2581 |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2582 for (h = xfwd; h; h = h->next) { |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2583 len += h->value.len + sizeof(", ") - 1; |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2584 } |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2585 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2586 if (len == 0) { |
573 | 2587 v->len = r->connection->addr_text.len; |
2588 v->data = r->connection->addr_text.data; | |
2589 return NGX_OK; | |
509 | 2590 } |
2591 | |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2592 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
|
2593 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2594 p = ngx_pnalloc(r->pool, len); |
509 | 2595 if (p == NULL) { |
573 | 2596 return NGX_ERROR; |
509 | 2597 } |
2598 | |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2599 v->len = len; |
573 | 2600 v->data = p; |
509 | 2601 |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2602 for (h = xfwd; h; h = h->next) { |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2603 p = ngx_copy(p, h->value.data, h->value.len); |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2604 *p++ = ','; *p++ = ' '; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2605 } |
509 | 2606 |
2607 ngx_memcpy(p, r->connection->addr_text.data, r->connection->addr_text.len); | |
2608 | |
573 | 2609 return NGX_OK; |
509 | 2610 } |
2611 | |
2612 | |
2613 static ngx_int_t | |
577 | 2614 ngx_http_proxy_internal_body_length_variable(ngx_http_request_t *r, |
2615 ngx_http_variable_value_t *v, uintptr_t data) | |
2616 { | |
1658 | 2617 ngx_http_proxy_ctx_t *ctx; |
2618 | |
2619 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
2620 | |
4927
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
2621 if (ctx == NULL || ctx->internal_body_length < 0) { |
577 | 2622 v->not_found = 1; |
2623 return NGX_OK; | |
2624 } | |
2625 | |
2626 v->valid = 1; | |
1565 | 2627 v->no_cacheable = 0; |
577 | 2628 v->not_found = 0; |
2629 | |
5188
886800caf360
Proxy: allocate $proxy_internal_body_length from request pool.
Ruslan Ermilov <ru@nginx.com>
parents:
5084
diff
changeset
|
2630 v->data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN); |
577 | 2631 |
2632 if (v->data == NULL) { | |
2633 return NGX_ERROR; | |
2634 } | |
2635 | |
4927
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
2636 v->len = ngx_sprintf(v->data, "%O", ctx->internal_body_length) - v->data; |
577 | 2637 |
2638 return NGX_OK; | |
2639 } | |
2640 | |
2641 | |
2642 static ngx_int_t | |
6051
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2643 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
|
2644 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
|
2645 { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2646 ngx_http_proxy_ctx_t *ctx; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2647 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2648 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
|
2649 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2650 if (ctx == NULL || !ctx->internal_chunked) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2651 v->not_found = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2652 return NGX_OK; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2653 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2654 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2655 v->valid = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2656 v->no_cacheable = 0; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2657 v->not_found = 0; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2658 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2659 v->data = (u_char *) "chunked"; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2660 v->len = sizeof("chunked") - 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2661 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2662 return NGX_OK; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2663 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2664 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2665 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2666 static ngx_int_t |
509 | 2667 ngx_http_proxy_rewrite_redirect(ngx_http_request_t *r, ngx_table_elt_t *h, |
2668 size_t prefix) | |
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 size_t len; |
509 | 2671 ngx_int_t rc; |
2672 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
|
2673 ngx_http_proxy_rewrite_t *pr; |
509 | 2674 ngx_http_proxy_loc_conf_t *plcf; |
2675 | |
2676 plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module); | |
2677 | |
2678 pr = plcf->redirects->elts; | |
2679 | |
2680 if (pr == NULL) { | |
2681 return NGX_DECLINED; | |
2682 } | |
2683 | |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2684 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
|
2685 |
509 | 2686 for (i = 0; i < plcf->redirects->nelts; i++) { |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
2687 rc = pr[i].handler(r, &h->value, prefix, len, &pr[i]); |
509 | 2688 |
2689 if (rc != NGX_DECLINED) { | |
2690 return rc; | |
2691 } | |
2692 } | |
2693 | |
2694 return NGX_DECLINED; | |
2695 } | |
2696 | |
2697 | |
2698 static ngx_int_t | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2699 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
|
2700 { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2701 u_char *p; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2702 size_t len; |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2703 ngx_int_t rc, rv; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2704 ngx_str_t *key, *value; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2705 ngx_uint_t i; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2706 ngx_array_t attrs; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2707 ngx_keyval_t *attr; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2708 ngx_http_proxy_loc_conf_t *plcf; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2709 |
7720
a88384c69d1e
Proxy: error checking for array init, missed in 7716:d6a5e14aa3e4.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7716
diff
changeset
|
2710 if (ngx_array_init(&attrs, r->pool, 2, sizeof(ngx_keyval_t)) != NGX_OK) { |
a88384c69d1e
Proxy: error checking for array init, missed in 7716:d6a5e14aa3e4.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7716
diff
changeset
|
2711 return NGX_ERROR; |
a88384c69d1e
Proxy: error checking for array init, missed in 7716:d6a5e14aa3e4.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7716
diff
changeset
|
2712 } |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2713 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2714 if (ngx_http_proxy_parse_cookie(&h->value, &attrs) != NGX_OK) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2715 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2716 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2717 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2718 attr = attrs.elts; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2719 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2720 if (attr[0].value.data == NULL) { |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2721 return NGX_DECLINED; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2722 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2723 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2724 rv = NGX_DECLINED; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2725 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2726 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
|
2727 |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2728 for (i = 1; i < attrs.nelts; i++) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2729 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2730 key = &attr[i].key; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2731 value = &attr[i].value; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2732 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2733 if (plcf->cookie_domains && key->len == 6 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2734 && ngx_strncasecmp(key->data, (u_char *) "domain", 6) == 0 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2735 && value->data) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2736 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2737 rc = ngx_http_proxy_rewrite_cookie_value(r, value, |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2738 plcf->cookie_domains); |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2739 if (rc == NGX_ERROR) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2740 return NGX_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2741 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2742 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2743 if (rc != NGX_DECLINED) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2744 rv = rc; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2745 } |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2746 } |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2747 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2748 if (plcf->cookie_paths && key->len == 4 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2749 && ngx_strncasecmp(key->data, (u_char *) "path", 4) == 0 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2750 && value->data) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2751 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2752 rc = ngx_http_proxy_rewrite_cookie_value(r, value, |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2753 plcf->cookie_paths); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2754 if (rc == NGX_ERROR) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2755 return NGX_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2756 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2757 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2758 if (rc != NGX_DECLINED) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2759 rv = rc; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2760 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2761 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2762 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2763 |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2764 if (plcf->cookie_flags) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2765 rc = ngx_http_proxy_rewrite_cookie_flags(r, &attrs, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2766 plcf->cookie_flags); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2767 if (rc == NGX_ERROR) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2768 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2769 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2770 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2771 if (rc != NGX_DECLINED) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2772 rv = rc; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2773 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2774 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2775 attr = attrs.elts; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2776 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2777 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2778 if (rv != NGX_OK) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2779 return rv; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2780 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2781 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2782 len = 0; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2783 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2784 for (i = 0; i < attrs.nelts; i++) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2785 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2786 if (attr[i].key.data == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2787 continue; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2788 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2789 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2790 if (i > 0) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2791 len += 2; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2792 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2793 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2794 len += attr[i].key.len; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2795 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2796 if (attr[i].value.data) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2797 len += 1 + attr[i].value.len; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2798 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2799 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2800 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2801 p = ngx_pnalloc(r->pool, len + 1); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2802 if (p == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2803 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2804 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2805 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2806 h->value.data = p; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2807 h->value.len = len; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2808 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2809 for (i = 0; i < attrs.nelts; i++) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2810 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2811 if (attr[i].key.data == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2812 continue; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2813 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2814 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2815 if (i > 0) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2816 *p++ = ';'; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2817 *p++ = ' '; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2818 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2819 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2820 p = ngx_cpymem(p, attr[i].key.data, attr[i].key.len); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2821 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2822 if (attr[i].value.data) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2823 *p++ = '='; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2824 p = ngx_cpymem(p, attr[i].value.data, attr[i].value.len); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2825 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2826 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2827 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2828 *p = '\0'; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2829 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2830 return NGX_OK; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2831 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2832 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2833 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2834 static ngx_int_t |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2835 ngx_http_proxy_parse_cookie(ngx_str_t *value, ngx_array_t *attrs) |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2836 { |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2837 u_char *start, *end, *p, *last; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2838 ngx_str_t name, val; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2839 ngx_keyval_t *attr; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2840 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2841 start = value->data; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2842 end = value->data + value->len; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2843 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2844 for ( ;; ) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2845 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2846 last = (u_char *) ngx_strchr(start, ';'); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2847 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2848 if (last == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2849 last = end; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2850 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2851 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2852 while (start < last && *start == ' ') { start++; } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2853 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2854 for (p = start; p < last && *p != '='; p++) { /* void */ } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2855 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2856 name.data = start; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2857 name.len = p - start; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2858 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2859 while (name.len && name.data[name.len - 1] == ' ') { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2860 name.len--; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2861 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2862 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2863 if (p < last) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2864 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2865 p++; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2866 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2867 while (p < last && *p == ' ') { p++; } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2868 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2869 val.data = p; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2870 val.len = last - val.data; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2871 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2872 while (val.len && val.data[val.len - 1] == ' ') { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2873 val.len--; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2874 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2875 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2876 } else { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2877 ngx_str_null(&val); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2878 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2879 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2880 attr = ngx_array_push(attrs); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2881 if (attr == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2882 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2883 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2884 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2885 attr->key = name; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2886 attr->value = val; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2887 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2888 if (last == end) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2889 break; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2890 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2891 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2892 start = last + 1; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2893 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2894 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2895 return NGX_OK; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2896 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2897 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2898 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2899 static ngx_int_t |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2900 ngx_http_proxy_rewrite_cookie_value(ngx_http_request_t *r, ngx_str_t *value, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2901 ngx_array_t *rewrites) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2902 { |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2903 ngx_int_t rc; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2904 ngx_uint_t i; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2905 ngx_http_proxy_rewrite_t *pr; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2906 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2907 pr = rewrites->elts; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2908 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2909 for (i = 0; i < rewrites->nelts; i++) { |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2910 rc = pr[i].handler(r, value, 0, value->len, &pr[i]); |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2911 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2912 if (rc != NGX_DECLINED) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2913 return rc; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2914 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2915 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2916 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2917 return NGX_DECLINED; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2918 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2919 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2920 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2921 static ngx_int_t |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2922 ngx_http_proxy_rewrite_cookie_flags(ngx_http_request_t *r, ngx_array_t *attrs, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2923 ngx_array_t *flags) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2924 { |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2925 ngx_str_t pattern, value; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2926 #if (NGX_PCRE) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2927 ngx_int_t rc; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2928 #endif |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2929 ngx_uint_t i, m, f, nelts; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2930 ngx_keyval_t *attr; |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2931 ngx_conf_bitmask_t *mask; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2932 ngx_http_complex_value_t *flags_values; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2933 ngx_http_proxy_cookie_flags_t *pcf; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2934 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2935 attr = attrs->elts; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2936 pcf = flags->elts; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2937 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2938 for (i = 0; i < flags->nelts; i++) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2939 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2940 #if (NGX_PCRE) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2941 if (pcf[i].regex) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2942 rc = ngx_http_regex_exec(r, pcf[i].cookie.regex, &attr[0].key); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2943 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2944 if (rc == NGX_ERROR) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2945 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2946 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2947 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2948 if (rc == NGX_OK) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2949 break; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2950 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2951 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2952 /* NGX_DECLINED */ |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2953 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2954 continue; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2955 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2956 #endif |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2957 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2958 if (ngx_http_complex_value(r, &pcf[i].cookie.complex, &pattern) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2959 != NGX_OK) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2960 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2961 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2962 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2963 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2964 if (pattern.len == attr[0].key.len |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2965 && ngx_strncasecmp(attr[0].key.data, pattern.data, pattern.len) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2966 == 0) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2967 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2968 break; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2969 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2970 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2971 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2972 if (i == flags->nelts) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2973 return NGX_DECLINED; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2974 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2975 |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2976 nelts = pcf[i].flags_values.nelts; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2977 flags_values = pcf[i].flags_values.elts; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2978 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2979 mask = ngx_http_proxy_cookie_flags_masks; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2980 f = 0; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2981 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2982 for (i = 0; i < nelts; i++) { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2983 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2984 if (ngx_http_complex_value(r, &flags_values[i], &value) != NGX_OK) { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2985 return NGX_ERROR; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2986 } |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2987 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2988 if (value.len == 0) { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2989 continue; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2990 } |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2991 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2992 for (m = 0; mask[m].name.len != 0; m++) { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2993 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2994 if (mask[m].name.len != value.len |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2995 || ngx_strncasecmp(mask[m].name.data, value.data, value.len) |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2996 != 0) |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2997 { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2998 continue; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2999 } |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3000 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3001 f |= mask[m].mask; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3002 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3003 break; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3004 } |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3005 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3006 if (mask[m].name.len == 0) { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3007 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3008 "invalid proxy_cookie_flags flag \"%V\"", &value); |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3009 } |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3010 } |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3011 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3012 if (f == 0) { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3013 return NGX_DECLINED; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3014 } |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3015 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3016 return ngx_http_proxy_edit_cookie_flags(r, attrs, f); |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3017 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3018 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3019 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3020 static ngx_int_t |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3021 ngx_http_proxy_edit_cookie_flags(ngx_http_request_t *r, ngx_array_t *attrs, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3022 ngx_uint_t flags) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3023 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3024 ngx_str_t *key, *value; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3025 ngx_uint_t i; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3026 ngx_keyval_t *attr; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3027 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3028 attr = attrs->elts; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3029 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3030 for (i = 1; i < attrs->nelts; i++) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3031 key = &attr[i].key; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3032 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3033 if (key->len == 6 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3034 && ngx_strncasecmp(key->data, (u_char *) "secure", 6) == 0) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3035 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3036 if (flags & NGX_HTTP_PROXY_COOKIE_SECURE_ON) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3037 flags &= ~NGX_HTTP_PROXY_COOKIE_SECURE_ON; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3038 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3039 } else if (flags & NGX_HTTP_PROXY_COOKIE_SECURE_OFF) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3040 key->data = NULL; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3041 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3042 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3043 continue; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3044 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3045 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3046 if (key->len == 8 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3047 && ngx_strncasecmp(key->data, (u_char *) "httponly", 8) == 0) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3048 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3049 if (flags & NGX_HTTP_PROXY_COOKIE_HTTPONLY_ON) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3050 flags &= ~NGX_HTTP_PROXY_COOKIE_HTTPONLY_ON; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3051 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3052 } else if (flags & NGX_HTTP_PROXY_COOKIE_HTTPONLY_OFF) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3053 key->data = NULL; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3054 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3055 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3056 continue; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3057 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3058 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3059 if (key->len == 8 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3060 && ngx_strncasecmp(key->data, (u_char *) "samesite", 8) == 0) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3061 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3062 value = &attr[i].value; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3063 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3064 if (flags & NGX_HTTP_PROXY_COOKIE_SAMESITE_STRICT) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3065 flags &= ~NGX_HTTP_PROXY_COOKIE_SAMESITE_STRICT; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3066 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3067 if (value->len != 6 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3068 || ngx_strncasecmp(value->data, (u_char *) "strict", 6) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3069 != 0) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3070 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3071 ngx_str_set(key, "SameSite"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3072 ngx_str_set(value, "Strict"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3073 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3074 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3075 } else if (flags & NGX_HTTP_PROXY_COOKIE_SAMESITE_LAX) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3076 flags &= ~NGX_HTTP_PROXY_COOKIE_SAMESITE_LAX; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3077 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3078 if (value->len != 3 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3079 || ngx_strncasecmp(value->data, (u_char *) "lax", 3) != 0) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3080 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3081 ngx_str_set(key, "SameSite"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3082 ngx_str_set(value, "Lax"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3083 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3084 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3085 } else if (flags & NGX_HTTP_PROXY_COOKIE_SAMESITE_NONE) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3086 flags &= ~NGX_HTTP_PROXY_COOKIE_SAMESITE_NONE; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3087 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3088 if (value->len != 4 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3089 || ngx_strncasecmp(value->data, (u_char *) "none", 4) != 0) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3090 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3091 ngx_str_set(key, "SameSite"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3092 ngx_str_set(value, "None"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3093 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3094 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3095 } else if (flags & NGX_HTTP_PROXY_COOKIE_SAMESITE_OFF) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3096 key->data = NULL; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3097 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3098 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3099 continue; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3100 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3101 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3102 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3103 if (flags & NGX_HTTP_PROXY_COOKIE_SECURE_ON) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3104 attr = ngx_array_push(attrs); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3105 if (attr == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3106 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3107 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3108 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3109 ngx_str_set(&attr->key, "Secure"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3110 ngx_str_null(&attr->value); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3111 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3112 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3113 if (flags & NGX_HTTP_PROXY_COOKIE_HTTPONLY_ON) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3114 attr = ngx_array_push(attrs); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3115 if (attr == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3116 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3117 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3118 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3119 ngx_str_set(&attr->key, "HttpOnly"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3120 ngx_str_null(&attr->value); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3121 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3122 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3123 if (flags & (NGX_HTTP_PROXY_COOKIE_SAMESITE_STRICT |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3124 |NGX_HTTP_PROXY_COOKIE_SAMESITE_LAX |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3125 |NGX_HTTP_PROXY_COOKIE_SAMESITE_NONE)) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3126 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3127 attr = ngx_array_push(attrs); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3128 if (attr == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3129 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3130 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3131 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3132 ngx_str_set(&attr->key, "SameSite"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3133 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3134 if (flags & NGX_HTTP_PROXY_COOKIE_SAMESITE_STRICT) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3135 ngx_str_set(&attr->value, "Strict"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3136 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3137 } else if (flags & NGX_HTTP_PROXY_COOKIE_SAMESITE_LAX) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3138 ngx_str_set(&attr->value, "Lax"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3139 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3140 } else { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3141 ngx_str_set(&attr->value, "None"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3142 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3143 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3144 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3145 return NGX_OK; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3146 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3147 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3148 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3149 static ngx_int_t |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3150 ngx_http_proxy_rewrite_complex_handler(ngx_http_request_t *r, ngx_str_t *value, |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3151 size_t prefix, size_t len, ngx_http_proxy_rewrite_t *pr) |
509 | 3152 { |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3153 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
|
3154 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3155 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
|
3156 return NGX_ERROR; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3157 } |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3158 |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3159 if (pattern.len > len |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3160 || ngx_rstrncmp(value->data + prefix, pattern.data, pattern.len) != 0) |
509 | 3161 { |
3162 return NGX_DECLINED; | |
3163 } | |
3164 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3165 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
|
3166 return NGX_ERROR; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3167 } |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3168 |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3169 return ngx_http_proxy_rewrite(r, value, prefix, pattern.len, &replacement); |
509 | 3170 } |
3171 | |
3172 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3173 #if (NGX_PCRE) |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3174 |
509 | 3175 static ngx_int_t |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3176 ngx_http_proxy_rewrite_regex_handler(ngx_http_request_t *r, ngx_str_t *value, |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3177 size_t prefix, size_t len, ngx_http_proxy_rewrite_t *pr) |
509 | 3178 { |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3179 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
|
3180 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3181 pattern.len = len; |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3182 pattern.data = value->data + prefix; |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3183 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3184 if (ngx_http_regex_exec(r, pr->pattern.regex, &pattern) != NGX_OK) { |
509 | 3185 return NGX_DECLINED; |
3186 } | |
3187 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3188 if (ngx_http_complex_value(r, &pr->replacement, &replacement) != NGX_OK) { |
509 | 3189 return NGX_ERROR; |
3190 } | |
3191 | |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3192 return ngx_http_proxy_rewrite(r, value, prefix, len, &replacement); |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3193 } |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3194 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3195 #endif |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3196 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3197 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3198 static ngx_int_t |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3199 ngx_http_proxy_rewrite_domain_handler(ngx_http_request_t *r, ngx_str_t *value, |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3200 size_t prefix, size_t len, ngx_http_proxy_rewrite_t *pr) |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3201 { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3202 u_char *p; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3203 ngx_str_t pattern, replacement; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3204 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3205 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
|
3206 return NGX_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3207 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3208 |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3209 p = value->data + prefix; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3210 |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3211 if (len && p[0] == '.') { |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3212 p++; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3213 prefix++; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3214 len--; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3215 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3216 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3217 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
|
3218 return NGX_DECLINED; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3219 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3220 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3221 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
|
3222 return NGX_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3223 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3224 |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3225 return ngx_http_proxy_rewrite(r, value, prefix, len, &replacement); |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3226 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3227 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3228 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3229 static ngx_int_t |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3230 ngx_http_proxy_rewrite(ngx_http_request_t *r, ngx_str_t *value, size_t prefix, |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3231 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
|
3232 { |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3233 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
|
3234 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
|
3235 |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3236 if (len == value->len) { |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3237 *value = *replacement; |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3238 return NGX_OK; |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3239 } |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3240 |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3241 new_len = replacement->len + value->len - len; |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3242 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3243 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
|
3244 |
5676
fbfdf8017748
Proxy: fixed possible uninitialized memory access.
Valentin Bartenev <vbart@nginx.com>
parents:
5661
diff
changeset
|
3245 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
|
3246 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
|
3247 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
|
3248 } |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3249 |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3250 p = ngx_copy(data, value->data, prefix); |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3251 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
|
3252 |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3253 ngx_memcpy(p, value->data + prefix + len, |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3254 value->len - len - prefix + 1); |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3255 |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3256 value->data = data; |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3257 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3258 } else { |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3259 p = ngx_copy(value->data + prefix, replacement->data, replacement->len); |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3260 |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3261 ngx_memmove(p, value->data + prefix + len, |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3262 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
|
3263 } |
3d51ba7f347b
Fixed: proxy_redirect with regex might broke Refresh header.
Valentin Bartenev <vbart@nginx.com>
parents:
4385
diff
changeset
|
3264 |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3265 value->len = new_len; |
509 | 3266 |
3267 return NGX_OK; | |
3268 } | |
3269 | |
3270 | |
3271 static ngx_int_t | |
3272 ngx_http_proxy_add_variables(ngx_conf_t *cf) | |
3273 { | |
3274 ngx_http_variable_t *var, *v; | |
3275 | |
3276 for (v = ngx_http_proxy_vars; v->name.len; v++) { | |
3277 var = ngx_http_add_variable(cf, &v->name, v->flags); | |
3278 if (var == NULL) { | |
3279 return NGX_ERROR; | |
3280 } | |
3281 | |
637 | 3282 var->get_handler = v->get_handler; |
509 | 3283 var->data = v->data; |
3284 } | |
3285 | |
3286 return NGX_OK; | |
507 | 3287 } |
3288 | |
3289 | |
3290 static void * | |
5951
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3291 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
|
3292 { |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3293 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
|
3294 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3295 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
|
3296 if (conf == NULL) { |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3297 return NULL; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3298 } |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3299 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3300 #if (NGX_HTTP_CACHE) |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3301 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
|
3302 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
|
3303 != NGX_OK) |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3304 { |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3305 return NULL; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3306 } |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3307 #endif |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3308 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3309 return conf; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3310 } |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3311 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3312 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3313 static void * |
507 | 3314 ngx_http_proxy_create_loc_conf(ngx_conf_t *cf) |
3315 { | |
3316 ngx_http_proxy_loc_conf_t *conf; | |
3317 | |
3318 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_proxy_loc_conf_t)); | |
3319 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
|
3320 return NULL; |
507 | 3321 } |
3322 | |
3323 /* | |
3324 * set by ngx_pcalloc(): | |
3325 * | |
3326 * conf->upstream.bufs.num = 0; | |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
3327 * conf->upstream.ignore_headers = 0; |
507 | 3328 * conf->upstream.next_upstream = 0; |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3329 * conf->upstream.cache_zone = NULL; |
2875
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
3330 * conf->upstream.cache_use_stale = 0; |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
3331 * conf->upstream.cache_methods = 0; |
507 | 3332 * conf->upstream.temp_path = NULL; |
649 | 3333 * conf->upstream.hide_headers_hash = { NULL, 0 }; |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3334 * conf->upstream.store_lengths = NULL; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3335 * conf->upstream.store_values = NULL; |
509 | 3336 * |
7238
06cf0c4b8618
Upstream: fixed comments after 13f8dec720b5.
Ruslan Ermilov <ru@nginx.com>
parents:
7220
diff
changeset
|
3337 * conf->location = NULL; |
06cf0c4b8618
Upstream: fixed comments after 13f8dec720b5.
Ruslan Ermilov <ru@nginx.com>
parents:
7220
diff
changeset
|
3338 * conf->url = { 0, NULL }; |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3339 * conf->headers.lengths = NULL; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3340 * conf->headers.values = NULL; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3341 * 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
|
3342 * conf->headers_cache.lengths = NULL; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3343 * conf->headers_cache.values = NULL; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3344 * 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
|
3345 * conf->body_lengths = NULL; |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3346 * conf->body_values = NULL; |
577 | 3347 * conf->body_source = { 0, NULL }; |
3470
b982f2dee8cf
fix proxy_redirect name in error message
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
3348 * conf->redirects = NULL; |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3349 * conf->ssl = 0; |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3350 * conf->ssl_protocols = 0; |
5390
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
3351 * conf->ssl_ciphers = { 0, NULL }; |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3352 * conf->ssl_trusted_certificate = { 0, NULL }; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3353 * conf->ssl_crl = { 0, NULL }; |
507 | 3354 */ |
577 | 3355 |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3356 conf->upstream.store = NGX_CONF_UNSET; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3357 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
|
3358 conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT; |
581 | 3359 conf->upstream.buffering = NGX_CONF_UNSET; |
6050
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
3360 conf->upstream.request_buffering = NGX_CONF_UNSET; |
629 | 3361 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
|
3362 conf->upstream.force_ranges = NGX_CONF_UNSET; |
581 | 3363 |
5008
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4962
diff
changeset
|
3364 conf->upstream.local = NGX_CONF_UNSET_PTR; |
7371
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
3365 conf->upstream.socket_keepalive = NGX_CONF_UNSET; |
5008
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4962
diff
changeset
|
3366 |
507 | 3367 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC; |
3368 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC; | |
3369 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
|
3370 conf->upstream.next_upstream_timeout = NGX_CONF_UNSET_MSEC; |
507 | 3371 |
3372 conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; | |
581 | 3373 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
|
3374 conf->upstream.limit_rate = NGX_CONF_UNSET_SIZE; |
529 | 3375 |
3376 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; | |
577 | 3377 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; |
529 | 3378 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; |
509 | 3379 |
3380 conf->upstream.pass_request_headers = NGX_CONF_UNSET; | |
3381 conf->upstream.pass_request_body = NGX_CONF_UNSET; | |
561 | 3382 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3383 #if (NGX_HTTP_CACHE) |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3384 conf->upstream.cache = NGX_CONF_UNSET; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3385 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
|
3386 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
|
3387 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
|
3388 conf->upstream.no_cache = NGX_CONF_UNSET_PTR; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3389 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; |
4385
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3390 conf->upstream.cache_lock = NGX_CONF_UNSET; |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3391 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
|
3392 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
|
3393 conf->upstream.cache_revalidate = NGX_CONF_UNSET; |
6290
4d5ac1a31d44
Upstream: proxy_cache_convert_head directive.
Roman Arutyunyan <arut@nginx.com>
parents:
6157
diff
changeset
|
3394 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
|
3395 conf->upstream.cache_background_update = NGX_CONF_UNSET; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3396 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3397 |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
3398 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
|
3399 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
|
3400 |
657 | 3401 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
|
3402 |
2184 | 3403 #if (NGX_HTTP_SSL) |
3404 conf->upstream.ssl_session_reuse = NGX_CONF_UNSET; | |
7831
bdd4d89370a7
Changed complex value slots to use NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7787
diff
changeset
|
3405 conf->upstream.ssl_name = NGX_CONF_UNSET_PTR; |
5660
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
3406 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
|
3407 conf->upstream.ssl_verify = NGX_CONF_UNSET; |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3408 conf->upstream.ssl_certificate = NGX_CONF_UNSET_PTR; |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3409 conf->upstream.ssl_certificate_key = NGX_CONF_UNSET_PTR; |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3410 conf->upstream.ssl_passwords = NGX_CONF_UNSET_PTR; |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3411 conf->ssl_verify_depth = NGX_CONF_UNSET_UINT; |
7730
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
3412 conf->ssl_conf_commands = NGX_CONF_UNSET_PTR; |
2184 | 3413 #endif |
507 | 3414 |
3415 /* "proxy_cyclic_temp_file" is disabled */ | |
3416 conf->upstream.cyclic_temp_file = 0; | |
3417 | |
7831
bdd4d89370a7
Changed complex value slots to use NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7787
diff
changeset
|
3418 conf->upstream.change_buffering = 1; |
bdd4d89370a7
Changed complex value slots to use NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7787
diff
changeset
|
3419 |
7728
485dba3e2a01
Core: ngx_conf_set_keyval_slot() now accepts NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7720
diff
changeset
|
3420 conf->headers_source = NGX_CONF_UNSET_PTR; |
485dba3e2a01
Core: ngx_conf_set_keyval_slot() now accepts NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7720
diff
changeset
|
3421 |
7831
bdd4d89370a7
Changed complex value slots to use NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7787
diff
changeset
|
3422 conf->method = NGX_CONF_UNSET_PTR; |
bdd4d89370a7
Changed complex value slots to use NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7787
diff
changeset
|
3423 |
509 | 3424 conf->redirect = NGX_CONF_UNSET; |
507 | 3425 |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3426 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
|
3427 conf->cookie_paths = NGX_CONF_UNSET_PTR; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3428 conf->cookie_flags = NGX_CONF_UNSET_PTR; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3429 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
3430 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
|
3431 |
1180
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
3432 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
|
3433 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
|
3434 |
3976
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3862
diff
changeset
|
3435 ngx_str_set(&conf->upstream.module, "proxy"); |
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3862
diff
changeset
|
3436 |
507 | 3437 return conf; |
3438 } | |
3439 | |
3440 | |
3441 static char * | |
3442 ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
3443 { | |
3444 ngx_http_proxy_loc_conf_t *prev = parent; | |
3445 ngx_http_proxy_loc_conf_t *conf = child; | |
3446 | |
3862
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3447 u_char *p; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3448 size_t size; |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3449 ngx_int_t rc; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3450 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
|
3451 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
|
3452 ngx_http_proxy_rewrite_t *pr; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3453 ngx_http_script_compile_t sc; |
509 | 3454 |
5948
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3455 #if (NGX_HTTP_CACHE) |
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3456 |
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3457 if (conf->upstream.store > 0) { |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3458 conf->upstream.cache = 0; |
5948
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3459 } |
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3460 |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3461 if (conf->upstream.cache > 0) { |
5948
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3462 conf->upstream.store = 0; |
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3463 } |
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3464 |
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3465 #endif |
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3466 |
5940
e3b3b89d74e8
Upstream: fixed inheritance of proxy_store and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5939
diff
changeset
|
3467 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
|
3468 ngx_conf_merge_value(conf->upstream.store, |
2894 | 3469 prev->upstream.store, 0); |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3470 |
5947
d9025ea1f5a5
Upstream: simplified proxy_store and friends configuration code.
Valentin Bartenev <vbart@nginx.com>
parents:
5940
diff
changeset
|
3471 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
|
3472 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
|
3473 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3474 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3475 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
|
3476 prev->upstream.store_access, 0600); |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1244
diff
changeset
|
3477 |
5832
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
3478 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
|
3479 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
|
3480 |
581 | 3481 ngx_conf_merge_value(conf->upstream.buffering, |
3482 prev->upstream.buffering, 1); | |
3483 | |
6050
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
3484 ngx_conf_merge_value(conf->upstream.request_buffering, |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
3485 prev->upstream.request_buffering, 1); |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
3486 |
629 | 3487 ngx_conf_merge_value(conf->upstream.ignore_client_abort, |
3488 prev->upstream.ignore_client_abort, 0); | |
3489 | |
5874
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
3490 ngx_conf_merge_value(conf->upstream.force_ranges, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
3491 prev->upstream.force_ranges, 0); |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
3492 |
5008
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4962
diff
changeset
|
3493 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
|
3494 prev->upstream.local, NULL); |
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4962
diff
changeset
|
3495 |
7371
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
3496 ngx_conf_merge_value(conf->upstream.socket_keepalive, |
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
3497 prev->upstream.socket_keepalive, 0); |
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
3498 |
507 | 3499 ngx_conf_merge_msec_value(conf->upstream.connect_timeout, |
3500 prev->upstream.connect_timeout, 60000); | |
3501 | |
3502 ngx_conf_merge_msec_value(conf->upstream.send_timeout, | |
3503 prev->upstream.send_timeout, 60000); | |
3504 | |
3505 ngx_conf_merge_msec_value(conf->upstream.read_timeout, | |
3506 prev->upstream.read_timeout, 60000); | |
3507 | |
5832
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
3508 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
|
3509 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
|
3510 |
507 | 3511 ngx_conf_merge_size_value(conf->upstream.send_lowat, |
3512 prev->upstream.send_lowat, 0); | |
3513 | |
581 | 3514 ngx_conf_merge_size_value(conf->upstream.buffer_size, |
3515 prev->upstream.buffer_size, | |
507 | 3516 (size_t) ngx_pagesize); |
3517 | |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
3518 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
|
3519 prev->upstream.limit_rate, 0); |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
3520 |
507 | 3521 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs, |
3522 8, ngx_pagesize); | |
3523 | |
3524 if (conf->upstream.bufs.num < 2) { | |
577 | 3525 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
507 | 3526 "there must be at least 2 \"proxy_buffers\""); |
3527 return NGX_CONF_ERROR; | |
3528 } | |
577 | 3529 |
507 | 3530 |
581 | 3531 size = conf->upstream.buffer_size; |
577 | 3532 if (size < conf->upstream.bufs.size) { |
507 | 3533 size = conf->upstream.bufs.size; |
3534 } | |
3535 | |
3536 | |
529 | 3537 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf, |
3538 prev->upstream.busy_buffers_size_conf, | |
507 | 3539 NGX_CONF_UNSET_SIZE); |
3540 | |
529 | 3541 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) { |
507 | 3542 conf->upstream.busy_buffers_size = 2 * size; |
529 | 3543 } else { |
3544 conf->upstream.busy_buffers_size = | |
3545 conf->upstream.busy_buffers_size_conf; | |
3546 } | |
577 | 3547 |
529 | 3548 if (conf->upstream.busy_buffers_size < size) { |
507 | 3549 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
|
3550 "\"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
|
3551 "the maximum of the value of \"proxy_buffer_size\" and " |
507 | 3552 "one of the \"proxy_buffers\""); |
3553 | |
3554 return NGX_CONF_ERROR; | |
529 | 3555 } |
507 | 3556 |
529 | 3557 if (conf->upstream.busy_buffers_size |
3558 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) | |
507 | 3559 { |
3560 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
3561 "\"proxy_busy_buffers_size\" must be less than " | |
3562 "the size of all \"proxy_buffers\" minus one buffer"); | |
3563 | |
3564 return NGX_CONF_ERROR; | |
3565 } | |
529 | 3566 |
507 | 3567 |
529 | 3568 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf, |
3569 prev->upstream.temp_file_write_size_conf, | |
507 | 3570 NGX_CONF_UNSET_SIZE); |
3571 | |
529 | 3572 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) { |
507 | 3573 conf->upstream.temp_file_write_size = 2 * size; |
529 | 3574 } else { |
3575 conf->upstream.temp_file_write_size = | |
3576 conf->upstream.temp_file_write_size_conf; | |
3577 } | |
577 | 3578 |
529 | 3579 if (conf->upstream.temp_file_write_size < size) { |
507 | 3580 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
|
3581 "\"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
|
3582 "than the maximum of the value of \"proxy_buffer_size\" and " |
507 | 3583 "one of the \"proxy_buffers\""); |
3584 | |
3585 return NGX_CONF_ERROR; | |
3586 } | |
3587 | |
529 | 3588 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf, |
3589 prev->upstream.max_temp_file_size_conf, | |
507 | 3590 NGX_CONF_UNSET_SIZE); |
3591 | |
529 | 3592 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) { |
507 | 3593 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; |
529 | 3594 } else { |
3595 conf->upstream.max_temp_file_size = | |
3596 conf->upstream.max_temp_file_size_conf; | |
3597 } | |
507 | 3598 |
529 | 3599 if (conf->upstream.max_temp_file_size != 0 |
3600 && conf->upstream.max_temp_file_size < size) | |
507 | 3601 { |
3602 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
561 | 3603 "\"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
|
3604 "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
|
3605 "the maximum of the value of \"proxy_buffer_size\" and " |
561 | 3606 "one of the \"proxy_buffers\""); |
507 | 3607 |
3608 return NGX_CONF_ERROR; | |
3609 } | |
3610 | |
529 | 3611 |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
3612 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
|
3613 prev->upstream.ignore_headers, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
3614 NGX_CONF_BITMASK_SET); |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
3615 |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
3616 |
507 | 3617 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream, |
3618 prev->upstream.next_upstream, | |
3619 (NGX_CONF_BITMASK_SET | |
3620 |NGX_HTTP_UPSTREAM_FT_ERROR | |
3621 |NGX_HTTP_UPSTREAM_FT_TIMEOUT)); | |
3622 | |
665 | 3623 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { |
3624 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET | |
3625 |NGX_HTTP_UPSTREAM_FT_OFF; | |
3626 } | |
3627 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3628 if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path, |
509 | 3629 prev->upstream.temp_path, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3630 &ngx_http_proxy_temp_path) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3631 != NGX_OK) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3632 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3633 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3634 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3635 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3636 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3637 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3638 |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3639 if (conf->upstream.cache == NGX_CONF_UNSET) { |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3640 ngx_conf_merge_value(conf->upstream.cache, |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3641 prev->upstream.cache, 0); |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3642 |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3643 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
|
3644 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
|
3645 } |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3646 |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3647 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
|
3648 ngx_shm_zone_t *shm_zone; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3649 |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3650 shm_zone = conf->upstream.cache_zone; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3651 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3652 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3653 "\"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
|
3654 &shm_zone->shm.name); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3655 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3656 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3657 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3658 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3659 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
|
3660 prev->upstream.cache_min_uses, 1); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3661 |
6793
0fba3ed4e7eb
Cache: proxy_cache_max_range_offset and friends.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6785
diff
changeset
|
3662 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
|
3663 prev->upstream.cache_max_range_offset, |
0fba3ed4e7eb
Cache: proxy_cache_max_range_offset and friends.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6785
diff
changeset
|
3664 NGX_MAX_OFF_T_VALUE); |
0fba3ed4e7eb
Cache: proxy_cache_max_range_offset and friends.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6785
diff
changeset
|
3665 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3666 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
|
3667 prev->upstream.cache_use_stale, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3668 (NGX_CONF_BITMASK_SET |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3669 |NGX_HTTP_UPSTREAM_FT_OFF)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3670 |
4401
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
3671 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
|
3672 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
|
3673 |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
|
3674 } |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
3675 |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
3676 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
|
3677 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
|
3678 } |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
3679 |
2875
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
3680 if (conf->upstream.cache_methods == 0) { |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
3681 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
|
3682 } |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
3683 |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
3684 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
|
3685 |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
3686 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
|
3687 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
|
3688 |
3526
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
3689 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
|
3690 prev->upstream.no_cache, NULL); |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
3691 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3692 ngx_conf_merge_ptr_value(conf->upstream.cache_valid, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3693 prev->upstream.cache_valid, NULL); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3694 |
2672 | 3695 if (conf->cache_key.value.data == NULL) { |
3696 conf->cache_key = prev->cache_key; | |
3697 } | |
3698 | |
4385
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3699 ngx_conf_merge_value(conf->upstream.cache_lock, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3700 prev->upstream.cache_lock, 0); |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3701 |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3702 ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3703 prev->upstream.cache_lock_timeout, 5000); |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3704 |
5905
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
3705 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
|
3706 prev->upstream.cache_lock_age, 5000); |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
3707 |
5441
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
3708 ngx_conf_merge_value(conf->upstream.cache_revalidate, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
3709 prev->upstream.cache_revalidate, 0); |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
3710 |
6290
4d5ac1a31d44
Upstream: proxy_cache_convert_head directive.
Roman Arutyunyan <arut@nginx.com>
parents:
6157
diff
changeset
|
3711 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
|
3712 prev->upstream.cache_convert_head, 1); |
4d5ac1a31d44
Upstream: proxy_cache_convert_head directive.
Roman Arutyunyan <arut@nginx.com>
parents:
6157
diff
changeset
|
3713 |
6906
1aeaae6e9446
Upstream: proxy_cache_background_update and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6793
diff
changeset
|
3714 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
|
3715 prev->upstream.cache_background_update, 0); |
1aeaae6e9446
Upstream: proxy_cache_background_update and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6793
diff
changeset
|
3716 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3717 #endif |
507 | 3718 |
509 | 3719 ngx_conf_merge_value(conf->upstream.pass_request_headers, |
3720 prev->upstream.pass_request_headers, 1); | |
3721 ngx_conf_merge_value(conf->upstream.pass_request_body, | |
3722 prev->upstream.pass_request_body, 1); | |
3723 | |
657 | 3724 ngx_conf_merge_value(conf->upstream.intercept_errors, |
3725 prev->upstream.intercept_errors, 0); | |
509 | 3726 |
2184 | 3727 #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
|
3728 |
8053
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
3729 if (ngx_http_proxy_merge_ssl(cf, conf, prev) != NGX_OK) { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
3730 return NGX_CONF_ERROR; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
3731 } |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
3732 |
2184 | 3733 ngx_conf_merge_value(conf->upstream.ssl_session_reuse, |
3734 prev->upstream.ssl_session_reuse, 1); | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3735 |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3736 ngx_conf_merge_bitmask_value(conf->ssl_protocols, prev->ssl_protocols, |
8152
d1cf09451ae8
SSL: enabled TLSv1.3 by default.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8053
diff
changeset
|
3737 (NGX_CONF_BITMASK_SET |
d1cf09451ae8
SSL: enabled TLSv1.3 by default.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8053
diff
changeset
|
3738 |NGX_SSL_TLSv1|NGX_SSL_TLSv1_1 |
d1cf09451ae8
SSL: enabled TLSv1.3 by default.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8053
diff
changeset
|
3739 |NGX_SSL_TLSv1_2|NGX_SSL_TLSv1_3)); |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3740 |
5390
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
3741 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
|
3742 "DEFAULT"); |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
3743 |
7831
bdd4d89370a7
Changed complex value slots to use NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7787
diff
changeset
|
3744 ngx_conf_merge_ptr_value(conf->upstream.ssl_name, |
bdd4d89370a7
Changed complex value slots to use NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7787
diff
changeset
|
3745 prev->upstream.ssl_name, NULL); |
5660
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
3746 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
|
3747 prev->upstream.ssl_server_name, 0); |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3748 ngx_conf_merge_value(conf->upstream.ssl_verify, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3749 prev->upstream.ssl_verify, 0); |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3750 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
|
3751 prev->ssl_verify_depth, 1); |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3752 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
|
3753 prev->ssl_trusted_certificate, ""); |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3754 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
|
3755 |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3756 ngx_conf_merge_ptr_value(conf->upstream.ssl_certificate, |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3757 prev->upstream.ssl_certificate, NULL); |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3758 ngx_conf_merge_ptr_value(conf->upstream.ssl_certificate_key, |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3759 prev->upstream.ssl_certificate_key, NULL); |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3760 ngx_conf_merge_ptr_value(conf->upstream.ssl_passwords, |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3761 prev->upstream.ssl_passwords, NULL); |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3762 |
7730
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
3763 ngx_conf_merge_ptr_value(conf->ssl_conf_commands, |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
3764 prev->ssl_conf_commands, NULL); |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
3765 |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3766 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
|
3767 return NGX_CONF_ERROR; |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3768 } |
5660
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
3769 |
2184 | 3770 #endif |
3771 | |
7831
bdd4d89370a7
Changed complex value slots to use NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7787
diff
changeset
|
3772 ngx_conf_merge_ptr_value(conf->method, prev->method, NULL); |
bdd4d89370a7
Changed complex value slots to use NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7787
diff
changeset
|
3773 |
509 | 3774 ngx_conf_merge_value(conf->redirect, prev->redirect, 1); |
3775 | |
3776 if (conf->redirect) { | |
507 | 3777 |
509 | 3778 if (conf->redirects == NULL) { |
3779 conf->redirects = prev->redirects; | |
3780 } | |
3781 | |
1658 | 3782 if (conf->redirects == NULL && conf->url.data) { |
509 | 3783 |
3784 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
|
3785 sizeof(ngx_http_proxy_rewrite_t)); |
509 | 3786 if (conf->redirects == NULL) { |
3787 return NGX_CONF_ERROR; | |
3788 } | |
3789 | |
3790 pr = ngx_array_push(conf->redirects); | |
3791 if (pr == NULL) { | |
3792 return NGX_CONF_ERROR; | |
3793 } | |
3794 | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3795 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
|
3796 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
|
3797 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3798 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
|
3799 |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3800 pr->handler = ngx_http_proxy_rewrite_complex_handler; |
1658 | 3801 |
3802 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
|
3803 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
|
3804 pr->replacement.value = conf->location; |
653 | 3805 |
3806 } else { | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3807 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
|
3808 + sizeof("/") - 1; |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3809 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3810 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
|
3811 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
|
3812 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
|
3813 } |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3814 |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3815 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
|
3816 |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3817 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
|
3818 *p = '/'; |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3819 |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3820 ngx_str_set(&pr->replacement.value, "/"); |
653 | 3821 } |
509 | 3822 } |
3823 } | |
3824 | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3825 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
|
3826 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3827 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
|
3828 |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3829 ngx_conf_merge_ptr_value(conf->cookie_flags, prev->cookie_flags, NULL); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3830 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
3831 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
|
3832 NGX_HTTP_VERSION_10); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
3833 |
1180
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
3834 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
|
3835 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
|
3836 |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
3837 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
|
3838 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
|
3839 |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
3840 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
|
3841 ngx_cacheline_size); |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
3842 |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
3843 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
|
3844 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
|
3845 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
|
3846 |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
3847 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
|
3848 &prev->upstream, ngx_http_proxy_hide_headers, &hash) |
649 | 3849 != NGX_OK) |
3850 { | |
3851 return NGX_CONF_ERROR; | |
3852 } | |
3853 | |
5938
cd2abf7e7740
Upstream: fixed unexpected inheritance into limit_except blocks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5937
diff
changeset
|
3854 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
|
3855 |
cd2abf7e7740
Upstream: fixed unexpected inheritance into limit_except blocks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5937
diff
changeset
|
3856 if (clcf->noname |
cd2abf7e7740
Upstream: fixed unexpected inheritance into limit_except blocks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5937
diff
changeset
|
3857 && 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
|
3858 { |
884 | 3859 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
|
3860 conf->location = prev->location; |
1658 | 3861 conf->vars = prev->vars; |
5937
5b9f711dc819
Upstream: inheritance of proxy_pass and friends (ticket #645).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5936
diff
changeset
|
3862 |
3734
e3a6785b5be4
*) make code consistent to fastcgi, etc
Igor Sysoev <igor@sysoev.ru>
parents:
3733
diff
changeset
|
3863 conf->proxy_lengths = prev->proxy_lengths; |
e3a6785b5be4
*) make code consistent to fastcgi, etc
Igor Sysoev <igor@sysoev.ru>
parents:
3733
diff
changeset
|
3864 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
|
3865 |
5b9f711dc819
Upstream: inheritance of proxy_pass and friends (ticket #645).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5936
diff
changeset
|
3866 #if (NGX_HTTP_SSL) |
8053
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
3867 conf->ssl = prev->ssl; |
5937
5b9f711dc819
Upstream: inheritance of proxy_pass and friends (ticket #645).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5936
diff
changeset
|
3868 #endif |
3734
e3a6785b5be4
*) make code consistent to fastcgi, etc
Igor Sysoev <igor@sysoev.ru>
parents:
3733
diff
changeset
|
3869 } |
e3a6785b5be4
*) make code consistent to fastcgi, etc
Igor Sysoev <igor@sysoev.ru>
parents:
3733
diff
changeset
|
3870 |
5938
cd2abf7e7740
Upstream: fixed unexpected inheritance into limit_except blocks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5937
diff
changeset
|
3871 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
|
3872 && (conf->upstream.upstream || conf->proxy_lengths)) |
cd2abf7e7740
Upstream: fixed unexpected inheritance into limit_except blocks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5937
diff
changeset
|
3873 { |
cd2abf7e7740
Upstream: fixed unexpected inheritance into limit_except blocks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5937
diff
changeset
|
3874 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
|
3875 } |
577 | 3876 |
3877 if (conf->body_source.data == NULL) { | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3878 conf->body_flushes = prev->body_flushes; |
577 | 3879 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
|
3880 conf->body_lengths = prev->body_lengths; |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3881 conf->body_values = prev->body_values; |
577 | 3882 } |
3883 | |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3884 if (conf->body_source.data && conf->body_lengths == NULL) { |
577 | 3885 |
3886 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
3887 | |
3888 sc.cf = cf; | |
3889 sc.source = &conf->body_source; | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3890 sc.flushes = &conf->body_flushes; |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3891 sc.lengths = &conf->body_lengths; |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3892 sc.values = &conf->body_values; |
577 | 3893 sc.complete_lengths = 1; |
3894 sc.complete_values = 1; | |
3895 | |
3896 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
3897 return NGX_CONF_ERROR; | |
3898 } | |
3899 } | |
3900 | |
7728
485dba3e2a01
Core: ngx_conf_set_keyval_slot() now accepts NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7720
diff
changeset
|
3901 ngx_conf_merge_ptr_value(conf->headers_source, prev->headers_source, NULL); |
485dba3e2a01
Core: ngx_conf_set_keyval_slot() now accepts NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7720
diff
changeset
|
3902 |
485dba3e2a01
Core: ngx_conf_set_keyval_slot() now accepts NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7720
diff
changeset
|
3903 if (conf->headers_source == prev->headers_source) { |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3904 conf->headers = prev->headers; |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3905 #if (NGX_HTTP_CACHE) |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3906 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
|
3907 #endif |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3908 } |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3909 |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3910 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
|
3911 ngx_http_proxy_headers); |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3912 if (rc != NGX_OK) { |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3913 return NGX_CONF_ERROR; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3914 } |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3915 |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3916 #if (NGX_HTTP_CACHE) |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3917 |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3918 if (conf->upstream.cache) { |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3919 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
|
3920 ngx_http_proxy_cache_headers); |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3921 if (rc != NGX_OK) { |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3922 return NGX_CONF_ERROR; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3923 } |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3924 } |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3925 |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3926 #endif |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3927 |
6747
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3928 /* |
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3929 * 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
|
3930 * 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
|
3931 */ |
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3932 |
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3933 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
|
3934 && 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
|
3935 { |
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3936 prev->headers = conf->headers; |
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3937 #if (NGX_HTTP_CACHE) |
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3938 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
|
3939 #endif |
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3940 } |
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3941 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3942 return NGX_CONF_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3943 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3944 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3945 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3946 static ngx_int_t |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3947 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
|
3948 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
|
3949 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3950 u_char *p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3951 size_t size; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3952 uintptr_t *code; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3953 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
|
3954 ngx_array_t headers_names, headers_merged; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3955 ngx_keyval_t *src, *s, *h; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3956 ngx_hash_key_t *hk; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3957 ngx_hash_init_t hash; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3958 ngx_http_script_compile_t sc; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3959 ngx_http_script_copy_code_t *copy; |
577 | 3960 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3961 if (headers->hash.buckets) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3962 return NGX_OK; |
509 | 3963 } |
3964 | |
3561
20708cffd6dc
use local headers_names array instead of stored in configuration
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
3965 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
|
3966 != NGX_OK) |
20708cffd6dc
use local headers_names array instead of stored in configuration
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
3967 { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3968 return NGX_ERROR; |
509 | 3969 } |
3970 | |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3971 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
|
3972 != NGX_OK) |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3973 { |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3974 return NGX_ERROR; |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3975 } |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3976 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3977 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
|
3978 if (headers->lengths == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3979 return NGX_ERROR; |
509 | 3980 } |
3981 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3982 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
|
3983 if (headers->values == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3984 return NGX_ERROR; |
509 | 3985 } |
3986 | |
6746
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
3987 if (conf->headers_source) { |
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
3988 |
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
3989 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
|
3990 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
|
3991 |
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
3992 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
|
3993 if (s == NULL) { |
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
3994 return NGX_ERROR; |
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
3995 } |
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
3996 |
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
3997 *s = src[i]; |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3998 } |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3999 } |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4000 |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
4001 h = default_headers; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
4002 |
2705
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
4003 while (h->key.len) { |
509 | 4004 |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4005 src = headers_merged.elts; |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4006 for (i = 0; i < headers_merged.nelts; i++) { |
509 | 4007 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { |
4008 goto next; | |
507 | 4009 } |
4010 } | |
4011 | |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4012 s = ngx_array_push(&headers_merged); |
509 | 4013 if (s == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4014 return NGX_ERROR; |
507 | 4015 } |
4016 | |
509 | 4017 *s = *h; |
507 | 4018 |
509 | 4019 next: |
507 | 4020 |
2705
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
4021 h++; |
509 | 4022 } |
507 | 4023 |
577 | 4024 |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4025 src = headers_merged.elts; |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4026 for (i = 0; i < headers_merged.nelts; i++) { |
507 | 4027 |
3561
20708cffd6dc
use local headers_names array instead of stored in configuration
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
4028 hk = ngx_array_push(&headers_names); |
649 | 4029 if (hk == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4030 return NGX_ERROR; |
507 | 4031 } |
4032 | |
649 | 4033 hk->key = src[i].key; |
4034 hk->key_hash = ngx_hash_key_lc(src[i].key.data, src[i].key.len); | |
4035 hk->value = (void *) 1; | |
509 | 4036 |
519 | 4037 if (src[i].value.len == 0) { |
4038 continue; | |
4039 } | |
4040 | |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4041 copy = ngx_array_push_n(headers->lengths, |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4042 sizeof(ngx_http_script_copy_code_t)); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4043 if (copy == NULL) { |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4044 return NGX_ERROR; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4045 } |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4046 |
7271
9e25a5380a21
Silenced -Wcast-function-type warnings (closes #1546).
Sergey Kandaurov <pluknet@nginx.com>
parents:
7238
diff
changeset
|
4047 copy->code = (ngx_http_script_code_pt) (void *) |
9e25a5380a21
Silenced -Wcast-function-type warnings (closes #1546).
Sergey Kandaurov <pluknet@nginx.com>
parents:
7238
diff
changeset
|
4048 ngx_http_script_copy_len_code; |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4049 copy->len = src[i].key.len; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4050 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4051 size = (sizeof(ngx_http_script_copy_code_t) |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4052 + src[i].key.len + sizeof(uintptr_t) - 1) |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4053 & ~(sizeof(uintptr_t) - 1); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4054 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4055 copy = ngx_array_push_n(headers->values, size); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4056 if (copy == NULL) { |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4057 return NGX_ERROR; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4058 } |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4059 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4060 copy->code = ngx_http_script_copy_code; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4061 copy->len = src[i].key.len; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4062 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4063 p = (u_char *) copy + sizeof(ngx_http_script_copy_code_t); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4064 ngx_memcpy(p, src[i].key.data, src[i].key.len); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4065 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4066 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4067 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4068 sc.cf = cf; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4069 sc.source = &src[i].value; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4070 sc.flushes = &headers->flushes; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4071 sc.lengths = &headers->lengths; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4072 sc.values = &headers->values; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4073 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4074 if (ngx_http_script_compile(&sc) != NGX_OK) { |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4075 return NGX_ERROR; |
507 | 4076 } |
4077 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
4078 code = ngx_array_push_n(headers->lengths, sizeof(uintptr_t)); |
509 | 4079 if (code == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4080 return NGX_ERROR; |
507 | 4081 } |
4082 | |
509 | 4083 *code = (uintptr_t) NULL; |
4084 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
4085 code = ngx_array_push_n(headers->values, sizeof(uintptr_t)); |
509 | 4086 if (code == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4087 return NGX_ERROR; |
509 | 4088 } |
4089 | |
4090 *code = (uintptr_t) NULL; | |
507 | 4091 } |
4092 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
4093 code = ngx_array_push_n(headers->lengths, sizeof(uintptr_t)); |
509 | 4094 if (code == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4095 return NGX_ERROR; |
507 | 4096 } |
4097 | |
509 | 4098 *code = (uintptr_t) NULL; |
507 | 4099 |
4100 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
4101 hash.hash = &headers->hash; |
649 | 4102 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
|
4103 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
|
4104 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
|
4105 hash.name = "proxy_headers_hash"; |
649 | 4106 hash.pool = cf->pool; |
4107 hash.temp_pool = NULL; | |
4108 | |
3561
20708cffd6dc
use local headers_names array instead of stored in configuration
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
4109 return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts); |
507 | 4110 } |
4111 | |
4112 | |
4113 static char * | |
4114 ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
4115 { | |
509 | 4116 ngx_http_proxy_loc_conf_t *plcf = conf; |
507 | 4117 |
1658 | 4118 size_t add; |
4119 u_short port; | |
4120 ngx_str_t *value, *url; | |
4121 ngx_url_t u; | |
4122 ngx_uint_t n; | |
4123 ngx_http_core_loc_conf_t *clcf; | |
4124 ngx_http_script_compile_t sc; | |
507 | 4125 |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2285
diff
changeset
|
4126 if (plcf->upstream.upstream || plcf->proxy_lengths) { |
555 | 4127 return "is duplicate"; |
4128 } | |
4129 | |
1658 | 4130 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); |
4131 | |
2989
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2949
diff
changeset
|
4132 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
|
4133 |
7321
45e513c3540d
Fixed invalid access to location defined as an empty string.
Ruslan Ermilov <ru@nginx.com>
parents:
7320
diff
changeset
|
4134 if (clcf->name.len && clcf->name.data[clcf->name.len - 1] == '/') { |
2989
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2949
diff
changeset
|
4135 clcf->auto_redirect = 1; |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2949
diff
changeset
|
4136 } |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2949
diff
changeset
|
4137 |
507 | 4138 value = cf->args->elts; |
4139 | |
4140 url = &value[1]; | |
4141 | |
1658 | 4142 n = ngx_http_script_variables_count(url); |
4143 | |
4144 if (n) { | |
4145 | |
4146 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
4147 | |
4148 sc.cf = cf; | |
4149 sc.source = url; | |
4150 sc.lengths = &plcf->proxy_lengths; | |
4151 sc.values = &plcf->proxy_values; | |
4152 sc.variables = n; | |
4153 sc.complete_lengths = 1; | |
4154 sc.complete_values = 1; | |
1679
ca317d9b5c09
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1671
diff
changeset
|
4155 |
1658 | 4156 if (ngx_http_script_compile(&sc) != NGX_OK) { |
4157 return NGX_CONF_ERROR; | |
4158 } | |
4159 | |
4160 #if (NGX_HTTP_SSL) | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
4161 plcf->ssl = 1; |
1658 | 4162 #endif |
4163 | |
4164 return NGX_CONF_OK; | |
4165 } | |
4166 | |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
969
diff
changeset
|
4167 if (ngx_strncasecmp(url->data, (u_char *) "http://", 7) == 0) { |
577 | 4168 add = 7; |
591 | 4169 port = 80; |
577 | 4170 |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
969
diff
changeset
|
4171 } else if (ngx_strncasecmp(url->data, (u_char *) "https://", 8) == 0) { |
577 | 4172 |
4173 #if (NGX_HTTP_SSL) | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
4174 plcf->ssl = 1; |
577 | 4175 |
4176 add = 8; | |
591 | 4177 port = 443; |
577 | 4178 #else |
4179 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
4180 "https protocol requires SSL support"); | |
4181 return NGX_CONF_ERROR; | |
4182 #endif | |
4183 | |
4184 } else { | |
507 | 4185 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid URL prefix"); |
4186 return NGX_CONF_ERROR; | |
4187 } | |
4188 | |
651 | 4189 ngx_memzero(&u, sizeof(ngx_url_t)); |
4190 | |
4191 u.url.len = url->len - add; | |
4192 u.url.data = url->data + add; | |
906 | 4193 u.default_port = port; |
4194 u.uri_part = 1; | |
884 | 4195 u.no_resolve = 1; |
4196 | |
4197 plcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0); | |
4198 if (plcf->upstream.upstream == NULL) { | |
507 | 4199 return NGX_CONF_ERROR; |
4200 } | |
4201 | |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2285
diff
changeset
|
4202 plcf->vars.schema.len = add; |
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2285
diff
changeset
|
4203 plcf->vars.schema.data = url->data; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4204 plcf->vars.key_start = plcf->vars.schema; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4205 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4206 ngx_http_proxy_set_vars(&u, &plcf->vars); |
507 | 4207 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4208 plcf->location = clcf->name; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4209 |
1353 | 4210 if (clcf->named |
507 | 4211 #if (NGX_PCRE) |
1353 | 4212 || clcf->regex |
4213 #endif | |
4214 || clcf->noname) | |
4215 { | |
1658 | 4216 if (plcf->vars.uri.len) { |
573 | 4217 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
|
4218 "\"proxy_pass\" cannot have URI part in " |
843
ebab9490204c
allow proxy_pass inside limit_except
Igor Sysoev <igor@sysoev.ru>
parents:
812
diff
changeset
|
4219 "location given by regular expression, " |
1353 | 4220 "or inside named location, " |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
4221 "or inside \"if\" statement, " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
4222 "or inside \"limit_except\" block"); |
573 | 4223 return NGX_CONF_ERROR; |
4224 } | |
4225 | |
1658 | 4226 plcf->location.len = 0; |
555 | 4227 } |
4228 | |
1658 | 4229 plcf->url = *url; |
509 | 4230 |
507 | 4231 return NGX_CONF_OK; |
4232 } | |
4233 | |
4234 | |
4235 static char * | |
509 | 4236 ngx_http_proxy_redirect(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
507 | 4237 { |
509 | 4238 ngx_http_proxy_loc_conf_t *plcf = conf; |
4239 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4240 u_char *p; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4241 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
|
4242 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
|
4243 ngx_http_compile_complex_value_t ccv; |
509 | 4244 |
4245 if (plcf->redirect == 0) { | |
7714
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4246 return "is duplicate"; |
509 | 4247 } |
4248 | |
4422
b1a9d725ab69
Fixed proxy_redirect off inheritance.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
4249 plcf->redirect = 1; |
b1a9d725ab69
Fixed proxy_redirect off inheritance.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
4250 |
509 | 4251 value = cf->args->elts; |
4252 | |
2784
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4253 if (cf->args->nelts == 2) { |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4254 if (ngx_strcmp(value[1].data, "off") == 0) { |
7714
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4255 |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4256 if (plcf->redirects) { |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4257 return "is duplicate"; |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4258 } |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4259 |
2784
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4260 plcf->redirect = 0; |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4261 return NGX_CONF_OK; |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4262 } |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4263 |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4264 if (ngx_strcmp(value[1].data, "default") != 0) { |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4265 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
|
4266 "invalid parameter \"%V\"", &value[1]); |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4267 return NGX_CONF_ERROR; |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4268 } |
509 | 4269 } |
4270 | |
4271 if (plcf->redirects == NULL) { | |
4272 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
|
4273 sizeof(ngx_http_proxy_rewrite_t)); |
509 | 4274 if (plcf->redirects == NULL) { |
4275 return NGX_CONF_ERROR; | |
4276 } | |
4277 } | |
4278 | |
4279 pr = ngx_array_push(plcf->redirects); | |
4280 if (pr == NULL) { | |
4281 return NGX_CONF_ERROR; | |
4282 } | |
4283 | |
7714
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4284 if (cf->args->nelts == 2 |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4285 && ngx_strcmp(value[1].data, "default") == 0) |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4286 { |
3471
d8c56e7851b8
"proxy_redirect default" may not be used if a proxy_pass uses variables
Igor Sysoev <igor@sysoev.ru>
parents:
3470
diff
changeset
|
4287 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
|
4288 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
|
4289 "\"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
|
4290 "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
|
4291 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
|
4292 } |
d8c56e7851b8
"proxy_redirect default" may not be used if a proxy_pass uses variables
Igor Sysoev <igor@sysoev.ru>
parents:
3470
diff
changeset
|
4293 |
1658 | 4294 if (plcf->url.data == NULL) { |
509 | 4295 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
|
4296 "\"proxy_redirect default\" should be placed " |
509 | 4297 "after the \"proxy_pass\" directive"); |
4298 return NGX_CONF_ERROR; | |
4299 } | |
4300 | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
4301 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
|
4302 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
4303 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
|
4304 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4305 ngx_memzero(&pr->replacement, sizeof(ngx_http_complex_value_t)); |
1658 | 4306 |
4307 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
|
4308 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
|
4309 pr->replacement.value = plcf->location; |
653 | 4310 |
4311 } else { | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
4312 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
|
4313 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
4314 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
|
4315 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
|
4316 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
|
4317 } |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
4318 |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
4319 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
|
4320 |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
4321 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
|
4322 *p = '/'; |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
4323 |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4324 ngx_str_set(&pr->replacement.value, "/"); |
653 | 4325 } |
509 | 4326 |
4327 return NGX_CONF_OK; | |
4328 } | |
4329 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4330 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4331 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
|
4332 value[1].len--; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4333 value[1].data++; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4334 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4335 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
|
4336 value[1].len--; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4337 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
|
4338 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4339 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
|
4340 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
|
4341 } |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4342 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4343 } else { |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4344 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
|
4345 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
|
4346 } |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4347 } |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4348 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4349 } else { |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4350 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4351 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
|
4352 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4353 ccv.cf = cf; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4354 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
|
4355 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
|
4356 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4357 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
|
4358 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
|
4359 } |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4360 |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
4361 pr->handler = ngx_http_proxy_rewrite_complex_handler; |
509 | 4362 } |
4363 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4364 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4365 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
|
4366 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4367 ccv.cf = cf; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4368 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
|
4369 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
|
4370 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4371 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { |
509 | 4372 return NGX_CONF_ERROR; |
4373 } | |
4374 | |
507 | 4375 return NGX_CONF_OK; |
4376 } | |
4377 | |
4378 | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4379 static char * |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4380 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
|
4381 { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4382 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
|
4383 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4384 ngx_str_t *value; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4385 ngx_http_proxy_rewrite_t *pr; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4386 ngx_http_compile_complex_value_t ccv; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4387 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4388 if (plcf->cookie_domains == NULL) { |
7714
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4389 return "is duplicate"; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4390 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4391 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4392 value = cf->args->elts; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4393 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4394 if (cf->args->nelts == 2) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4395 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4396 if (ngx_strcmp(value[1].data, "off") == 0) { |
7714
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4397 |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4398 if (plcf->cookie_domains != NGX_CONF_UNSET_PTR) { |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4399 return "is duplicate"; |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4400 } |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4401 |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4402 plcf->cookie_domains = NULL; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4403 return NGX_CONF_OK; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4404 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4405 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4406 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
|
4407 "invalid parameter \"%V\"", &value[1]); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4408 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4409 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4410 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4411 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
|
4412 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
|
4413 sizeof(ngx_http_proxy_rewrite_t)); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4414 if (plcf->cookie_domains == NULL) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4415 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4416 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4417 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4418 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4419 pr = ngx_array_push(plcf->cookie_domains); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4420 if (pr == NULL) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4421 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4422 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4423 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4424 if (value[1].data[0] == '~') { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4425 value[1].len--; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4426 value[1].data++; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4427 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4428 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
|
4429 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4430 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4431 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4432 } else { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4433 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4434 if (value[1].data[0] == '.') { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4435 value[1].len--; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4436 value[1].data++; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4437 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4438 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4439 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
|
4440 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4441 ccv.cf = cf; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4442 ccv.value = &value[1]; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4443 ccv.complex_value = &pr->pattern.complex; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4444 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4445 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
|
4446 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4447 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4448 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4449 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
|
4450 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4451 if (value[2].data[0] == '.') { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4452 value[2].len--; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4453 value[2].data++; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4454 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4455 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4456 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4457 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
|
4458 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4459 ccv.cf = cf; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4460 ccv.value = &value[2]; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4461 ccv.complex_value = &pr->replacement; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4462 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4463 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
|
4464 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4465 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4466 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4467 return NGX_CONF_OK; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4468 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4469 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4470 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4471 static char * |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4472 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
|
4473 { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4474 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
|
4475 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4476 ngx_str_t *value; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4477 ngx_http_proxy_rewrite_t *pr; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4478 ngx_http_compile_complex_value_t ccv; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4479 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4480 if (plcf->cookie_paths == NULL) { |
7714
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4481 return "is duplicate"; |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4482 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4483 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4484 value = cf->args->elts; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4485 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4486 if (cf->args->nelts == 2) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4487 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4488 if (ngx_strcmp(value[1].data, "off") == 0) { |
7714
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4489 |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4490 if (plcf->cookie_paths != NGX_CONF_UNSET_PTR) { |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4491 return "is duplicate"; |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4492 } |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4493 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4494 plcf->cookie_paths = NULL; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4495 return NGX_CONF_OK; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4496 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4497 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4498 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
|
4499 "invalid parameter \"%V\"", &value[1]); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4500 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4501 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4502 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4503 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
|
4504 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
|
4505 sizeof(ngx_http_proxy_rewrite_t)); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4506 if (plcf->cookie_paths == NULL) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4507 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4508 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4509 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4510 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4511 pr = ngx_array_push(plcf->cookie_paths); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4512 if (pr == NULL) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4513 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4514 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4515 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4516 if (value[1].data[0] == '~') { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4517 value[1].len--; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4518 value[1].data++; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4519 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4520 if (value[1].data[0] == '*') { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4521 value[1].len--; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4522 value[1].data++; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4523 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4524 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
|
4525 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4526 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4527 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4528 } else { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4529 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
|
4530 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4531 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4532 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4533 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4534 } else { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4535 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4536 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
|
4537 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4538 ccv.cf = cf; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4539 ccv.value = &value[1]; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4540 ccv.complex_value = &pr->pattern.complex; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4541 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4542 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
|
4543 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4544 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4545 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4546 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
|
4547 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4548 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4549 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
|
4550 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4551 ccv.cf = cf; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4552 ccv.value = &value[2]; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4553 ccv.complex_value = &pr->replacement; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4554 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4555 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
|
4556 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4557 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4558 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4559 return NGX_CONF_OK; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4560 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4561 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4562 |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4563 static char * |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4564 ngx_http_proxy_cookie_flags(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4565 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4566 ngx_http_proxy_loc_conf_t *plcf = conf; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4567 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4568 ngx_str_t *value; |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4569 ngx_uint_t i; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4570 ngx_http_complex_value_t *cv; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4571 ngx_http_proxy_cookie_flags_t *pcf; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4572 ngx_http_compile_complex_value_t ccv; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4573 #if (NGX_PCRE) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4574 ngx_regex_compile_t rc; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4575 u_char errstr[NGX_MAX_CONF_ERRSTR]; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4576 #endif |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4577 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4578 if (plcf->cookie_flags == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4579 return "is duplicate"; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4580 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4581 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4582 value = cf->args->elts; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4583 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4584 if (cf->args->nelts == 2) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4585 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4586 if (ngx_strcmp(value[1].data, "off") == 0) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4587 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4588 if (plcf->cookie_flags != NGX_CONF_UNSET_PTR) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4589 return "is duplicate"; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4590 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4591 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4592 plcf->cookie_flags = NULL; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4593 return NGX_CONF_OK; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4594 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4595 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4596 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4597 "invalid parameter \"%V\"", &value[1]); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4598 return NGX_CONF_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4599 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4600 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4601 if (plcf->cookie_flags == NGX_CONF_UNSET_PTR) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4602 plcf->cookie_flags = ngx_array_create(cf->pool, 1, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4603 sizeof(ngx_http_proxy_cookie_flags_t)); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4604 if (plcf->cookie_flags == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4605 return NGX_CONF_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4606 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4607 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4608 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4609 pcf = ngx_array_push(plcf->cookie_flags); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4610 if (pcf == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4611 return NGX_CONF_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4612 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4613 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4614 pcf->regex = 0; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4615 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4616 if (value[1].data[0] == '~') { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4617 value[1].len--; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4618 value[1].data++; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4619 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4620 #if (NGX_PCRE) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4621 ngx_memzero(&rc, sizeof(ngx_regex_compile_t)); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4622 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4623 rc.pattern = value[1]; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4624 rc.err.len = NGX_MAX_CONF_ERRSTR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4625 rc.err.data = errstr; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4626 rc.options = NGX_REGEX_CASELESS; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4627 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4628 pcf->cookie.regex = ngx_http_regex_compile(cf, &rc); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4629 if (pcf->cookie.regex == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4630 return NGX_CONF_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4631 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4632 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4633 pcf->regex = 1; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4634 #else |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4635 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4636 "using regex \"%V\" requires PCRE library", |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4637 &value[1]); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4638 return NGX_CONF_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4639 #endif |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4640 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4641 } else { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4642 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4643 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4644 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4645 ccv.cf = cf; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4646 ccv.value = &value[1]; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4647 ccv.complex_value = &pcf->cookie.complex; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4648 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4649 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4650 return NGX_CONF_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4651 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4652 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4653 |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4654 if (ngx_array_init(&pcf->flags_values, cf->pool, cf->args->nelts - 2, |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4655 sizeof(ngx_http_complex_value_t)) |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4656 != NGX_OK) |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4657 { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4658 return NGX_CONF_ERROR; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4659 } |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4660 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4661 for (i = 2; i < cf->args->nelts; i++) { |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4662 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4663 cv = ngx_array_push(&pcf->flags_values); |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4664 if (cv == NULL) { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4665 return NGX_CONF_ERROR; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4666 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4667 |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4668 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4669 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4670 ccv.cf = cf; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4671 ccv.value = &value[i]; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4672 ccv.complex_value = cv; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4673 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4674 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4675 return NGX_CONF_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4676 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4677 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4678 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4679 return NGX_CONF_OK; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4680 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4681 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4682 |
4463
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4683 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
|
4684 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
|
4685 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
|
4686 { |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4687 #if (NGX_PCRE) |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4688 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
|
4689 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
|
4690 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4691 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
|
4692 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4693 rc.pattern = *regex; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4694 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
|
4695 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
|
4696 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4697 if (caseless) { |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4698 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
|
4699 } |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4700 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4701 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
|
4702 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
|
4703 return NGX_ERROR; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4704 } |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4705 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4706 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
|
4707 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4708 return NGX_OK; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4709 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4710 #else |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4711 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4712 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
|
4713 "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
|
4714 return NGX_ERROR; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4715 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4716 #endif |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4717 } |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4718 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4719 |
507 | 4720 static char * |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4721 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
|
4722 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4723 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
|
4724 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4725 ngx_str_t *value; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4726 ngx_http_script_compile_t sc; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4727 |
5947
d9025ea1f5a5
Upstream: simplified proxy_store and friends configuration code.
Valentin Bartenev <vbart@nginx.com>
parents:
5940
diff
changeset
|
4728 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
|
4729 return "is duplicate"; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4730 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4731 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4732 value = cf->args->elts; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4733 |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
4734 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
|
4735 plcf->upstream.store = 0; |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4736 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4737 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4738 |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
4739 #if (NGX_HTTP_CACHE) |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
4740 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
|
4741 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
|
4742 } |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
4743 #endif |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
4744 |
5947
d9025ea1f5a5
Upstream: simplified proxy_store and friends configuration code.
Valentin Bartenev <vbart@nginx.com>
parents:
5940
diff
changeset
|
4745 plcf->upstream.store = 1; |
d9025ea1f5a5
Upstream: simplified proxy_store and friends configuration code.
Valentin Bartenev <vbart@nginx.com>
parents:
5940
diff
changeset
|
4746 |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
4747 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
|
4748 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4749 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4750 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4751 /* include the terminating '\0' into script */ |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4752 value[1].len++; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4753 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4754 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
|
4755 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4756 sc.cf = cf; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4757 sc.source = &value[1]; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4758 sc.lengths = &plcf->upstream.store_lengths; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4759 sc.values = &plcf->upstream.store_values; |
1563
022ec9420f80
style fix: remove double semicolons
Igor Sysoev <igor@sysoev.ru>
parents:
1488
diff
changeset
|
4760 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
|
4761 sc.complete_lengths = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4762 sc.complete_values = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4763 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4764 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
|
4765 return NGX_CONF_ERROR; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4766 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4767 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4768 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4769 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4770 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4771 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4772 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4773 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4774 static char * |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4775 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
|
4776 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4777 ngx_http_proxy_loc_conf_t *plcf = conf; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4778 |
5951
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4779 ngx_str_t *value; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4780 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
|
4781 ngx_http_compile_complex_value_t ccv; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4782 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4783 value = cf->args->elts; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4784 |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
4785 if (plcf->upstream.cache != NGX_CONF_UNSET) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4786 return "is duplicate"; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4787 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4788 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4789 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
|
4790 plcf->upstream.cache = 0; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4791 return NGX_CONF_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4792 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4793 |
5947
d9025ea1f5a5
Upstream: simplified proxy_store and friends configuration code.
Valentin Bartenev <vbart@nginx.com>
parents:
5940
diff
changeset
|
4794 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
|
4795 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
|
4796 } |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
4797 |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
4798 plcf->upstream.cache = 1; |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
4799 |
5951
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4800 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
|
4801 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4802 ccv.cf = cf; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4803 ccv.value = &value[1]; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4804 ccv.complex_value = &cv; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4805 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4806 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
|
4807 return NGX_CONF_ERROR; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4808 } |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4809 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4810 if (cv.lengths != NULL) { |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4811 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4812 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
|
4813 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
|
4814 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
|
4815 return NGX_CONF_ERROR; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4816 } |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4817 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4818 *plcf->upstream.cache_value = cv; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4819 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4820 return NGX_CONF_OK; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4821 } |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4822 |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
4823 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
|
4824 &ngx_http_proxy_module); |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
4825 if (plcf->upstream.cache_zone == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4826 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4827 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4828 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4829 return NGX_CONF_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4830 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4831 |
2672 | 4832 |
4833 static char * | |
4834 ngx_http_proxy_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
4835 { | |
4836 ngx_http_proxy_loc_conf_t *plcf = conf; | |
4837 | |
4838 ngx_str_t *value; | |
4839 ngx_http_compile_complex_value_t ccv; | |
4840 | |
4841 value = cf->args->elts; | |
4842 | |
4947
4251e72b8bb4
Allow the complex value to be defined as an empty string.
Ruslan Ermilov <ru@nginx.com>
parents:
4927
diff
changeset
|
4843 if (plcf->cache_key.value.data) { |
2672 | 4844 return "is duplicate"; |
4845 } | |
4846 | |
4847 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
4848 | |
4849 ccv.cf = cf; | |
4850 ccv.value = &value[1]; | |
4851 ccv.complex_value = &plcf->cache_key; | |
4852 | |
4853 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
4854 return NGX_CONF_ERROR; | |
4855 } | |
4856 | |
4857 return NGX_CONF_OK; | |
4858 } | |
4859 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4860 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4861 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4862 |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4863 #if (NGX_HTTP_SSL) |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4864 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4865 static char * |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4866 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
|
4867 { |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4868 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
|
4869 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4870 ngx_str_t *value; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4871 |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
4872 if (plcf->upstream.ssl_passwords != NGX_CONF_UNSET_PTR) { |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4873 return "is duplicate"; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4874 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4875 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4876 value = cf->args->elts; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4877 |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
4878 plcf->upstream.ssl_passwords = ngx_ssl_read_password_file(cf, &value[1]); |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
4879 |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
4880 if (plcf->upstream.ssl_passwords == NULL) { |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4881 return NGX_CONF_ERROR; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4882 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4883 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4884 return NGX_CONF_OK; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4885 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4886 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4887 #endif |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4888 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4889 |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4890 static char * |
507 | 4891 ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data) |
4892 { | |
4893 #if (NGX_FREEBSD) | |
4894 ssize_t *np = data; | |
4895 | |
673 | 4896 if ((u_long) *np >= ngx_freebsd_net_inet_tcp_sendspace) { |
507 | 4897 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
4898 "\"proxy_send_lowat\" must be less than %d " | |
4899 "(sysctl net.inet.tcp.sendspace)", | |
4900 ngx_freebsd_net_inet_tcp_sendspace); | |
4901 | |
4902 return NGX_CONF_ERROR; | |
4903 } | |
4904 | |
4905 #elif !(NGX_HAVE_SO_SNDLOWAT) | |
4906 ssize_t *np = data; | |
4907 | |
4908 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
4909 "\"proxy_send_lowat\" is not supported, ignored"); | |
4910 | |
4911 *np = 0; | |
4912 | |
4913 #endif | |
4914 | |
4915 return NGX_CONF_OK; | |
4916 } | |
884 | 4917 |
4918 | |
1658 | 4919 #if (NGX_HTTP_SSL) |
4920 | |
7730
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4921 static char * |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4922 ngx_http_proxy_ssl_conf_command_check(ngx_conf_t *cf, void *post, void *data) |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4923 { |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4924 #ifndef SSL_CONF_FLAG_FILE |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4925 return "is not supported on this platform"; |
7787
7ce28b4cc57e
SSL: fixed build by Sun C with old OpenSSL versions.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7786
diff
changeset
|
4926 #else |
7ce28b4cc57e
SSL: fixed build by Sun C with old OpenSSL versions.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7786
diff
changeset
|
4927 return NGX_CONF_OK; |
7730
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4928 #endif |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4929 } |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4930 |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4931 |
1658 | 4932 static ngx_int_t |
8053
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4933 ngx_http_proxy_merge_ssl(ngx_conf_t *cf, ngx_http_proxy_loc_conf_t *conf, |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4934 ngx_http_proxy_loc_conf_t *prev) |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4935 { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4936 ngx_uint_t preserve; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4937 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4938 if (conf->ssl_protocols == 0 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4939 && conf->ssl_ciphers.data == NULL |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4940 && conf->upstream.ssl_certificate == NGX_CONF_UNSET_PTR |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4941 && conf->upstream.ssl_certificate_key == NGX_CONF_UNSET_PTR |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4942 && conf->upstream.ssl_passwords == NGX_CONF_UNSET_PTR |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4943 && conf->upstream.ssl_verify == NGX_CONF_UNSET |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4944 && conf->ssl_verify_depth == NGX_CONF_UNSET_UINT |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4945 && conf->ssl_trusted_certificate.data == NULL |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4946 && conf->ssl_crl.data == NULL |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4947 && conf->upstream.ssl_session_reuse == NGX_CONF_UNSET |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4948 && conf->ssl_conf_commands == NGX_CONF_UNSET_PTR) |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4949 { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4950 if (prev->upstream.ssl) { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4951 conf->upstream.ssl = prev->upstream.ssl; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4952 return NGX_OK; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4953 } |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4954 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4955 preserve = 1; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4956 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4957 } else { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4958 preserve = 0; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4959 } |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4960 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4961 conf->upstream.ssl = ngx_pcalloc(cf->pool, sizeof(ngx_ssl_t)); |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4962 if (conf->upstream.ssl == NULL) { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4963 return NGX_ERROR; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4964 } |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4965 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4966 conf->upstream.ssl->log = cf->log; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4967 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4968 /* |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4969 * special handling to preserve conf->upstream.ssl |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4970 * in the "http" section to inherit it to all servers |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4971 */ |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4972 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4973 if (preserve) { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4974 prev->upstream.ssl = conf->upstream.ssl; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4975 } |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4976 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4977 return NGX_OK; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4978 } |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4979 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4980 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4981 static ngx_int_t |
1658 | 4982 ngx_http_proxy_set_ssl(ngx_conf_t *cf, ngx_http_proxy_loc_conf_t *plcf) |
4983 { | |
4984 ngx_pool_cleanup_t *cln; | |
4985 | |
8053
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4986 if (plcf->upstream.ssl->ctx) { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4987 return NGX_OK; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4988 } |
1658 | 4989 |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
4990 if (ngx_ssl_create(plcf->upstream.ssl, plcf->ssl_protocols, NULL) |
1658 | 4991 != NGX_OK) |
4992 { | |
4993 return NGX_ERROR; | |
4994 } | |
4995 | |
5659
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
4996 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
|
4997 if (cln == NULL) { |
7473
8981dbb12254
SSL: fixed potential leak on memory allocation errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7371
diff
changeset
|
4998 ngx_ssl_cleanup_ctx(plcf->upstream.ssl); |
5659
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
4999 return NGX_ERROR; |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
5000 } |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
5001 |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
5002 cln->handler = ngx_ssl_cleanup_ctx; |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
5003 cln->data = plcf->upstream.ssl; |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
5004 |
7904
419c066cb710
SSL: ciphers now set before loading certificates (ticket #2035).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
5005 if (ngx_ssl_ciphers(cf, plcf->upstream.ssl, &plcf->ssl_ciphers, 0) |
419c066cb710
SSL: ciphers now set before loading certificates (ticket #2035).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
5006 != NGX_OK) |
419c066cb710
SSL: ciphers now set before loading certificates (ticket #2035).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
5007 { |
419c066cb710
SSL: ciphers now set before loading certificates (ticket #2035).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
5008 return NGX_ERROR; |
419c066cb710
SSL: ciphers now set before loading certificates (ticket #2035).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
5009 } |
419c066cb710
SSL: ciphers now set before loading certificates (ticket #2035).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
5010 |
8042
c7e25324be11
Upstream: handling of certificates specified as an empty string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8033
diff
changeset
|
5011 if (plcf->upstream.ssl_certificate |
c7e25324be11
Upstream: handling of certificates specified as an empty string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8033
diff
changeset
|
5012 && plcf->upstream.ssl_certificate->value.len) |
c7e25324be11
Upstream: handling of certificates specified as an empty string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8033
diff
changeset
|
5013 { |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5014 if (plcf->upstream.ssl_certificate_key == NULL) { |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5015 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
|
5016 "no \"proxy_ssl_certificate_key\" is defined " |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5017 "for certificate \"%V\"", |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5018 &plcf->upstream.ssl_certificate->value); |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5019 return NGX_ERROR; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5020 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5021 |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5022 if (plcf->upstream.ssl_certificate->lengths |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5023 || plcf->upstream.ssl_certificate_key->lengths) |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5024 { |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5025 plcf->upstream.ssl_passwords = |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5026 ngx_ssl_preserve_passwords(cf, plcf->upstream.ssl_passwords); |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5027 if (plcf->upstream.ssl_passwords == NULL) { |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5028 return NGX_ERROR; |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5029 } |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5030 |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5031 } else { |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5032 if (ngx_ssl_certificate(cf, plcf->upstream.ssl, |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5033 &plcf->upstream.ssl_certificate->value, |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5034 &plcf->upstream.ssl_certificate_key->value, |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5035 plcf->upstream.ssl_passwords) |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5036 != NGX_OK) |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5037 { |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5038 return NGX_ERROR; |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5039 } |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5040 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5041 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5042 |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5043 if (plcf->upstream.ssl_verify) { |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5044 if (plcf->ssl_trusted_certificate.len == 0) { |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5045 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
|
5046 "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
|
5047 return NGX_ERROR; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5048 } |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5049 |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5050 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
|
5051 &plcf->ssl_trusted_certificate, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5052 plcf->ssl_verify_depth) |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5053 != NGX_OK) |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5054 { |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5055 return NGX_ERROR; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5056 } |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5057 |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5058 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
|
5059 return NGX_ERROR; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5060 } |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5061 } |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5062 |
7320
696df3ac27ac
SSL: save sessions for upstream peers using a callback function.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7271
diff
changeset
|
5063 if (ngx_ssl_client_session_cache(cf, plcf->upstream.ssl, |
696df3ac27ac
SSL: save sessions for upstream peers using a callback function.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7271
diff
changeset
|
5064 plcf->upstream.ssl_session_reuse) |
696df3ac27ac
SSL: save sessions for upstream peers using a callback function.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7271
diff
changeset
|
5065 != NGX_OK) |
696df3ac27ac
SSL: save sessions for upstream peers using a callback function.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7271
diff
changeset
|
5066 { |
696df3ac27ac
SSL: save sessions for upstream peers using a callback function.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7271
diff
changeset
|
5067 return NGX_ERROR; |
696df3ac27ac
SSL: save sessions for upstream peers using a callback function.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7271
diff
changeset
|
5068 } |
696df3ac27ac
SSL: save sessions for upstream peers using a callback function.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7271
diff
changeset
|
5069 |
7730
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
5070 if (ngx_ssl_conf_commands(cf, plcf->upstream.ssl, plcf->ssl_conf_commands) |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
5071 != NGX_OK) |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
5072 { |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
5073 return NGX_ERROR; |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
5074 } |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
5075 |
1658 | 5076 return NGX_OK; |
5077 } | |
5078 | |
5079 #endif | |
5080 | |
5081 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
5082 static void |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
5083 ngx_http_proxy_set_vars(ngx_url_t *u, ngx_http_proxy_vars_t *v) |
1658 | 5084 { |
2203
8e5bf1bc87e2
*) refactor ngx_parse_inet_url()
Igor Sysoev <igor@sysoev.ru>
parents:
2184
diff
changeset
|
5085 if (u->family != AF_UNIX) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
5086 |
1658 | 5087 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
|
5088 |
1658 | 5089 v->host_header = u->host; |
5090 | |
5091 if (u->default_port == 80) { | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
5092 ngx_str_set(&v->port, "80"); |
1658 | 5093 |
5094 } else { | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
5095 ngx_str_set(&v->port, "443"); |
1658 | 5096 } |
5097 | |
5098 } 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
|
5099 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
|
5100 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
|
5101 v->port = u->port_text; |
1658 | 5102 } |
5103 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
5104 v->key_start.len += v->host_header.len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
5105 |
1658 | 5106 } else { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
5107 ngx_str_set(&v->host_header, "localhost"); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
5108 ngx_str_null(&v->port); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
5109 v->key_start.len += sizeof("unix:") - 1 + u->host.len + 1; |
1658 | 5110 } |
5111 | |
5112 v->uri = u->uri; | |
5113 } |