Mercurial > hg > nginx
annotate src/http/modules/ngx_http_proxy_module.c @ 9329:eebab9268326 default tip
MIME: added mjs extension to text/javascript.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sat, 31 Aug 2024 05:40:14 +0300 |
parents | 098019656024 |
children |
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 |
9252
51e0dc713784
Proxy: use zero Content-Length while discarding request body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8152
diff
changeset
|
1344 } else if (r->discard_body) { |
9263
388a801e9bb9
Request body: discarded body now treated as no body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9252
diff
changeset
|
1345 ctx->internal_body_length = -1; |
9252
51e0dc713784
Proxy: use zero Content-Length while discarding request body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8152
diff
changeset
|
1346 |
4927
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
1347 } else { |
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
1348 ctx->internal_body_length = r->headers_in.content_length_n; |
577 | 1349 } |
1350 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1351 le.ip = headers->lengths->elts; |
509 | 1352 le.request = r; |
573 | 1353 le.flushed = 1; |
507 | 1354 |
509 | 1355 while (*(uintptr_t *) le.ip) { |
7047
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 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
|
1358 key_len = lcode(&le); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1359 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1360 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
509 | 1361 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
1362 } | |
1363 le.ip += sizeof(uintptr_t); | |
7047
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 if (val_len == 0) { |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1366 continue; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1367 } |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1368 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1369 len += key_len + sizeof(": ") - 1 + val_len + sizeof(CRLF) - 1; |
507 | 1370 } |
1371 | |
1372 | |
509 | 1373 if (plcf->upstream.pass_request_headers) { |
1374 part = &r->headers_in.headers.part; | |
1375 header = part->elts; | |
1376 | |
1377 for (i = 0; /* void */; i++) { | |
507 | 1378 |
509 | 1379 if (i >= part->nelts) { |
1380 if (part->next == NULL) { | |
1381 break; | |
1382 } | |
1383 | |
1384 part = part->next; | |
1385 header = part->elts; | |
577 | 1386 i = 0; |
507 | 1387 } |
1388 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1389 if (ngx_hash_find(&headers->hash, header[i].hash, |
649 | 1390 header[i].lowcase_key, header[i].key.len)) |
509 | 1391 { |
1392 continue; | |
1393 } | |
1394 | |
1395 len += header[i].key.len + sizeof(": ") - 1 | |
1396 + header[i].value.len + sizeof(CRLF) - 1; | |
507 | 1397 } |
509 | 1398 } |
507 | 1399 |
1400 | |
1401 b = ngx_create_temp_buf(r->pool, len); | |
1402 if (b == NULL) { | |
1403 return NGX_ERROR; | |
1404 } | |
1405 | |
1406 cl = ngx_alloc_chain_link(r->pool); | |
1407 if (cl == NULL) { | |
1408 return NGX_ERROR; | |
1409 } | |
1410 | |
1411 cl->buf = b; | |
1412 | |
1413 | |
1414 /* the request line */ | |
1415 | |
573 | 1416 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
|
1417 *b->last++ = ' '; |
507 | 1418 |
555 | 1419 u->uri.data = b->last; |
1420 | |
4377
726a1ca9b52b
Proxy: made proxy_pass with variables more consistent.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4336
diff
changeset
|
1421 if (plcf->proxy_lengths && ctx->vars.uri.len) { |
1658 | 1422 b->last = ngx_copy(b->last, ctx->vars.uri.data, ctx->vars.uri.len); |
1423 | |
1424 } else if (unparsed_uri) { | |
573 | 1425 b->last = ngx_copy(b->last, r->unparsed_uri.data, r->unparsed_uri.len); |
1426 | |
507 | 1427 } else { |
555 | 1428 if (r->valid_location) { |
1658 | 1429 b->last = ngx_copy(b->last, ctx->vars.uri.data, ctx->vars.uri.len); |
555 | 1430 } |
551 | 1431 |
507 | 1432 if (escape) { |
509 | 1433 ngx_escape_uri(b->last, r->uri.data + loc_len, |
1434 r->uri.len - loc_len, NGX_ESCAPE_URI); | |
1435 b->last += r->uri.len - loc_len + escape; | |
507 | 1436 |
577 | 1437 } else { |
573 | 1438 b->last = ngx_copy(b->last, r->uri.data + loc_len, |
1439 r->uri.len - loc_len); | |
507 | 1440 } |
1441 | |
1442 if (r->args.len > 0) { | |
1443 *b->last++ = '?'; | |
573 | 1444 b->last = ngx_copy(b->last, r->args.data, r->args.len); |
507 | 1445 } |
1446 } | |
1447 | |
555 | 1448 u->uri.len = b->last - u->uri.data; |
1449 | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1450 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
|
1451 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
|
1452 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
|
1453 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1454 } else { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1455 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
|
1456 sizeof(ngx_http_proxy_version) - 1); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1457 } |
507 | 1458 |
577 | 1459 ngx_memzero(&e, sizeof(ngx_http_script_engine_t)); |
507 | 1460 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1461 e.ip = headers->values->elts; |
507 | 1462 e.pos = b->last; |
509 | 1463 e.request = r; |
573 | 1464 e.flushed = 1; |
507 | 1465 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1466 le.ip = headers->lengths->elts; |
509 | 1467 |
1468 while (*(uintptr_t *) le.ip) { | |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1469 |
509 | 1470 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
515 | 1471 (void) lcode(&le); |
509 | 1472 |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1473 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
|
1474 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
|
1475 } |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1476 le.ip += sizeof(uintptr_t); |
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 if (val_len == 0) { |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1479 e.skip = 1; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1480 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1481 while (*(uintptr_t *) e.ip) { |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1482 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
|
1483 code((ngx_http_script_engine_t *) &e); |
509 | 1484 } |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1485 e.ip += sizeof(uintptr_t); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1486 |
509 | 1487 e.skip = 0; |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1488 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1489 continue; |
509 | 1490 } |
1491 | |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1492 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
|
1493 code((ngx_http_script_engine_t *) &e); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1494 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1495 *e.pos++ = ':'; *e.pos++ = ' '; |
509 | 1496 |
1497 while (*(uintptr_t *) e.ip) { | |
1498 code = *(ngx_http_script_code_pt *) e.ip; | |
1499 code((ngx_http_script_engine_t *) &e); | |
577 | 1500 } |
509 | 1501 e.ip += sizeof(uintptr_t); |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1502 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
1503 *e.pos++ = CR; *e.pos++ = LF; |
507 | 1504 } |
1505 | |
1506 b->last = e.pos; | |
1507 | |
1508 | |
509 | 1509 if (plcf->upstream.pass_request_headers) { |
1510 part = &r->headers_in.headers.part; | |
1511 header = part->elts; | |
577 | 1512 |
509 | 1513 for (i = 0; /* void */; i++) { |
507 | 1514 |
509 | 1515 if (i >= part->nelts) { |
1516 if (part->next == NULL) { | |
1517 break; | |
1518 } | |
1519 | |
1520 part = part->next; | |
1521 header = part->elts; | |
577 | 1522 i = 0; |
507 | 1523 } |
1524 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
1525 if (ngx_hash_find(&headers->hash, header[i].hash, |
649 | 1526 header[i].lowcase_key, header[i].key.len)) |
509 | 1527 { |
1528 continue; | |
1529 } | |
507 | 1530 |
573 | 1531 b->last = ngx_copy(b->last, header[i].key.data, header[i].key.len); |
507 | 1532 |
509 | 1533 *b->last++ = ':'; *b->last++ = ' '; |
507 | 1534 |
573 | 1535 b->last = ngx_copy(b->last, header[i].value.data, |
1536 header[i].value.len); | |
507 | 1537 |
509 | 1538 *b->last++ = CR; *b->last++ = LF; |
507 | 1539 |
509 | 1540 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1541 "http proxy header: \"%V: %V\"", | |
1542 &header[i].key, &header[i].value); | |
1543 } | |
507 | 1544 } |
1545 | |
577 | 1546 |
507 | 1547 /* add "\r\n" at the header end */ |
1548 *b->last++ = CR; *b->last++ = LF; | |
1549 | |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
1550 if (plcf->body_values) { |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
1551 e.ip = plcf->body_values->elts; |
577 | 1552 e.pos = b->last; |
6043
613b14b305c7
Proxy: fixed proxy_set_body with proxy_cache.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6003
diff
changeset
|
1553 e.skip = 0; |
577 | 1554 |
1555 while (*(uintptr_t *) e.ip) { | |
1556 code = *(ngx_http_script_code_pt *) e.ip; | |
1557 code((ngx_http_script_engine_t *) &e); | |
1558 } | |
579 | 1559 |
1560 b->last = e.pos; | |
577 | 1561 } |
1562 | |
1774 | 1563 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
|
1564 "http proxy header:%N\"%*s\"", |
1774 | 1565 (size_t) (b->last - b->pos), b->pos); |
507 | 1566 |
6050
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1567 if (r->request_body_no_buffering) { |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1568 |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1569 u->request_bufs = cl; |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1570 |
6051
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1571 if (ctx->internal_chunked) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1572 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
|
1573 u->output.filter_ctx = r; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1574 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1575 |
6050
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
1576 } else if (plcf->body_values == NULL && plcf->upstream.pass_request_body) { |
509 | 1577 |
1578 body = u->request_bufs; | |
1579 u->request_bufs = cl; | |
1580 | |
1581 while (body) { | |
1582 b = ngx_alloc_buf(r->pool); | |
1583 if (b == NULL) { | |
1584 return NGX_ERROR; | |
1585 } | |
1586 | |
1587 ngx_memcpy(b, body->buf, sizeof(ngx_buf_t)); | |
1588 | |
1589 cl->next = ngx_alloc_chain_link(r->pool); | |
1590 if (cl->next == NULL) { | |
1591 return NGX_ERROR; | |
1592 } | |
1593 | |
1594 cl = cl->next; | |
1595 cl->buf = b; | |
1596 | |
1597 body = body->next; | |
1598 } | |
1599 | |
1600 } else { | |
1601 u->request_bufs = cl; | |
1602 } | |
1603 | |
4009
3183165283cc
Fixing proxy_set_body and proxy_pass_request_body with SSL.
Maxim Dounin <mdounin@mdounin.ru>
parents:
3977
diff
changeset
|
1604 b->flush = 1; |
509 | 1605 cl->next = NULL; |
1606 | |
507 | 1607 return NGX_OK; |
1608 } | |
1609 | |
1610 | |
1611 static ngx_int_t | |
1612 ngx_http_proxy_reinit_request(ngx_http_request_t *r) | |
1613 { | |
1658 | 1614 ngx_http_proxy_ctx_t *ctx; |
1615 | |
1616 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
1617 | |
1618 if (ctx == NULL) { | |
509 | 1619 return NGX_OK; |
1620 } | |
1621 | |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1622 ctx->status.code = 0; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1623 ctx->status.count = 0; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1624 ctx->status.start = NULL; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1625 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
|
1626 ctx->chunked.state = 0; |
509 | 1627 |
1628 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
|
1629 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
|
1630 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
|
1631 r->state = 0; |
509 | 1632 |
1633 return NGX_OK; | |
1634 } | |
1635 | |
1636 | |
1637 static ngx_int_t | |
6051
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1638 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
|
1639 { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1640 ngx_http_request_t *r = data; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1641 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1642 off_t size; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1643 u_char *chunk; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1644 ngx_int_t rc; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1645 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
|
1646 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
|
1647 ngx_http_proxy_ctx_t *ctx; |
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 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
|
1650 "proxy output filter"); |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1651 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1652 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
|
1653 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1654 if (in == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1655 out = in; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1656 goto out; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1657 } |
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 out = NULL; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1660 ll = &out; |
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 if (!ctx->header_sent) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1663 /* first buffer contains headers, pass it unmodified */ |
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 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
|
1666 "proxy output header"); |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1667 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1668 ctx->header_sent = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1669 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1670 tl = ngx_alloc_chain_link(r->pool); |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1671 if (tl == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1672 return NGX_ERROR; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1673 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1674 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1675 tl->buf = in->buf; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1676 *ll = tl; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1677 ll = &tl->next; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1678 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1679 in = in->next; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1680 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1681 if (in == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1682 tl->next = NULL; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1683 goto out; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1684 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1685 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1686 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1687 size = 0; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1688 cl = in; |
6056
24ccec3c4a87
Proxy: fixed proxy_request_buffering and chunked with preread body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6051
diff
changeset
|
1689 fl = ll; |
6051
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1690 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1691 for ( ;; ) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1692 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
6480 | 1693 "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
|
1694 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1695 size += ngx_buf_size(cl->buf); |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1696 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1697 if (cl->buf->flush |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1698 || cl->buf->sync |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1699 || ngx_buf_in_memory(cl->buf) |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1700 || cl->buf->in_file) |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1701 { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1702 tl = ngx_alloc_chain_link(r->pool); |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1703 if (tl == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1704 return NGX_ERROR; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1705 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1706 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1707 tl->buf = cl->buf; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1708 *ll = tl; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1709 ll = &tl->next; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1710 } |
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 if (cl->next == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1713 break; |
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 cl = cl->next; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1717 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1718 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1719 if (size) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1720 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
|
1721 if (tl == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1722 return NGX_ERROR; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1723 } |
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 b = tl->buf; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1726 chunk = b->start; |
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 if (chunk == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1729 /* the "0000000000000000" is 64-bit hexadecimal string */ |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1730 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1731 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
|
1732 if (chunk == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1733 return NGX_ERROR; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1734 } |
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 b->start = chunk; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1737 b->end = chunk + sizeof("0000000000000000" CRLF) - 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1738 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1739 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1740 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
|
1741 b->memory = 0; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1742 b->temporary = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1743 b->pos = chunk; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1744 b->last = ngx_sprintf(chunk, "%xO" CRLF, size); |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1745 |
6056
24ccec3c4a87
Proxy: fixed proxy_request_buffering and chunked with preread body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6051
diff
changeset
|
1746 tl->next = *fl; |
24ccec3c4a87
Proxy: fixed proxy_request_buffering and chunked with preread body.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6051
diff
changeset
|
1747 *fl = tl; |
6051
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1748 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1749 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1750 if (cl->buf->last_buf) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1751 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
|
1752 if (tl == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1753 return NGX_ERROR; |
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 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1756 b = tl->buf; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1757 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1758 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
|
1759 b->temporary = 0; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1760 b->memory = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1761 b->last_buf = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1762 b->pos = (u_char *) CRLF "0" CRLF CRLF; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1763 b->last = b->pos + 7; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1764 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1765 cl->buf->last_buf = 0; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1766 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1767 *ll = tl; |
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 if (size == 0) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1770 b->pos += 2; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1771 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1772 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1773 } else if (size > 0) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1774 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
|
1775 if (tl == NULL) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1776 return NGX_ERROR; |
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 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1779 b = tl->buf; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1780 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1781 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
|
1782 b->temporary = 0; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1783 b->memory = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1784 b->pos = (u_char *) CRLF; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1785 b->last = b->pos + 2; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1786 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1787 *ll = tl; |
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 } else { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1790 *ll = NULL; |
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 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1793 out: |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1794 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1795 rc = ngx_chain_writer(&r->upstream->writer, out); |
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 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
|
1798 (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
|
1799 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1800 return rc; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1801 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1802 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1803 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
1804 static ngx_int_t |
509 | 1805 ngx_http_proxy_process_status_line(ngx_http_request_t *r) |
1806 { | |
3628 | 1807 size_t len; |
509 | 1808 ngx_int_t rc; |
1809 ngx_http_upstream_t *u; | |
1658 | 1810 ngx_http_proxy_ctx_t *ctx; |
1811 | |
1812 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
1813 | |
1814 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
|
1815 return NGX_ERROR; |
509 | 1816 } |
1817 | |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1818 u = r->upstream; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1819 |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1820 rc = ngx_http_parse_status_line(r, &u->buffer, &ctx->status); |
509 | 1821 |
1822 if (rc == NGX_AGAIN) { | |
1823 return rc; | |
1824 } | |
1825 | |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1826 if (rc == NGX_ERROR) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1827 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1828 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1829 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1830 if (r->cache) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1831 r->http_version = NGX_HTTP_VERSION_9; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1832 return NGX_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1833 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1834 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1835 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1836 |
509 | 1837 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
577 | 1838 "upstream sent no valid HTTP/1.0 header"); |
509 | 1839 |
619 | 1840 #if 0 |
509 | 1841 if (u->accel) { |
1842 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
1843 } | |
619 | 1844 #endif |
509 | 1845 |
1846 r->http_version = NGX_HTTP_VERSION_9; | |
1616 | 1847 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
|
1848 u->headers_in.connection_close = 1; |
577 | 1849 |
509 | 1850 return NGX_OK; |
1851 } | |
1852 | |
5575
d15822784cf9
Upstream: fix $upstream_status variable.
Piotr Sikora <piotr@cloudflare.com>
parents:
5466
diff
changeset
|
1853 if (u->state && u->state->status == 0) { |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1854 u->state->status = ctx->status.code; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1855 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
1856 |
3627
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1857 u->headers_in.status_n = ctx->status.code; |
9061fdb2ed8c
use ngx_http_parse_status_line()
Igor Sysoev <igor@sysoev.ru>
parents:
3615
diff
changeset
|
1858 |
3628 | 1859 len = ctx->status.end - ctx->status.start; |
1860 u->headers_in.status_line.len = len; | |
1861 | |
1862 u->headers_in.status_line.data = ngx_pnalloc(r->pool, len); | |
529 | 1863 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
|
1864 return NGX_ERROR; |
509 | 1865 } |
573 | 1866 |
3628 | 1867 ngx_memcpy(u->headers_in.status_line.data, ctx->status.start, len); |
509 | 1868 |
1869 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1870 "http proxy status %ui \"%V\"", | |
936 | 1871 u->headers_in.status_n, &u->headers_in.status_line); |
509 | 1872 |
4125
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4009
diff
changeset
|
1873 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
|
1874 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
|
1875 } |
e5df04b05e75
Protocol version parsing in ngx_http_parse_status_line().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4009
diff
changeset
|
1876 |
509 | 1877 u->process_header = ngx_http_proxy_process_header; |
1878 | |
1879 return ngx_http_proxy_process_header(r); | |
1880 } | |
1881 | |
1882 | |
1883 static ngx_int_t | |
507 | 1884 ngx_http_proxy_process_header(ngx_http_request_t *r) |
1885 { | |
509 | 1886 ngx_int_t rc; |
1887 ngx_table_elt_t *h; | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1888 ngx_http_upstream_t *u; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1889 ngx_http_proxy_ctx_t *ctx; |
509 | 1890 ngx_http_upstream_header_t *hh; |
1891 ngx_http_upstream_main_conf_t *umcf; | |
1892 | |
1893 umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module); | |
1894 | |
2024 | 1895 for ( ;; ) { |
509 | 1896 |
2256 | 1897 rc = ngx_http_parse_header_line(r, &r->upstream->buffer, 1); |
509 | 1898 |
1899 if (rc == NGX_OK) { | |
1900 | |
1901 /* a header line has been parsed successfully */ | |
507 | 1902 |
509 | 1903 h = ngx_list_push(&r->upstream->headers_in.headers); |
1904 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
|
1905 return NGX_ERROR; |
509 | 1906 } |
1907 | |
1908 h->hash = r->header_hash; | |
1909 | |
1910 h->key.len = r->header_name_end - r->header_name_start; | |
1911 h->value.len = r->header_end - r->header_start; | |
1912 | |
2049 | 1913 h->key.data = ngx_pnalloc(r->pool, |
649 | 1914 h->key.len + 1 + h->value.len + 1 + h->key.len); |
509 | 1915 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
|
1916 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
|
1917 return NGX_ERROR; |
509 | 1918 } |
1919 | |
1920 h->value.data = h->key.data + h->key.len + 1; | |
649 | 1921 h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1; |
507 | 1922 |
4529
1ebec1d15a25
Fixed incorrect ngx_cpystrn() usage in ngx_http_*_process_header().
Maxim Dounin <mdounin@mdounin.ru>
parents:
4499
diff
changeset
|
1923 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
|
1924 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
|
1925 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
|
1926 h->value.data[h->value.len] = '\0'; |
509 | 1927 |
649 | 1928 if (h->key.len == r->lowcase_index) { |
1929 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); | |
1930 | |
1931 } else { | |
2135 | 1932 ngx_strlow(h->lowcase_key, h->key.data, h->key.len); |
509 | 1933 } |
1934 | |
649 | 1935 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash, |
1936 h->lowcase_key, h->key.len); | |
1937 | |
8033
2bf7792c262e
Upstream: header handlers can now return parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8032
diff
changeset
|
1938 if (hh) { |
2bf7792c262e
Upstream: header handlers can now return parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8032
diff
changeset
|
1939 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
|
1940 |
2bf7792c262e
Upstream: header handlers can now return parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8032
diff
changeset
|
1941 if (rc != NGX_OK) { |
2bf7792c262e
Upstream: header handlers can now return parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8032
diff
changeset
|
1942 return rc; |
2bf7792c262e
Upstream: header handlers can now return parsing errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8032
diff
changeset
|
1943 } |
649 | 1944 } |
1945 | |
509 | 1946 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1947 "http proxy header: \"%V: %V\"", | |
1948 &h->key, &h->value); | |
1949 | |
1950 continue; | |
1951 } | |
1952 | |
1953 if (rc == NGX_HTTP_PARSE_HEADER_DONE) { | |
1954 | |
1955 /* a whole header has been parsed successfully */ | |
1956 | |
1957 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1958 "http proxy header done"); | |
1959 | |
649 | 1960 /* |
1961 * if no "Server" and "Date" in header line, | |
1962 * then add the special empty headers | |
1963 */ | |
1964 | |
1965 if (r->upstream->headers_in.server == NULL) { | |
1966 h = ngx_list_push(&r->upstream->headers_in.headers); | |
1967 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
|
1968 return NGX_ERROR; |
649 | 1969 } |
1970 | |
1971 h->hash = ngx_hash(ngx_hash(ngx_hash(ngx_hash( | |
1972 ngx_hash('s', 'e'), 'r'), 'v'), 'e'), 'r'); | |
1973 | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
1974 ngx_str_set(&h->key, "Server"); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
1975 ngx_str_null(&h->value); |
649 | 1976 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
|
1977 h->next = NULL; |
649 | 1978 } |
1979 | |
1980 if (r->upstream->headers_in.date == NULL) { | |
1981 h = ngx_list_push(&r->upstream->headers_in.headers); | |
1982 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
|
1983 return NGX_ERROR; |
649 | 1984 } |
1985 | |
1986 h->hash = ngx_hash(ngx_hash(ngx_hash('d', 'a'), 't'), 'e'); | |
1987 | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
1988 ngx_str_set(&h->key, "Date"); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
1989 ngx_str_null(&h->value); |
649 | 1990 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
|
1991 h->next = NULL; |
649 | 1992 } |
1993 | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1994 /* 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
|
1995 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1996 u = r->upstream; |
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 if (u->headers_in.chunked) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
1999 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
|
2000 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2001 |
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 * 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
|
2004 * 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
|
2005 */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2006 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2007 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
|
2008 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2009 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
|
2010 || 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
|
2011 || ctx->head |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2012 || (!u->headers_in.chunked |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2013 && 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
|
2014 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2015 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
|
2016 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2017 |
5072
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
2018 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
|
2019 u->keepalive = 0; |
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 if (r->headers_in.upgrade) { |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
2022 u->upgrade = 1; |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
2023 } |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
2024 } |
7fa7e60a7f66
Proxy: support for connection upgrade (101 Switching Protocols).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5012
diff
changeset
|
2025 |
509 | 2026 return NGX_OK; |
2027 } | |
2028 | |
521 | 2029 if (rc == NGX_AGAIN) { |
2030 return NGX_AGAIN; | |
2031 } | |
2032 | |
7884
b87b7092cedb
Improved logging of invalid headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
2033 /* rc == NGX_HTTP_PARSE_INVALID_HEADER */ |
b87b7092cedb
Improved logging of invalid headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
2034 |
7933
2f443cac3f1e
Upstream: fixed logging level of upstream invalid header errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7931
diff
changeset
|
2035 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
|
2036 "upstream sent invalid header: \"%*s\\x%02xd...\"", |
b87b7092cedb
Improved logging of invalid headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
2037 r->header_end - r->header_name_start, |
b87b7092cedb
Improved logging of invalid headers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7881
diff
changeset
|
2038 r->header_name_start, *r->header_end); |
509 | 2039 |
2040 return NGX_HTTP_UPSTREAM_INVALID_HEADER; | |
2041 } | |
507 | 2042 } |
2043 | |
2044 | |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2045 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2046 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
|
2047 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2048 ngx_http_request_t *r = data; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2049 ngx_http_upstream_t *u; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2050 ngx_http_proxy_ctx_t *ctx; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2051 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2052 u = r->upstream; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2053 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
|
2054 |
4602
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2055 if (ctx == NULL) { |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2056 return NGX_ERROR; |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2057 } |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2058 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2059 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
6480 | 2060 "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
|
2061 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
|
2062 u->headers_in.content_length_n); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2063 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2064 /* 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
|
2065 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2066 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
|
2067 || 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
|
2068 || ctx->head) |
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 /* 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
|
2071 /* 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
|
2072 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2073 u->pipe->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2074 u->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2075 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
|
2076 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2077 } else if (u->headers_in.chunked) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2078 /* chunked */ |
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->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
|
2081 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
|
2082 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2083 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
|
2084 u->length = 1; |
4126
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 } 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
|
2087 /* 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
|
2088 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2089 u->pipe->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2090 u->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2091 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
|
2092 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2093 } else { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2094 /* content length or connection close */ |
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 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
|
2097 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
|
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 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2101 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2102 |
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 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2105 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
|
2106 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2107 ngx_buf_t *b; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2108 ngx_chain_t *cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2109 ngx_http_request_t *r; |
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 if (buf->pos == buf->last) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2112 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2113 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2114 |
7675
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2115 if (p->upstream_done) { |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2116 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
|
2117 "http proxy data after close"); |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2118 return NGX_OK; |
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 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2121 if (p->length == 0) { |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2122 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2123 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
|
2124 "upstream sent more data than specified in " |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2125 "\"Content-Length\" header"); |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2126 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2127 r = p->input_ctx; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2128 r->upstream->keepalive = 0; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2129 p->upstream_done = 1; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2130 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2131 return NGX_OK; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2132 } |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2133 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2134 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
|
2135 if (cl == NULL) { |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2136 return NGX_ERROR; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2137 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2138 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2139 b = cl->buf; |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2140 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2141 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
|
2142 b->shadow = buf; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2143 b->tag = p->tag; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2144 b->last_shadow = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2145 b->recycled = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2146 buf->shadow = b; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2147 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2148 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
|
2149 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2150 if (p->in) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2151 *p->last_in = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2152 } else { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2153 p->in = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2154 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2155 p->last_in = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2156 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2157 if (p->length == -1) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2158 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2159 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2160 |
7675
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2161 if (b->last - b->pos > p->length) { |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2162 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2163 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
|
2164 "upstream sent more data than specified in " |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2165 "\"Content-Length\" header"); |
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 b->last = b->pos + p->length; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2168 p->upstream_done = 1; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2169 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2170 return NGX_OK; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2171 } |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2172 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2173 p->length -= b->last - b->pos; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2174 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2175 if (p->length == 0) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2176 r = p->input_ctx; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2177 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
|
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 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2181 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2182 |
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 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2185 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
|
2186 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2187 ngx_int_t rc; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2188 ngx_buf_t *b, **prev; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2189 ngx_chain_t *cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2190 ngx_http_request_t *r; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2191 ngx_http_proxy_ctx_t *ctx; |
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 if (buf->pos == buf->last) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2194 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2195 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2196 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2197 r = p->input_ctx; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2198 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
|
2199 |
4602
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2200 if (ctx == NULL) { |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2201 return NGX_ERROR; |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2202 } |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2203 |
7676
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2204 if (p->upstream_done) { |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2205 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
|
2206 "http proxy data after close"); |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2207 return NGX_OK; |
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 |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2210 if (p->length == 0) { |
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 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
|
2213 "upstream sent data after final chunk"); |
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 r->upstream->keepalive = 0; |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2216 p->upstream_done = 1; |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2217 |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2218 return NGX_OK; |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2219 } |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2220 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2221 b = NULL; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2222 prev = &buf->shadow; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2223 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2224 for ( ;; ) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2225 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2226 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
|
2227 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2228 if (rc == NGX_OK) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2229 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2230 /* a chunk has been parsed successfully */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2231 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2232 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
|
2233 if (cl == NULL) { |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2234 return NGX_ERROR; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2235 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2236 |
5466
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2237 b = cl->buf; |
e7b3b9855be8
Use ngx_chain_get_free_buf() in pipe input filters.
Valentin Bartenev <vbart@nginx.com>
parents:
5441
diff
changeset
|
2238 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2239 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
|
2240 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2241 b->pos = buf->pos; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2242 b->start = buf->start; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2243 b->end = buf->end; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2244 b->tag = p->tag; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2245 b->temporary = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2246 b->recycled = 1; |
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 *prev = b; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2249 prev = &b->shadow; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2250 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2251 if (p->in) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2252 *p->last_in = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2253 } else { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2254 p->in = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2255 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2256 p->last_in = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2257 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2258 /* STUB */ b->num = buf->num; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2259 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2260 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
|
2261 "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
|
2262 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2263 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
|
2264 |
5359
2fda9065d0f4
Win32: Borland C compatibility fixes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5301
diff
changeset
|
2265 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
|
2266 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
|
2267 ctx->chunked.size = 0; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2268 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2269 continue; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2270 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2271 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2272 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
|
2273 buf->pos = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2274 b->last = buf->last; |
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 continue; |
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 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2279 if (rc == NGX_DONE) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2280 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2281 /* 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
|
2282 |
7676
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2283 p->length = 0; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2284 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
|
2285 |
7676
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2286 if (buf->pos != buf->last) { |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2287 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
|
2288 "upstream sent data after final chunk"); |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2289 r->upstream->keepalive = 0; |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2290 } |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2291 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2292 break; |
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 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2295 if (rc == NGX_AGAIN) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2296 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2297 /* 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
|
2298 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2299 p->length = ctx->chunked.length; |
4126
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 break; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2302 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2303 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2304 /* invalid response */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2305 |
7677 | 2306 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
|
2307 "upstream sent invalid chunked response"); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2308 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2309 return NGX_ERROR; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2310 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2311 |
7677 | 2312 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, p->log, 0, |
6480 | 2313 "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
|
2314 ctx->chunked.state, p->length); |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2315 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2316 if (b) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2317 b->shadow = buf; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2318 b->last_shadow = 1; |
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 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
|
2321 "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
|
2322 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2323 return NGX_OK; |
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 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2326 /* 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
|
2327 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2328 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
|
2329 return NGX_ERROR; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2330 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2331 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2332 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2333 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2334 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2335 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2336 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2337 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
|
2338 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2339 ngx_http_request_t *r = data; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2340 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2341 ngx_buf_t *b; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2342 ngx_chain_t *cl, **ll; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2343 ngx_http_upstream_t *u; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2344 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2345 u = r->upstream; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2346 |
7760
83c4622053b0
Upstream: fixed zero size buf alerts on extra data (ticket #2117).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7730
diff
changeset
|
2347 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
|
2348 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
|
2349 "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
|
2350 "\"Content-Length\" header"); |
7931
055b2a847117
Proxy: disabled keepalive on extra data in non-buffered mode.
Awdhesh Mathpal <mathpal@amazon.com>
parents:
7904
diff
changeset
|
2351 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
|
2352 return NGX_OK; |
83c4622053b0
Upstream: fixed zero size buf alerts on extra data (ticket #2117).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7730
diff
changeset
|
2353 } |
83c4622053b0
Upstream: fixed zero size buf alerts on extra data (ticket #2117).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7730
diff
changeset
|
2354 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2355 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
|
2356 ll = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2357 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2358 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2359 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
|
2360 if (cl == NULL) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2361 return NGX_ERROR; |
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 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2364 *ll = cl; |
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 cl->buf->flush = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2367 cl->buf->memory = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2368 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2369 b = &u->buffer; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2370 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2371 cl->buf->pos = b->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2372 b->last += bytes; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2373 cl->buf->last = b->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2374 cl->buf->tag = u->output.tag; |
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 if (u->length == -1) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2377 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2378 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2379 |
7675
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2380 if (bytes > u->length) { |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2381 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2382 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
|
2383 "upstream sent more data than specified in " |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2384 "\"Content-Length\" header"); |
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 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
|
2387 u->length = 0; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2388 |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2389 return NGX_OK; |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2390 } |
9afa45068b8f
Proxy: drop extra data sent by upstream.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7473
diff
changeset
|
2391 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2392 u->length -= bytes; |
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 if (u->length == 0) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2395 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
|
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 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2399 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2400 |
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 static ngx_int_t |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2403 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
|
2404 { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2405 ngx_http_request_t *r = data; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2406 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2407 ngx_int_t rc; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2408 ngx_buf_t *b, *buf; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2409 ngx_chain_t *cl, **ll; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2410 ngx_http_upstream_t *u; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2411 ngx_http_proxy_ctx_t *ctx; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2412 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2413 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
|
2414 |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2415 if (ctx == NULL) { |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2416 return NGX_ERROR; |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2417 } |
8036fc6af2df
Proxy: added ctx checking to input filters.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4593
diff
changeset
|
2418 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2419 u = r->upstream; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2420 buf = &u->buffer; |
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 buf->pos = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2423 buf->last += bytes; |
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 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
|
2426 ll = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2427 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2428 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2429 for ( ;; ) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2430 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2431 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
|
2432 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2433 if (rc == NGX_OK) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2434 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2435 /* a chunk has been parsed successfully */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2436 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2437 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
|
2438 if (cl == NULL) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2439 return NGX_ERROR; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2440 } |
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 *ll = cl; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2443 ll = &cl->next; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2444 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2445 b = cl->buf; |
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->flush = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2448 b->memory = 1; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2449 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2450 b->pos = buf->pos; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2451 b->tag = u->output.tag; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2452 |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2453 if (buf->last - buf->pos >= ctx->chunked.size) { |
5359
2fda9065d0f4
Win32: Borland C compatibility fixes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5301
diff
changeset
|
2454 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
|
2455 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
|
2456 ctx->chunked.size = 0; |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2457 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2458 } else { |
4925
32030fa8cb14
Request body: chunked parsing moved to ngx_http_parse.c from proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4602
diff
changeset
|
2459 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
|
2460 buf->pos = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2461 b->last = buf->last; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2462 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2463 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2464 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
|
2465 "http proxy out buf %p %z", |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2466 b->pos, b->last - b->pos); |
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 continue; |
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 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2471 if (rc == NGX_DONE) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2472 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2473 /* 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
|
2474 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2475 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
|
2476 u->length = 0; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2477 |
7676
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2478 if (buf->pos != buf->last) { |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2479 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
|
2480 "upstream sent data after final chunk"); |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2481 u->keepalive = 0; |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2482 } |
d225b70d38b6
Proxy: detection of data after final chunk.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7675
diff
changeset
|
2483 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2484 break; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2485 } |
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 if (rc == NGX_AGAIN) { |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2488 break; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2489 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2490 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2491 /* invalid response */ |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2492 |
4145
f321e9750c8c
Proxy: logging levels tuned, double logging fixed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4144
diff
changeset
|
2493 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
|
2494 "upstream sent invalid chunked response"); |
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_ERROR; |
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 return NGX_OK; |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2500 } |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2501 |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
2502 |
507 | 2503 static void |
2504 ngx_http_proxy_abort_request(ngx_http_request_t *r) | |
2505 { | |
2506 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2507 "abort http proxy request"); | |
577 | 2508 |
507 | 2509 return; |
2510 } | |
2511 | |
2512 | |
2513 static void | |
2514 ngx_http_proxy_finalize_request(ngx_http_request_t *r, ngx_int_t rc) | |
577 | 2515 { |
507 | 2516 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2517 "finalize http proxy request"); | |
2518 | |
2519 return; | |
2520 } | |
2521 | |
2522 | |
573 | 2523 static ngx_int_t |
2524 ngx_http_proxy_host_variable(ngx_http_request_t *r, | |
2525 ngx_http_variable_value_t *v, uintptr_t data) | |
507 | 2526 { |
1658 | 2527 ngx_http_proxy_ctx_t *ctx; |
2528 | |
2529 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
2530 | |
2531 if (ctx == NULL) { | |
2532 v->not_found = 1; | |
2533 return NGX_OK; | |
2534 } | |
2535 | |
2536 v->len = ctx->vars.host_header.len; | |
577 | 2537 v->valid = 1; |
1565 | 2538 v->no_cacheable = 0; |
573 | 2539 v->not_found = 0; |
1658 | 2540 v->data = ctx->vars.host_header.data; |
507 | 2541 |
573 | 2542 return NGX_OK; |
507 | 2543 } |
2544 | |
2545 | |
573 | 2546 static ngx_int_t |
2547 ngx_http_proxy_port_variable(ngx_http_request_t *r, | |
2548 ngx_http_variable_value_t *v, uintptr_t data) | |
507 | 2549 { |
1658 | 2550 ngx_http_proxy_ctx_t *ctx; |
2551 | |
2552 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
2553 | |
2554 if (ctx == NULL) { | |
2555 v->not_found = 1; | |
2556 return NGX_OK; | |
2557 } | |
2558 | |
2559 v->len = ctx->vars.port.len; | |
577 | 2560 v->valid = 1; |
1565 | 2561 v->no_cacheable = 0; |
573 | 2562 v->not_found = 0; |
1658 | 2563 v->data = ctx->vars.port.data; |
509 | 2564 |
573 | 2565 return NGX_OK; |
509 | 2566 } |
2567 | |
2568 | |
573 | 2569 static ngx_int_t |
509 | 2570 ngx_http_proxy_add_x_forwarded_for_variable(ngx_http_request_t *r, |
573 | 2571 ngx_http_variable_value_t *v, uintptr_t data) |
509 | 2572 { |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2573 size_t len; |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2574 u_char *p; |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2575 ngx_table_elt_t *h, *xfwd; |
509 | 2576 |
577 | 2577 v->valid = 1; |
1565 | 2578 v->no_cacheable = 0; |
573 | 2579 v->not_found = 0; |
509 | 2580 |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2581 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
|
2582 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2583 len = 0; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2584 |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2585 for (h = xfwd; h; h = h->next) { |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2586 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
|
2587 } |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2588 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2589 if (len == 0) { |
573 | 2590 v->len = r->connection->addr_text.len; |
2591 v->data = r->connection->addr_text.data; | |
2592 return NGX_OK; | |
509 | 2593 } |
2594 | |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2595 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
|
2596 |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2597 p = ngx_pnalloc(r->pool, len); |
509 | 2598 if (p == NULL) { |
573 | 2599 return NGX_ERROR; |
509 | 2600 } |
2601 | |
5084
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2602 v->len = len; |
573 | 2603 v->data = p; |
509 | 2604 |
8024
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2605 for (h = xfwd; h; h = h->next) { |
ef6a3a99a81a
Reworked multi headers to use linked lists.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7933
diff
changeset
|
2606 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
|
2607 *p++ = ','; *p++ = ' '; |
f7fe817c92a2
Correctly handle multiple X-Forwarded-For headers (ticket #106).
Ruslan Ermilov <ru@nginx.com>
parents:
5072
diff
changeset
|
2608 } |
509 | 2609 |
2610 ngx_memcpy(p, r->connection->addr_text.data, r->connection->addr_text.len); | |
2611 | |
573 | 2612 return NGX_OK; |
509 | 2613 } |
2614 | |
2615 | |
2616 static ngx_int_t | |
577 | 2617 ngx_http_proxy_internal_body_length_variable(ngx_http_request_t *r, |
2618 ngx_http_variable_value_t *v, uintptr_t data) | |
2619 { | |
1658 | 2620 ngx_http_proxy_ctx_t *ctx; |
2621 | |
2622 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | |
2623 | |
4927
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
2624 if (ctx == NULL || ctx->internal_body_length < 0) { |
577 | 2625 v->not_found = 1; |
2626 return NGX_OK; | |
2627 } | |
2628 | |
2629 v->valid = 1; | |
1565 | 2630 v->no_cacheable = 0; |
577 | 2631 v->not_found = 0; |
2632 | |
5188
886800caf360
Proxy: allocate $proxy_internal_body_length from request pool.
Ruslan Ermilov <ru@nginx.com>
parents:
5084
diff
changeset
|
2633 v->data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN); |
577 | 2634 |
2635 if (v->data == NULL) { | |
2636 return NGX_ERROR; | |
2637 } | |
2638 | |
4927
93294110728f
Request body: always use calculated size of a request body in proxy.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4925
diff
changeset
|
2639 v->len = ngx_sprintf(v->data, "%O", ctx->internal_body_length) - v->data; |
577 | 2640 |
2641 return NGX_OK; | |
2642 } | |
2643 | |
2644 | |
2645 static ngx_int_t | |
6051
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2646 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
|
2647 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
|
2648 { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2649 ngx_http_proxy_ctx_t *ctx; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2650 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2651 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
|
2652 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2653 if (ctx == NULL || !ctx->internal_chunked) { |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2654 v->not_found = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2655 return NGX_OK; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2656 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2657 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2658 v->valid = 1; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2659 v->no_cacheable = 0; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2660 v->not_found = 0; |
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 v->data = (u_char *) "chunked"; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2663 v->len = sizeof("chunked") - 1; |
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 return NGX_OK; |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2666 } |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2667 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2668 |
d97e6be2d292
Proxy: proxy_request_buffering chunked support.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6050
diff
changeset
|
2669 static ngx_int_t |
509 | 2670 ngx_http_proxy_rewrite_redirect(ngx_http_request_t *r, ngx_table_elt_t *h, |
2671 size_t prefix) | |
2672 { | |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2673 size_t len; |
509 | 2674 ngx_int_t rc; |
2675 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
|
2676 ngx_http_proxy_rewrite_t *pr; |
509 | 2677 ngx_http_proxy_loc_conf_t *plcf; |
2678 | |
2679 plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module); | |
2680 | |
2681 pr = plcf->redirects->elts; | |
2682 | |
2683 if (pr == NULL) { | |
2684 return NGX_DECLINED; | |
2685 } | |
2686 | |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
2687 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
|
2688 |
509 | 2689 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
|
2690 rc = pr[i].handler(r, &h->value, prefix, len, &pr[i]); |
509 | 2691 |
2692 if (rc != NGX_DECLINED) { | |
2693 return rc; | |
2694 } | |
2695 } | |
2696 | |
2697 return NGX_DECLINED; | |
2698 } | |
2699 | |
2700 | |
2701 static ngx_int_t | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2702 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
|
2703 { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2704 u_char *p; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2705 size_t len; |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2706 ngx_int_t rc, rv; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2707 ngx_str_t *key, *value; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2708 ngx_uint_t i; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2709 ngx_array_t attrs; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2710 ngx_keyval_t *attr; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2711 ngx_http_proxy_loc_conf_t *plcf; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2712 |
7720
a88384c69d1e
Proxy: error checking for array init, missed in 7716:d6a5e14aa3e4.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7716
diff
changeset
|
2713 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
|
2714 return NGX_ERROR; |
a88384c69d1e
Proxy: error checking for array init, missed in 7716:d6a5e14aa3e4.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7716
diff
changeset
|
2715 } |
7716
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 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
|
2718 return NGX_ERROR; |
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 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2721 attr = attrs.elts; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2722 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2723 if (attr[0].value.data == NULL) { |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2724 return NGX_DECLINED; |
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 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2727 rv = NGX_DECLINED; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2728 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2729 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
|
2730 |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2731 for (i = 1; i < attrs.nelts; i++) { |
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 key = &attr[i].key; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2734 value = &attr[i].value; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2735 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2736 if (plcf->cookie_domains && key->len == 6 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2737 && 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
|
2738 && value->data) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2739 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2740 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
|
2741 plcf->cookie_domains); |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2742 if (rc == NGX_ERROR) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2743 return NGX_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2744 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2745 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2746 if (rc != NGX_DECLINED) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2747 rv = rc; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2748 } |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2749 } |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2750 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2751 if (plcf->cookie_paths && key->len == 4 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2752 && 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
|
2753 && value->data) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2754 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2755 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
|
2756 plcf->cookie_paths); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2757 if (rc == NGX_ERROR) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2758 return NGX_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2759 } |
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 if (rc != NGX_DECLINED) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2762 rv = rc; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2763 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2764 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2765 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
2766 |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2767 if (plcf->cookie_flags) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2768 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
|
2769 plcf->cookie_flags); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2770 if (rc == NGX_ERROR) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2771 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2772 } |
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 if (rc != NGX_DECLINED) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2775 rv = rc; |
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 attr = attrs.elts; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2779 } |
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 if (rv != NGX_OK) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2782 return rv; |
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 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2785 len = 0; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2786 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2787 for (i = 0; i < attrs.nelts; i++) { |
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 if (attr[i].key.data == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2790 continue; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2791 } |
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 if (i > 0) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2794 len += 2; |
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 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2797 len += attr[i].key.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 if (attr[i].value.data) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2800 len += 1 + attr[i].value.len; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2801 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2802 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2803 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2804 p = ngx_pnalloc(r->pool, len + 1); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2805 if (p == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2806 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2807 } |
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 h->value.data = p; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2810 h->value.len = len; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2811 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2812 for (i = 0; i < attrs.nelts; i++) { |
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 if (attr[i].key.data == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2815 continue; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2816 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2817 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2818 if (i > 0) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2819 *p++ = ';'; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2820 *p++ = ' '; |
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 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2823 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
|
2824 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2825 if (attr[i].value.data) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2826 *p++ = '='; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2827 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
|
2828 } |
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 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2831 *p = '\0'; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2832 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2833 return NGX_OK; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2834 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2835 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2836 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2837 static ngx_int_t |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2838 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
|
2839 { |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2840 u_char *start, *end, *p, *last; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2841 ngx_str_t name, val; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2842 ngx_keyval_t *attr; |
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 start = value->data; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2845 end = value->data + value->len; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2846 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2847 for ( ;; ) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2848 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2849 last = (u_char *) ngx_strchr(start, ';'); |
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 if (last == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2852 last = end; |
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 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2855 while (start < last && *start == ' ') { start++; } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2856 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2857 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
|
2858 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2859 name.data = start; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2860 name.len = p - start; |
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 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
|
2863 name.len--; |
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 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2866 if (p < last) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2867 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2868 p++; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2869 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2870 while (p < last && *p == ' ') { p++; } |
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 val.data = p; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2873 val.len = last - val.data; |
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 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
|
2876 val.len--; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2877 } |
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 } else { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2880 ngx_str_null(&val); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2881 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2882 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2883 attr = ngx_array_push(attrs); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2884 if (attr == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2885 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2886 } |
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 attr->key = name; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2889 attr->value = val; |
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 if (last == end) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2892 break; |
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 start = last + 1; |
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 return NGX_OK; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2899 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2900 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2901 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2902 static ngx_int_t |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2903 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
|
2904 ngx_array_t *rewrites) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2905 { |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2906 ngx_int_t rc; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2907 ngx_uint_t i; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2908 ngx_http_proxy_rewrite_t *pr; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2909 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2910 pr = rewrites->elts; |
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 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
|
2913 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
|
2914 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2915 if (rc != NGX_DECLINED) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2916 return rc; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2917 } |
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 return NGX_DECLINED; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2921 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2922 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2923 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
2924 static ngx_int_t |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2925 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
|
2926 ngx_array_t *flags) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2927 { |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2928 ngx_str_t pattern, value; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2929 #if (NGX_PCRE) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2930 ngx_int_t rc; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2931 #endif |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2932 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
|
2933 ngx_keyval_t *attr; |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2934 ngx_conf_bitmask_t *mask; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2935 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
|
2936 ngx_http_proxy_cookie_flags_t *pcf; |
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 attr = attrs->elts; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2939 pcf = flags->elts; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2940 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2941 for (i = 0; i < flags->nelts; i++) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2942 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2943 #if (NGX_PCRE) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2944 if (pcf[i].regex) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2945 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
|
2946 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2947 if (rc == NGX_ERROR) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2948 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2949 } |
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 if (rc == NGX_OK) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2952 break; |
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 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2955 /* NGX_DECLINED */ |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2956 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2957 continue; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2958 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2959 #endif |
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 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
|
2962 != NGX_OK) |
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 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2965 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2966 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2967 if (pattern.len == attr[0].key.len |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2968 && 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
|
2969 == 0) |
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 break; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2972 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2973 } |
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 if (i == flags->nelts) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2976 return NGX_DECLINED; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2977 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
2978 |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2979 nelts = pcf[i].flags_values.nelts; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2980 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
|
2981 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2982 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
|
2983 f = 0; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2984 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2985 for (i = 0; i < nelts; i++) { |
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 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
|
2988 return NGX_ERROR; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2989 } |
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 if (value.len == 0) { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2992 continue; |
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 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2995 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
|
2996 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
2997 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
|
2998 || 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
|
2999 != 0) |
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 continue; |
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 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3004 f |= mask[m].mask; |
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 break; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3007 } |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3008 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3009 if (mask[m].name.len == 0) { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3010 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
|
3011 "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
|
3012 } |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3013 } |
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 if (f == 0) { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3016 return NGX_DECLINED; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3017 } |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3018 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
3019 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
|
3020 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3021 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3022 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3023 static ngx_int_t |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3024 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
|
3025 ngx_uint_t flags) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3026 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3027 ngx_str_t *key, *value; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3028 ngx_uint_t i; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3029 ngx_keyval_t *attr; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3030 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3031 attr = attrs->elts; |
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 for (i = 1; i < attrs->nelts; i++) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3034 key = &attr[i].key; |
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 (key->len == 6 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3037 && 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
|
3038 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3039 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
|
3040 flags &= ~NGX_HTTP_PROXY_COOKIE_SECURE_ON; |
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 } 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
|
3043 key->data = NULL; |
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 continue; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3047 } |
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 (key->len == 8 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3050 && 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
|
3051 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3052 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
|
3053 flags &= ~NGX_HTTP_PROXY_COOKIE_HTTPONLY_ON; |
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 } 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
|
3056 key->data = NULL; |
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 continue; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3060 } |
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 if (key->len == 8 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3063 && 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
|
3064 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3065 value = &attr[i].value; |
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 (flags & NGX_HTTP_PROXY_COOKIE_SAMESITE_STRICT) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3068 flags &= ~NGX_HTTP_PROXY_COOKIE_SAMESITE_STRICT; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3069 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3070 if (value->len != 6 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3071 || 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
|
3072 != 0) |
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 ngx_str_set(key, "SameSite"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3075 ngx_str_set(value, "Strict"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3076 } |
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 } 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
|
3079 flags &= ~NGX_HTTP_PROXY_COOKIE_SAMESITE_LAX; |
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 if (value->len != 3 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3082 || 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
|
3083 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3084 ngx_str_set(key, "SameSite"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3085 ngx_str_set(value, "Lax"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3086 } |
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 } 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
|
3089 flags &= ~NGX_HTTP_PROXY_COOKIE_SAMESITE_NONE; |
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 if (value->len != 4 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3092 || 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
|
3093 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3094 ngx_str_set(key, "SameSite"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3095 ngx_str_set(value, "None"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3096 } |
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 } 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
|
3099 key->data = NULL; |
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 continue; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3103 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3104 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3105 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3106 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
|
3107 attr = ngx_array_push(attrs); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3108 if (attr == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3109 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3110 } |
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 ngx_str_set(&attr->key, "Secure"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3113 ngx_str_null(&attr->value); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3114 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3115 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3116 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
|
3117 attr = ngx_array_push(attrs); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3118 if (attr == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3119 return NGX_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3120 } |
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 ngx_str_set(&attr->key, "HttpOnly"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3123 ngx_str_null(&attr->value); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3124 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3125 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3126 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
|
3127 |NGX_HTTP_PROXY_COOKIE_SAMESITE_LAX |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3128 |NGX_HTTP_PROXY_COOKIE_SAMESITE_NONE)) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3129 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3130 attr = ngx_array_push(attrs); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3131 if (attr == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3132 return NGX_ERROR; |
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 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3135 ngx_str_set(&attr->key, "SameSite"); |
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 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
|
3138 ngx_str_set(&attr->value, "Strict"); |
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 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
|
3141 ngx_str_set(&attr->value, "Lax"); |
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 } else { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3144 ngx_str_set(&attr->value, "None"); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3145 } |
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 return NGX_OK; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3149 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3150 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3151 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3152 static ngx_int_t |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3153 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
|
3154 size_t prefix, size_t len, ngx_http_proxy_rewrite_t *pr) |
509 | 3155 { |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3156 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
|
3157 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3158 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
|
3159 return NGX_ERROR; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3160 } |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3161 |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3162 if (pattern.len > len |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3163 || ngx_rstrncmp(value->data + prefix, pattern.data, pattern.len) != 0) |
509 | 3164 { |
3165 return NGX_DECLINED; | |
3166 } | |
3167 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3168 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
|
3169 return NGX_ERROR; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3170 } |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3171 |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3172 return ngx_http_proxy_rewrite(r, value, prefix, pattern.len, &replacement); |
509 | 3173 } |
3174 | |
3175 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3176 #if (NGX_PCRE) |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3177 |
509 | 3178 static ngx_int_t |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3179 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
|
3180 size_t prefix, size_t len, ngx_http_proxy_rewrite_t *pr) |
509 | 3181 { |
4462
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3182 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
|
3183 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3184 pattern.len = len; |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3185 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
|
3186 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3187 if (ngx_http_regex_exec(r, pr->pattern.regex, &pattern) != NGX_OK) { |
509 | 3188 return NGX_DECLINED; |
3189 } | |
3190 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3191 if (ngx_http_complex_value(r, &pr->replacement, &replacement) != NGX_OK) { |
509 | 3192 return NGX_ERROR; |
3193 } | |
3194 | |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3195 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
|
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 #endif |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3199 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3200 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3201 static ngx_int_t |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3202 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
|
3203 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
|
3204 { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3205 u_char *p; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3206 ngx_str_t pattern, replacement; |
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 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
|
3209 return NGX_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3210 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3211 |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3212 p = value->data + prefix; |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3213 |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3214 if (len && p[0] == '.') { |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3215 p++; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3216 prefix++; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3217 len--; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3218 } |
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 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
|
3221 return NGX_DECLINED; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3222 } |
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 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
|
3225 return NGX_ERROR; |
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 |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3228 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
|
3229 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3230 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3231 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3232 static ngx_int_t |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3233 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
|
3234 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
|
3235 { |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3236 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
|
3237 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
|
3238 |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3239 if (len == value->len) { |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3240 *value = *replacement; |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3241 return NGX_OK; |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3242 } |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3243 |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3244 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
|
3245 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3246 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
|
3247 |
5676
fbfdf8017748
Proxy: fixed possible uninitialized memory access.
Valentin Bartenev <vbart@nginx.com>
parents:
5661
diff
changeset
|
3248 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
|
3249 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
|
3250 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
|
3251 } |
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 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
|
3254 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
|
3255 |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3256 ngx_memcpy(p, value->data + prefix + len, |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3257 value->len - len - prefix + 1); |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3258 |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3259 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
|
3260 |
a73c63bdce32
Proxy: generic rewrite code from the "proxy_redirect" handlers moved to a
Valentin Bartenev <vbart@nginx.com>
parents:
4461
diff
changeset
|
3261 } else { |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3262 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
|
3263 |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3264 ngx_memmove(p, value->data + prefix + len, |
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3265 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
|
3266 } |
3d51ba7f347b
Fixed: proxy_redirect with regex might broke Refresh header.
Valentin Bartenev <vbart@nginx.com>
parents:
4385
diff
changeset
|
3267 |
7715
5c7917292b29
Proxy: changed interface of some internal functions.
Ruslan Ermilov <ru@nginx.com>
parents:
7714
diff
changeset
|
3268 value->len = new_len; |
509 | 3269 |
3270 return NGX_OK; | |
3271 } | |
3272 | |
3273 | |
3274 static ngx_int_t | |
3275 ngx_http_proxy_add_variables(ngx_conf_t *cf) | |
3276 { | |
3277 ngx_http_variable_t *var, *v; | |
3278 | |
3279 for (v = ngx_http_proxy_vars; v->name.len; v++) { | |
3280 var = ngx_http_add_variable(cf, &v->name, v->flags); | |
3281 if (var == NULL) { | |
3282 return NGX_ERROR; | |
3283 } | |
3284 | |
637 | 3285 var->get_handler = v->get_handler; |
509 | 3286 var->data = v->data; |
3287 } | |
3288 | |
3289 return NGX_OK; | |
507 | 3290 } |
3291 | |
3292 | |
3293 static void * | |
5951
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3294 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
|
3295 { |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3296 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
|
3297 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3298 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
|
3299 if (conf == NULL) { |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3300 return NULL; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3301 } |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3302 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3303 #if (NGX_HTTP_CACHE) |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3304 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
|
3305 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
|
3306 != NGX_OK) |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3307 { |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3308 return NULL; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3309 } |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3310 #endif |
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 return conf; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3313 } |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3314 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3315 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
3316 static void * |
507 | 3317 ngx_http_proxy_create_loc_conf(ngx_conf_t *cf) |
3318 { | |
3319 ngx_http_proxy_loc_conf_t *conf; | |
3320 | |
3321 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_proxy_loc_conf_t)); | |
3322 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
|
3323 return NULL; |
507 | 3324 } |
3325 | |
3326 /* | |
3327 * set by ngx_pcalloc(): | |
3328 * | |
3329 * conf->upstream.bufs.num = 0; | |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
3330 * conf->upstream.ignore_headers = 0; |
507 | 3331 * conf->upstream.next_upstream = 0; |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3332 * conf->upstream.cache_zone = NULL; |
2875
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
3333 * conf->upstream.cache_use_stale = 0; |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
3334 * conf->upstream.cache_methods = 0; |
507 | 3335 * conf->upstream.temp_path = NULL; |
649 | 3336 * 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
|
3337 * conf->upstream.store_lengths = NULL; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3338 * conf->upstream.store_values = NULL; |
509 | 3339 * |
7238
06cf0c4b8618
Upstream: fixed comments after 13f8dec720b5.
Ruslan Ermilov <ru@nginx.com>
parents:
7220
diff
changeset
|
3340 * conf->location = NULL; |
06cf0c4b8618
Upstream: fixed comments after 13f8dec720b5.
Ruslan Ermilov <ru@nginx.com>
parents:
7220
diff
changeset
|
3341 * conf->url = { 0, NULL }; |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3342 * conf->headers.lengths = NULL; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3343 * conf->headers.values = NULL; |
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3344 * 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
|
3345 * conf->headers_cache.lengths = NULL; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3346 * conf->headers_cache.values = NULL; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3347 * 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
|
3348 * conf->body_lengths = NULL; |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3349 * conf->body_values = NULL; |
577 | 3350 * conf->body_source = { 0, NULL }; |
3470
b982f2dee8cf
fix proxy_redirect name in error message
Igor Sysoev <igor@sysoev.ru>
parents:
3399
diff
changeset
|
3351 * conf->redirects = NULL; |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3352 * conf->ssl = 0; |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3353 * conf->ssl_protocols = 0; |
5390
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
3354 * conf->ssl_ciphers = { 0, NULL }; |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3355 * conf->ssl_trusted_certificate = { 0, NULL }; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3356 * conf->ssl_crl = { 0, NULL }; |
507 | 3357 */ |
577 | 3358 |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3359 conf->upstream.store = NGX_CONF_UNSET; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3360 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
|
3361 conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT; |
581 | 3362 conf->upstream.buffering = NGX_CONF_UNSET; |
6050
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
3363 conf->upstream.request_buffering = NGX_CONF_UNSET; |
629 | 3364 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
|
3365 conf->upstream.force_ranges = NGX_CONF_UNSET; |
581 | 3366 |
5008
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4962
diff
changeset
|
3367 conf->upstream.local = NGX_CONF_UNSET_PTR; |
7371
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
3368 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
|
3369 |
507 | 3370 conf->upstream.connect_timeout = NGX_CONF_UNSET_MSEC; |
3371 conf->upstream.send_timeout = NGX_CONF_UNSET_MSEC; | |
3372 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
|
3373 conf->upstream.next_upstream_timeout = NGX_CONF_UNSET_MSEC; |
507 | 3374 |
3375 conf->upstream.send_lowat = NGX_CONF_UNSET_SIZE; | |
581 | 3376 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
|
3377 conf->upstream.limit_rate = NGX_CONF_UNSET_SIZE; |
529 | 3378 |
3379 conf->upstream.busy_buffers_size_conf = NGX_CONF_UNSET_SIZE; | |
577 | 3380 conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; |
529 | 3381 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; |
509 | 3382 |
3383 conf->upstream.pass_request_headers = NGX_CONF_UNSET; | |
3384 conf->upstream.pass_request_body = NGX_CONF_UNSET; | |
561 | 3385 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3386 #if (NGX_HTTP_CACHE) |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3387 conf->upstream.cache = NGX_CONF_UNSET; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3388 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
|
3389 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
|
3390 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
|
3391 conf->upstream.no_cache = NGX_CONF_UNSET_PTR; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3392 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; |
4385
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3393 conf->upstream.cache_lock = NGX_CONF_UNSET; |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3394 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
|
3395 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
|
3396 conf->upstream.cache_revalidate = NGX_CONF_UNSET; |
6290
4d5ac1a31d44
Upstream: proxy_cache_convert_head directive.
Roman Arutyunyan <arut@nginx.com>
parents:
6157
diff
changeset
|
3397 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
|
3398 conf->upstream.cache_background_update = NGX_CONF_UNSET; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3399 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3400 |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
3401 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
|
3402 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
|
3403 |
657 | 3404 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
|
3405 |
2184 | 3406 #if (NGX_HTTP_SSL) |
3407 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
|
3408 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
|
3409 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
|
3410 conf->upstream.ssl_verify = NGX_CONF_UNSET; |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3411 conf->upstream.ssl_certificate = NGX_CONF_UNSET_PTR; |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3412 conf->upstream.ssl_certificate_key = NGX_CONF_UNSET_PTR; |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3413 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
|
3414 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
|
3415 conf->ssl_conf_commands = NGX_CONF_UNSET_PTR; |
2184 | 3416 #endif |
507 | 3417 |
3418 /* "proxy_cyclic_temp_file" is disabled */ | |
3419 conf->upstream.cyclic_temp_file = 0; | |
3420 | |
7831
bdd4d89370a7
Changed complex value slots to use NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7787
diff
changeset
|
3421 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
|
3422 |
7728
485dba3e2a01
Core: ngx_conf_set_keyval_slot() now accepts NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7720
diff
changeset
|
3423 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
|
3424 |
7831
bdd4d89370a7
Changed complex value slots to use NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7787
diff
changeset
|
3425 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
|
3426 |
509 | 3427 conf->redirect = NGX_CONF_UNSET; |
507 | 3428 |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3429 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
|
3430 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
|
3431 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
|
3432 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
3433 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
|
3434 |
1180
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
3435 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
|
3436 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
|
3437 |
3976
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3862
diff
changeset
|
3438 ngx_str_set(&conf->upstream.module, "proxy"); |
215fe9223419
update r3945 with more descriptive error message
Igor Sysoev <igor@sysoev.ru>
parents:
3862
diff
changeset
|
3439 |
507 | 3440 return conf; |
3441 } | |
3442 | |
3443 | |
3444 static char * | |
3445 ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
3446 { | |
3447 ngx_http_proxy_loc_conf_t *prev = parent; | |
3448 ngx_http_proxy_loc_conf_t *conf = child; | |
3449 | |
3862
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3450 u_char *p; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3451 size_t size; |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3452 ngx_int_t rc; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3453 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
|
3454 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
|
3455 ngx_http_proxy_rewrite_t *pr; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3456 ngx_http_script_compile_t sc; |
509 | 3457 |
5948
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3458 #if (NGX_HTTP_CACHE) |
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 if (conf->upstream.store > 0) { |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3461 conf->upstream.cache = 0; |
5948
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3462 } |
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3463 |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3464 if (conf->upstream.cache > 0) { |
5948
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3465 conf->upstream.store = 0; |
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3466 } |
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3467 |
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3468 #endif |
f2ff0aa89126
Upstream: mutually exclusive inheritance of "cache" and "store".
Valentin Bartenev <vbart@nginx.com>
parents:
5947
diff
changeset
|
3469 |
5940
e3b3b89d74e8
Upstream: fixed inheritance of proxy_store and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5939
diff
changeset
|
3470 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
|
3471 ngx_conf_merge_value(conf->upstream.store, |
2894 | 3472 prev->upstream.store, 0); |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3473 |
5947
d9025ea1f5a5
Upstream: simplified proxy_store and friends configuration code.
Valentin Bartenev <vbart@nginx.com>
parents:
5940
diff
changeset
|
3474 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
|
3475 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
|
3476 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3477 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
3478 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
|
3479 prev->upstream.store_access, 0600); |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1244
diff
changeset
|
3480 |
5832
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
3481 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
|
3482 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
|
3483 |
581 | 3484 ngx_conf_merge_value(conf->upstream.buffering, |
3485 prev->upstream.buffering, 1); | |
3486 | |
6050
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
3487 ngx_conf_merge_value(conf->upstream.request_buffering, |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
3488 prev->upstream.request_buffering, 1); |
a08fad30aeac
Request body: unbuffered reading.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6043
diff
changeset
|
3489 |
629 | 3490 ngx_conf_merge_value(conf->upstream.ignore_client_abort, |
3491 prev->upstream.ignore_client_abort, 0); | |
3492 | |
5874
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
3493 ngx_conf_merge_value(conf->upstream.force_ranges, |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
3494 prev->upstream.force_ranges, 0); |
2aff40b3dea2
Upstream: proxy_force_ranges and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5832
diff
changeset
|
3495 |
5008
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4962
diff
changeset
|
3496 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
|
3497 prev->upstream.local, NULL); |
fd84344f1df7
Fixed and improved the "*_bind" directives of proxying modules.
Ruslan Ermilov <ru@nginx.com>
parents:
4962
diff
changeset
|
3498 |
7371
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
3499 ngx_conf_merge_value(conf->upstream.socket_keepalive, |
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
3500 prev->upstream.socket_keepalive, 0); |
8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
Vladimir Homutov <vl@nginx.com>
parents:
7321
diff
changeset
|
3501 |
507 | 3502 ngx_conf_merge_msec_value(conf->upstream.connect_timeout, |
3503 prev->upstream.connect_timeout, 60000); | |
3504 | |
3505 ngx_conf_merge_msec_value(conf->upstream.send_timeout, | |
3506 prev->upstream.send_timeout, 60000); | |
3507 | |
3508 ngx_conf_merge_msec_value(conf->upstream.read_timeout, | |
3509 prev->upstream.read_timeout, 60000); | |
3510 | |
5832
d09b689911ac
Upstream: limited next_upstream time and tries (ticket #544).
Roman Arutyunyan <arut@nginx.com>
parents:
5738
diff
changeset
|
3511 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
|
3512 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
|
3513 |
507 | 3514 ngx_conf_merge_size_value(conf->upstream.send_lowat, |
3515 prev->upstream.send_lowat, 0); | |
3516 | |
581 | 3517 ngx_conf_merge_size_value(conf->upstream.buffer_size, |
3518 prev->upstream.buffer_size, | |
507 | 3519 (size_t) ngx_pagesize); |
3520 | |
5883
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
3521 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
|
3522 prev->upstream.limit_rate, 0); |
973ee2276300
Upstream: proxy_limit_rate and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5874
diff
changeset
|
3523 |
507 | 3524 ngx_conf_merge_bufs_value(conf->upstream.bufs, prev->upstream.bufs, |
3525 8, ngx_pagesize); | |
3526 | |
3527 if (conf->upstream.bufs.num < 2) { | |
577 | 3528 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
507 | 3529 "there must be at least 2 \"proxy_buffers\""); |
3530 return NGX_CONF_ERROR; | |
3531 } | |
577 | 3532 |
507 | 3533 |
581 | 3534 size = conf->upstream.buffer_size; |
577 | 3535 if (size < conf->upstream.bufs.size) { |
507 | 3536 size = conf->upstream.bufs.size; |
3537 } | |
3538 | |
3539 | |
529 | 3540 ngx_conf_merge_size_value(conf->upstream.busy_buffers_size_conf, |
3541 prev->upstream.busy_buffers_size_conf, | |
507 | 3542 NGX_CONF_UNSET_SIZE); |
3543 | |
529 | 3544 if (conf->upstream.busy_buffers_size_conf == NGX_CONF_UNSET_SIZE) { |
507 | 3545 conf->upstream.busy_buffers_size = 2 * size; |
529 | 3546 } else { |
3547 conf->upstream.busy_buffers_size = | |
3548 conf->upstream.busy_buffers_size_conf; | |
3549 } | |
577 | 3550 |
529 | 3551 if (conf->upstream.busy_buffers_size < size) { |
507 | 3552 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
|
3553 "\"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
|
3554 "the maximum of the value of \"proxy_buffer_size\" and " |
507 | 3555 "one of the \"proxy_buffers\""); |
3556 | |
3557 return NGX_CONF_ERROR; | |
529 | 3558 } |
507 | 3559 |
529 | 3560 if (conf->upstream.busy_buffers_size |
3561 > (conf->upstream.bufs.num - 1) * conf->upstream.bufs.size) | |
507 | 3562 { |
3563 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
3564 "\"proxy_busy_buffers_size\" must be less than " | |
3565 "the size of all \"proxy_buffers\" minus one buffer"); | |
3566 | |
3567 return NGX_CONF_ERROR; | |
3568 } | |
529 | 3569 |
507 | 3570 |
529 | 3571 ngx_conf_merge_size_value(conf->upstream.temp_file_write_size_conf, |
3572 prev->upstream.temp_file_write_size_conf, | |
507 | 3573 NGX_CONF_UNSET_SIZE); |
3574 | |
529 | 3575 if (conf->upstream.temp_file_write_size_conf == NGX_CONF_UNSET_SIZE) { |
507 | 3576 conf->upstream.temp_file_write_size = 2 * size; |
529 | 3577 } else { |
3578 conf->upstream.temp_file_write_size = | |
3579 conf->upstream.temp_file_write_size_conf; | |
3580 } | |
577 | 3581 |
529 | 3582 if (conf->upstream.temp_file_write_size < size) { |
507 | 3583 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
|
3584 "\"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
|
3585 "than the maximum of the value of \"proxy_buffer_size\" and " |
507 | 3586 "one of the \"proxy_buffers\""); |
3587 | |
3588 return NGX_CONF_ERROR; | |
3589 } | |
3590 | |
529 | 3591 ngx_conf_merge_size_value(conf->upstream.max_temp_file_size_conf, |
3592 prev->upstream.max_temp_file_size_conf, | |
507 | 3593 NGX_CONF_UNSET_SIZE); |
3594 | |
529 | 3595 if (conf->upstream.max_temp_file_size_conf == NGX_CONF_UNSET_SIZE) { |
507 | 3596 conf->upstream.max_temp_file_size = 1024 * 1024 * 1024; |
529 | 3597 } else { |
3598 conf->upstream.max_temp_file_size = | |
3599 conf->upstream.max_temp_file_size_conf; | |
3600 } | |
507 | 3601 |
529 | 3602 if (conf->upstream.max_temp_file_size != 0 |
3603 && conf->upstream.max_temp_file_size < size) | |
507 | 3604 { |
3605 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
561 | 3606 "\"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
|
3607 "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
|
3608 "the maximum of the value of \"proxy_buffer_size\" and " |
561 | 3609 "one of the \"proxy_buffers\""); |
507 | 3610 |
3611 return NGX_CONF_ERROR; | |
3612 } | |
3613 | |
529 | 3614 |
2786
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
3615 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
|
3616 prev->upstream.ignore_headers, |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
3617 NGX_CONF_BITMASK_SET); |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
3618 |
4e002555652d
proxy_ignore_headers and fastcgi_ignore_headers
Igor Sysoev <igor@sysoev.ru>
parents:
2784
diff
changeset
|
3619 |
507 | 3620 ngx_conf_merge_bitmask_value(conf->upstream.next_upstream, |
3621 prev->upstream.next_upstream, | |
3622 (NGX_CONF_BITMASK_SET | |
3623 |NGX_HTTP_UPSTREAM_FT_ERROR | |
3624 |NGX_HTTP_UPSTREAM_FT_TIMEOUT)); | |
3625 | |
665 | 3626 if (conf->upstream.next_upstream & NGX_HTTP_UPSTREAM_FT_OFF) { |
3627 conf->upstream.next_upstream = NGX_CONF_BITMASK_SET | |
3628 |NGX_HTTP_UPSTREAM_FT_OFF; | |
3629 } | |
3630 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3631 if (ngx_conf_merge_path_value(cf, &conf->upstream.temp_path, |
509 | 3632 prev->upstream.temp_path, |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3633 &ngx_http_proxy_temp_path) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3634 != NGX_OK) |
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 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3637 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3638 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3639 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3640 #if (NGX_HTTP_CACHE) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3641 |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3642 if (conf->upstream.cache == NGX_CONF_UNSET) { |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3643 ngx_conf_merge_value(conf->upstream.cache, |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3644 prev->upstream.cache, 0); |
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 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
|
3647 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
|
3648 } |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3649 |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3650 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
|
3651 ngx_shm_zone_t *shm_zone; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3652 |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
3653 shm_zone = conf->upstream.cache_zone; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3654 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3655 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3656 "\"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
|
3657 &shm_zone->shm.name); |
2592
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 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3660 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3661 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3662 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
|
3663 prev->upstream.cache_min_uses, 1); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3664 |
6793
0fba3ed4e7eb
Cache: proxy_cache_max_range_offset and friends.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6785
diff
changeset
|
3665 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
|
3666 prev->upstream.cache_max_range_offset, |
0fba3ed4e7eb
Cache: proxy_cache_max_range_offset and friends.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6785
diff
changeset
|
3667 NGX_MAX_OFF_T_VALUE); |
0fba3ed4e7eb
Cache: proxy_cache_max_range_offset and friends.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6785
diff
changeset
|
3668 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3669 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
|
3670 prev->upstream.cache_use_stale, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3671 (NGX_CONF_BITMASK_SET |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3672 |NGX_HTTP_UPSTREAM_FT_OFF)); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3673 |
4401
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
3674 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
|
3675 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
|
3676 |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
|
3677 } |
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 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
|
3680 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
|
3681 } |
d45742815c90
Fixed proxy_cache_use_stale in "no live upstreams" case.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4400
diff
changeset
|
3682 |
2875
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
3683 if (conf->upstream.cache_methods == 0) { |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
3684 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
|
3685 } |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
3686 |
6e1941b321b7
proxy_cache_methods and fastcgi_cache_methods
Igor Sysoev <igor@sysoev.ru>
parents:
2786
diff
changeset
|
3687 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
|
3688 |
3699
b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Igor Sysoev <igor@sysoev.ru>
parents:
3692
diff
changeset
|
3689 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
|
3690 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
|
3691 |
3526
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
3692 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
|
3693 prev->upstream.no_cache, NULL); |
62a4fd1e6e2c
proxy_no_cache and fastcgi_no_cache
Igor Sysoev <igor@sysoev.ru>
parents:
3523
diff
changeset
|
3694 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3695 ngx_conf_merge_ptr_value(conf->upstream.cache_valid, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3696 prev->upstream.cache_valid, NULL); |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3697 |
2672 | 3698 if (conf->cache_key.value.data == NULL) { |
3699 conf->cache_key = prev->cache_key; | |
3700 } | |
3701 | |
4385
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3702 ngx_conf_merge_value(conf->upstream.cache_lock, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3703 prev->upstream.cache_lock, 0); |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3704 |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3705 ngx_conf_merge_msec_value(conf->upstream.cache_lock_timeout, |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3706 prev->upstream.cache_lock_timeout, 5000); |
70ba81827472
Cache locks initial implementation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4377
diff
changeset
|
3707 |
5905
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
3708 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
|
3709 prev->upstream.cache_lock_age, 5000); |
2f7e557eab5b
Cache: proxy_cache_lock_age and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
5900
diff
changeset
|
3710 |
5441
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
3711 ngx_conf_merge_value(conf->upstream.cache_revalidate, |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
3712 prev->upstream.cache_revalidate, 0); |
43ccaf8e8728
Upstream: cache revalidation with conditional requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5391
diff
changeset
|
3713 |
6290
4d5ac1a31d44
Upstream: proxy_cache_convert_head directive.
Roman Arutyunyan <arut@nginx.com>
parents:
6157
diff
changeset
|
3714 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
|
3715 prev->upstream.cache_convert_head, 1); |
4d5ac1a31d44
Upstream: proxy_cache_convert_head directive.
Roman Arutyunyan <arut@nginx.com>
parents:
6157
diff
changeset
|
3716 |
6906
1aeaae6e9446
Upstream: proxy_cache_background_update and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6793
diff
changeset
|
3717 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
|
3718 prev->upstream.cache_background_update, 0); |
1aeaae6e9446
Upstream: proxy_cache_background_update and friends.
Roman Arutyunyan <arut@nginx.com>
parents:
6793
diff
changeset
|
3719 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3720 #endif |
507 | 3721 |
509 | 3722 ngx_conf_merge_value(conf->upstream.pass_request_headers, |
3723 prev->upstream.pass_request_headers, 1); | |
3724 ngx_conf_merge_value(conf->upstream.pass_request_body, | |
3725 prev->upstream.pass_request_body, 1); | |
3726 | |
657 | 3727 ngx_conf_merge_value(conf->upstream.intercept_errors, |
3728 prev->upstream.intercept_errors, 0); | |
509 | 3729 |
2184 | 3730 #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
|
3731 |
8053
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
3732 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
|
3733 return NGX_CONF_ERROR; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
3734 } |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
3735 |
2184 | 3736 ngx_conf_merge_value(conf->upstream.ssl_session_reuse, |
3737 prev->upstream.ssl_session_reuse, 1); | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3738 |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3739 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
|
3740 (NGX_CONF_BITMASK_SET |
d1cf09451ae8
SSL: enabled TLSv1.3 by default.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8053
diff
changeset
|
3741 |NGX_SSL_TLSv1|NGX_SSL_TLSv1_1 |
d1cf09451ae8
SSL: enabled TLSv1.3 by default.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8053
diff
changeset
|
3742 |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
|
3743 |
5390
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
3744 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
|
3745 "DEFAULT"); |
919d230ecdbe
Proxy: added the "proxy_ssl_ciphers" directive.
Piotr Sikora <piotr@cloudflare.com>
parents:
5385
diff
changeset
|
3746 |
7831
bdd4d89370a7
Changed complex value slots to use NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7787
diff
changeset
|
3747 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
|
3748 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
|
3749 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
|
3750 prev->upstream.ssl_server_name, 0); |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3751 ngx_conf_merge_value(conf->upstream.ssl_verify, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3752 prev->upstream.ssl_verify, 0); |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3753 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
|
3754 prev->ssl_verify_depth, 1); |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3755 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
|
3756 prev->ssl_trusted_certificate, ""); |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
3757 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
|
3758 |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3759 ngx_conf_merge_ptr_value(conf->upstream.ssl_certificate, |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3760 prev->upstream.ssl_certificate, NULL); |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3761 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
|
3762 prev->upstream.ssl_certificate_key, NULL); |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3763 ngx_conf_merge_ptr_value(conf->upstream.ssl_passwords, |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
3764 prev->upstream.ssl_passwords, NULL); |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
3765 |
7730
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
3766 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
|
3767 prev->ssl_conf_commands, NULL); |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
3768 |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3769 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
|
3770 return NGX_CONF_ERROR; |
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
3771 } |
5660
7022564a9e0e
Upstream: proxy_ssl_name and proxy_ssl_server_name directives.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5659
diff
changeset
|
3772 |
2184 | 3773 #endif |
3774 | |
7831
bdd4d89370a7
Changed complex value slots to use NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7787
diff
changeset
|
3775 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
|
3776 |
509 | 3777 ngx_conf_merge_value(conf->redirect, prev->redirect, 1); |
3778 | |
3779 if (conf->redirect) { | |
507 | 3780 |
509 | 3781 if (conf->redirects == NULL) { |
3782 conf->redirects = prev->redirects; | |
3783 } | |
3784 | |
1658 | 3785 if (conf->redirects == NULL && conf->url.data) { |
509 | 3786 |
3787 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
|
3788 sizeof(ngx_http_proxy_rewrite_t)); |
509 | 3789 if (conf->redirects == NULL) { |
3790 return NGX_CONF_ERROR; | |
3791 } | |
3792 | |
3793 pr = ngx_array_push(conf->redirects); | |
3794 if (pr == NULL) { | |
3795 return NGX_CONF_ERROR; | |
3796 } | |
3797 | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3798 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
|
3799 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
|
3800 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3801 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
|
3802 |
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->handler = ngx_http_proxy_rewrite_complex_handler; |
1658 | 3804 |
3805 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
|
3806 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
|
3807 pr->replacement.value = conf->location; |
653 | 3808 |
3809 } else { | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3810 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
|
3811 + sizeof("/") - 1; |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3812 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3813 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
|
3814 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
|
3815 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
|
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 |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
3818 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
|
3819 |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3820 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
|
3821 *p = '/'; |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
3822 |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
3823 ngx_str_set(&pr->replacement.value, "/"); |
653 | 3824 } |
509 | 3825 } |
3826 } | |
3827 | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
3828 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
|
3829 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
3830 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
|
3831 |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
3832 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
|
3833 |
4126
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
3834 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
|
3835 NGX_HTTP_VERSION_10); |
bba9a5ccc6cd
Proxy: basic HTTP/1.1 support (including keepalive).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4125
diff
changeset
|
3836 |
1180
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_max_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_max_size, 512); |
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 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
|
3841 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
|
3842 |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
3843 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
|
3844 ngx_cacheline_size); |
1666b7b0bafc
proxy_headers_hash_max_size and proxy_headers_hash_bucket_size
Igor Sysoev <igor@sysoev.ru>
parents:
1125
diff
changeset
|
3845 |
1701
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
3846 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
|
3847 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
|
3848 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
|
3849 |
40d004d95d88
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
Igor Sysoev <igor@sysoev.ru>
parents:
1699
diff
changeset
|
3850 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
|
3851 &prev->upstream, ngx_http_proxy_hide_headers, &hash) |
649 | 3852 != NGX_OK) |
3853 { | |
3854 return NGX_CONF_ERROR; | |
3855 } | |
3856 | |
5938
cd2abf7e7740
Upstream: fixed unexpected inheritance into limit_except blocks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5937
diff
changeset
|
3857 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
|
3858 |
cd2abf7e7740
Upstream: fixed unexpected inheritance into limit_except blocks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5937
diff
changeset
|
3859 if (clcf->noname |
cd2abf7e7740
Upstream: fixed unexpected inheritance into limit_except blocks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5937
diff
changeset
|
3860 && 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
|
3861 { |
884 | 3862 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
|
3863 conf->location = prev->location; |
1658 | 3864 conf->vars = prev->vars; |
5937
5b9f711dc819
Upstream: inheritance of proxy_pass and friends (ticket #645).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5936
diff
changeset
|
3865 |
3734
e3a6785b5be4
*) make code consistent to fastcgi, etc
Igor Sysoev <igor@sysoev.ru>
parents:
3733
diff
changeset
|
3866 conf->proxy_lengths = prev->proxy_lengths; |
e3a6785b5be4
*) make code consistent to fastcgi, etc
Igor Sysoev <igor@sysoev.ru>
parents:
3733
diff
changeset
|
3867 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
|
3868 |
5b9f711dc819
Upstream: inheritance of proxy_pass and friends (ticket #645).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5936
diff
changeset
|
3869 #if (NGX_HTTP_SSL) |
8053
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
3870 conf->ssl = prev->ssl; |
5937
5b9f711dc819
Upstream: inheritance of proxy_pass and friends (ticket #645).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5936
diff
changeset
|
3871 #endif |
3734
e3a6785b5be4
*) make code consistent to fastcgi, etc
Igor Sysoev <igor@sysoev.ru>
parents:
3733
diff
changeset
|
3872 } |
e3a6785b5be4
*) make code consistent to fastcgi, etc
Igor Sysoev <igor@sysoev.ru>
parents:
3733
diff
changeset
|
3873 |
5938
cd2abf7e7740
Upstream: fixed unexpected inheritance into limit_except blocks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5937
diff
changeset
|
3874 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
|
3875 && (conf->upstream.upstream || conf->proxy_lengths)) |
cd2abf7e7740
Upstream: fixed unexpected inheritance into limit_except blocks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5937
diff
changeset
|
3876 { |
cd2abf7e7740
Upstream: fixed unexpected inheritance into limit_except blocks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5937
diff
changeset
|
3877 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
|
3878 } |
577 | 3879 |
3880 if (conf->body_source.data == NULL) { | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3881 conf->body_flushes = prev->body_flushes; |
577 | 3882 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
|
3883 conf->body_lengths = prev->body_lengths; |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3884 conf->body_values = prev->body_values; |
577 | 3885 } |
3886 | |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3887 if (conf->body_source.data && conf->body_lengths == NULL) { |
577 | 3888 |
3889 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
3890 | |
3891 sc.cf = cf; | |
3892 sc.source = &conf->body_source; | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3893 sc.flushes = &conf->body_flushes; |
5910
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3894 sc.lengths = &conf->body_lengths; |
29fa5023bd6f
Proxy: renamed and rearranged fields in proxy configuration.
Roman Arutyunyan <arut@nginx.com>
parents:
5909
diff
changeset
|
3895 sc.values = &conf->body_values; |
577 | 3896 sc.complete_lengths = 1; |
3897 sc.complete_values = 1; | |
3898 | |
3899 if (ngx_http_script_compile(&sc) != NGX_OK) { | |
3900 return NGX_CONF_ERROR; | |
3901 } | |
3902 } | |
3903 | |
7728
485dba3e2a01
Core: ngx_conf_set_keyval_slot() now accepts NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7720
diff
changeset
|
3904 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
|
3905 |
485dba3e2a01
Core: ngx_conf_set_keyval_slot() now accepts NGX_CONF_UNSET_PTR.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7720
diff
changeset
|
3906 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
|
3907 conf->headers = prev->headers; |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3908 #if (NGX_HTTP_CACHE) |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3909 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
|
3910 #endif |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3911 } |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3912 |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3913 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
|
3914 ngx_http_proxy_headers); |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3915 if (rc != NGX_OK) { |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3916 return NGX_CONF_ERROR; |
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 |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3919 #if (NGX_HTTP_CACHE) |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3920 |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3921 if (conf->upstream.cache) { |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3922 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
|
3923 ngx_http_proxy_cache_headers); |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3924 if (rc != NGX_OK) { |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3925 return NGX_CONF_ERROR; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3926 } |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3927 } |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
3928 |
5907
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3929 #endif |
195561ef367f
Upstream: moved header initializations to separate functions.
Roman Arutyunyan <arut@nginx.com>
parents:
5905
diff
changeset
|
3930 |
6747
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 * 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
|
3933 * 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
|
3934 */ |
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 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
|
3937 && 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
|
3938 { |
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3939 prev->headers = conf->headers; |
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3940 #if (NGX_HTTP_CACHE) |
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3941 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
|
3942 #endif |
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3943 } |
20eb4587225b
Upstream: handling of proxy_set_header at http level.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6746
diff
changeset
|
3944 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3945 return NGX_CONF_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3946 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3947 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3948 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3949 static ngx_int_t |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3950 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
|
3951 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
|
3952 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3953 u_char *p; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3954 size_t size; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3955 uintptr_t *code; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3956 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
|
3957 ngx_array_t headers_names, headers_merged; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3958 ngx_keyval_t *src, *s, *h; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3959 ngx_hash_key_t *hk; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3960 ngx_hash_init_t hash; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3961 ngx_http_script_compile_t sc; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3962 ngx_http_script_copy_code_t *copy; |
577 | 3963 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3964 if (headers->hash.buckets) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3965 return NGX_OK; |
509 | 3966 } |
3967 | |
3561
20708cffd6dc
use local headers_names array instead of stored in configuration
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
3968 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
|
3969 != NGX_OK) |
20708cffd6dc
use local headers_names array instead of stored in configuration
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
3970 { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3971 return NGX_ERROR; |
509 | 3972 } |
3973 | |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3974 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
|
3975 != NGX_OK) |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3976 { |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3977 return NGX_ERROR; |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3978 } |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
3979 |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3980 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
|
3981 if (headers->lengths == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3982 return NGX_ERROR; |
509 | 3983 } |
3984 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
3985 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
|
3986 if (headers->values == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
3987 return NGX_ERROR; |
509 | 3988 } |
3989 | |
6746
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
3990 if (conf->headers_source) { |
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 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
|
3993 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
|
3994 |
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
3995 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
|
3996 if (s == NULL) { |
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
3997 return NGX_ERROR; |
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
3998 } |
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
3999 |
63991ab67b3a
Proxy: do not create conf->headers_source when not needed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6591
diff
changeset
|
4000 *s = src[i]; |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4001 } |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4002 } |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4003 |
5909
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
4004 h = default_headers; |
8d0cf26ce071
Upstream: different header lists for cached and uncached requests.
Roman Arutyunyan <arut@nginx.com>
parents:
5908
diff
changeset
|
4005 |
2705
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
4006 while (h->key.len) { |
509 | 4007 |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4008 src = headers_merged.elts; |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4009 for (i = 0; i < headers_merged.nelts; i++) { |
509 | 4010 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { |
4011 goto next; | |
507 | 4012 } |
4013 } | |
4014 | |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4015 s = ngx_array_push(&headers_merged); |
509 | 4016 if (s == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4017 return NGX_ERROR; |
507 | 4018 } |
4019 | |
509 | 4020 *s = *h; |
507 | 4021 |
509 | 4022 next: |
507 | 4023 |
2705
d040c3786239
do not pass if-... headers for cacheable responses
Igor Sysoev <igor@sysoev.ru>
parents:
2672
diff
changeset
|
4024 h++; |
509 | 4025 } |
507 | 4026 |
577 | 4027 |
4274
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4028 src = headers_merged.elts; |
595560d9dcbf
Fixed proxy_set_header inheritance with proxy_cache (ticket #45).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4205
diff
changeset
|
4029 for (i = 0; i < headers_merged.nelts; i++) { |
507 | 4030 |
3561
20708cffd6dc
use local headers_names array instead of stored in configuration
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
4031 hk = ngx_array_push(&headers_names); |
649 | 4032 if (hk == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4033 return NGX_ERROR; |
507 | 4034 } |
4035 | |
649 | 4036 hk->key = src[i].key; |
4037 hk->key_hash = ngx_hash_key_lc(src[i].key.data, src[i].key.len); | |
4038 hk->value = (void *) 1; | |
509 | 4039 |
519 | 4040 if (src[i].value.len == 0) { |
4041 continue; | |
4042 } | |
4043 | |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4044 copy = ngx_array_push_n(headers->lengths, |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4045 sizeof(ngx_http_script_copy_code_t)); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4046 if (copy == NULL) { |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4047 return NGX_ERROR; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4048 } |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4049 |
9312
098019656024
Changed script length code casts to work with -Wpedantic.
Maxim Dounin <mdounin@mdounin.ru>
parents:
9263
diff
changeset
|
4050 copy->code = (ngx_http_script_code_pt) (uintptr_t) |
7271
9e25a5380a21
Silenced -Wcast-function-type warnings (closes #1546).
Sergey Kandaurov <pluknet@nginx.com>
parents:
7238
diff
changeset
|
4051 ngx_http_script_copy_len_code; |
7047
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4052 copy->len = src[i].key.len; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4053 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4054 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
|
4055 + 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
|
4056 & ~(sizeof(uintptr_t) - 1); |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4057 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4058 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
|
4059 if (copy == NULL) { |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4060 return NGX_ERROR; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4061 } |
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 copy->code = ngx_http_script_copy_code; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4064 copy->len = 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 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
|
4067 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
|
4068 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4069 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
|
4070 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4071 sc.cf = cf; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4072 sc.source = &src[i].value; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4073 sc.flushes = &headers->flushes; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4074 sc.lengths = &headers->lengths; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4075 sc.values = &headers->values; |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4076 |
3fef8c5caa75
Proxy: split configured header names and values.
Piotr Sikora <piotrsikora@google.com>
parents:
7001
diff
changeset
|
4077 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
|
4078 return NGX_ERROR; |
507 | 4079 } |
4080 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
4081 code = ngx_array_push_n(headers->lengths, sizeof(uintptr_t)); |
509 | 4082 if (code == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4083 return NGX_ERROR; |
507 | 4084 } |
4085 | |
509 | 4086 *code = (uintptr_t) NULL; |
4087 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
4088 code = ngx_array_push_n(headers->values, sizeof(uintptr_t)); |
509 | 4089 if (code == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4090 return NGX_ERROR; |
509 | 4091 } |
4092 | |
4093 *code = (uintptr_t) NULL; | |
507 | 4094 } |
4095 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
4096 code = ngx_array_push_n(headers->lengths, sizeof(uintptr_t)); |
509 | 4097 if (code == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4098 return NGX_ERROR; |
507 | 4099 } |
4100 | |
509 | 4101 *code = (uintptr_t) NULL; |
507 | 4102 |
4103 | |
5908
f8e80f8c7fc7
Upstream: moved header lists to separate structures.
Roman Arutyunyan <arut@nginx.com>
parents:
5907
diff
changeset
|
4104 hash.hash = &headers->hash; |
649 | 4105 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
|
4106 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
|
4107 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
|
4108 hash.name = "proxy_headers_hash"; |
649 | 4109 hash.pool = cf->pool; |
4110 hash.temp_pool = NULL; | |
4111 | |
3561
20708cffd6dc
use local headers_names array instead of stored in configuration
Igor Sysoev <igor@sysoev.ru>
parents:
3526
diff
changeset
|
4112 return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts); |
507 | 4113 } |
4114 | |
4115 | |
4116 static char * | |
4117 ngx_http_proxy_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
4118 { | |
509 | 4119 ngx_http_proxy_loc_conf_t *plcf = conf; |
507 | 4120 |
1658 | 4121 size_t add; |
4122 u_short port; | |
4123 ngx_str_t *value, *url; | |
4124 ngx_url_t u; | |
4125 ngx_uint_t n; | |
4126 ngx_http_core_loc_conf_t *clcf; | |
4127 ngx_http_script_compile_t sc; | |
507 | 4128 |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2285
diff
changeset
|
4129 if (plcf->upstream.upstream || plcf->proxy_lengths) { |
555 | 4130 return "is duplicate"; |
4131 } | |
4132 | |
1658 | 4133 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); |
4134 | |
2989
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2949
diff
changeset
|
4135 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
|
4136 |
7321
45e513c3540d
Fixed invalid access to location defined as an empty string.
Ruslan Ermilov <ru@nginx.com>
parents:
7320
diff
changeset
|
4137 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
|
4138 clcf->auto_redirect = 1; |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2949
diff
changeset
|
4139 } |
dff9764eaca2
do auto redirect for proxy_pass/fastcgi_pass with variables
Igor Sysoev <igor@sysoev.ru>
parents:
2949
diff
changeset
|
4140 |
507 | 4141 value = cf->args->elts; |
4142 | |
4143 url = &value[1]; | |
4144 | |
1658 | 4145 n = ngx_http_script_variables_count(url); |
4146 | |
4147 if (n) { | |
4148 | |
4149 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t)); | |
4150 | |
4151 sc.cf = cf; | |
4152 sc.source = url; | |
4153 sc.lengths = &plcf->proxy_lengths; | |
4154 sc.values = &plcf->proxy_values; | |
4155 sc.variables = n; | |
4156 sc.complete_lengths = 1; | |
4157 sc.complete_values = 1; | |
1679
ca317d9b5c09
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1671
diff
changeset
|
4158 |
1658 | 4159 if (ngx_http_script_compile(&sc) != NGX_OK) { |
4160 return NGX_CONF_ERROR; | |
4161 } | |
4162 | |
4163 #if (NGX_HTTP_SSL) | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
4164 plcf->ssl = 1; |
1658 | 4165 #endif |
4166 | |
4167 return NGX_CONF_OK; | |
4168 } | |
4169 | |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
969
diff
changeset
|
4170 if (ngx_strncasecmp(url->data, (u_char *) "http://", 7) == 0) { |
577 | 4171 add = 7; |
591 | 4172 port = 80; |
577 | 4173 |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
969
diff
changeset
|
4174 } else if (ngx_strncasecmp(url->data, (u_char *) "https://", 8) == 0) { |
577 | 4175 |
4176 #if (NGX_HTTP_SSL) | |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
4177 plcf->ssl = 1; |
577 | 4178 |
4179 add = 8; | |
591 | 4180 port = 443; |
577 | 4181 #else |
4182 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
4183 "https protocol requires SSL support"); | |
4184 return NGX_CONF_ERROR; | |
4185 #endif | |
4186 | |
4187 } else { | |
507 | 4188 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid URL prefix"); |
4189 return NGX_CONF_ERROR; | |
4190 } | |
4191 | |
651 | 4192 ngx_memzero(&u, sizeof(ngx_url_t)); |
4193 | |
4194 u.url.len = url->len - add; | |
4195 u.url.data = url->data + add; | |
906 | 4196 u.default_port = port; |
4197 u.uri_part = 1; | |
884 | 4198 u.no_resolve = 1; |
4199 | |
4200 plcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0); | |
4201 if (plcf->upstream.upstream == NULL) { | |
507 | 4202 return NGX_CONF_ERROR; |
4203 } | |
4204 | |
2391
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2285
diff
changeset
|
4205 plcf->vars.schema.len = add; |
d88e757cc7d8
delete surplus upstream.schema field
Igor Sysoev <igor@sysoev.ru>
parents:
2285
diff
changeset
|
4206 plcf->vars.schema.data = url->data; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4207 plcf->vars.key_start = plcf->vars.schema; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4208 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4209 ngx_http_proxy_set_vars(&u, &plcf->vars); |
507 | 4210 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4211 plcf->location = clcf->name; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4212 |
1353 | 4213 if (clcf->named |
507 | 4214 #if (NGX_PCRE) |
1353 | 4215 || clcf->regex |
4216 #endif | |
4217 || clcf->noname) | |
4218 { | |
1658 | 4219 if (plcf->vars.uri.len) { |
573 | 4220 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
|
4221 "\"proxy_pass\" cannot have URI part in " |
843
ebab9490204c
allow proxy_pass inside limit_except
Igor Sysoev <igor@sysoev.ru>
parents:
812
diff
changeset
|
4222 "location given by regular expression, " |
1353 | 4223 "or inside named location, " |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
4224 "or inside \"if\" statement, " |
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4529
diff
changeset
|
4225 "or inside \"limit_except\" block"); |
573 | 4226 return NGX_CONF_ERROR; |
4227 } | |
4228 | |
1658 | 4229 plcf->location.len = 0; |
555 | 4230 } |
4231 | |
1658 | 4232 plcf->url = *url; |
509 | 4233 |
507 | 4234 return NGX_CONF_OK; |
4235 } | |
4236 | |
4237 | |
4238 static char * | |
509 | 4239 ngx_http_proxy_redirect(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
507 | 4240 { |
509 | 4241 ngx_http_proxy_loc_conf_t *plcf = conf; |
4242 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4243 u_char *p; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4244 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
|
4245 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
|
4246 ngx_http_compile_complex_value_t ccv; |
509 | 4247 |
4248 if (plcf->redirect == 0) { | |
7714
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4249 return "is duplicate"; |
509 | 4250 } |
4251 | |
4422
b1a9d725ab69
Fixed proxy_redirect off inheritance.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
4252 plcf->redirect = 1; |
b1a9d725ab69
Fixed proxy_redirect off inheritance.
Valentin Bartenev <vbart@nginx.com>
parents:
4412
diff
changeset
|
4253 |
509 | 4254 value = cf->args->elts; |
4255 | |
2784
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4256 if (cf->args->nelts == 2) { |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4257 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
|
4258 |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4259 if (plcf->redirects) { |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4260 return "is duplicate"; |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4261 } |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4262 |
2784
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4263 plcf->redirect = 0; |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4264 return NGX_CONF_OK; |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4265 } |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4266 |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4267 if (ngx_strcmp(value[1].data, "default") != 0) { |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4268 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
|
4269 "invalid parameter \"%V\"", &value[1]); |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4270 return NGX_CONF_ERROR; |
c2230102df6f
*) check a proxy_redirect single parameter
Igor Sysoev <igor@sysoev.ru>
parents:
2753
diff
changeset
|
4271 } |
509 | 4272 } |
4273 | |
4274 if (plcf->redirects == NULL) { | |
4275 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
|
4276 sizeof(ngx_http_proxy_rewrite_t)); |
509 | 4277 if (plcf->redirects == NULL) { |
4278 return NGX_CONF_ERROR; | |
4279 } | |
4280 } | |
4281 | |
4282 pr = ngx_array_push(plcf->redirects); | |
4283 if (pr == NULL) { | |
4284 return NGX_CONF_ERROR; | |
4285 } | |
4286 | |
7714
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4287 if (cf->args->nelts == 2 |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4288 && ngx_strcmp(value[1].data, "default") == 0) |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4289 { |
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 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
|
4291 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
|
4292 "\"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
|
4293 "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
|
4294 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
|
4295 } |
d8c56e7851b8
"proxy_redirect default" may not be used if a proxy_pass uses variables
Igor Sysoev <igor@sysoev.ru>
parents:
3470
diff
changeset
|
4296 |
1658 | 4297 if (plcf->url.data == NULL) { |
509 | 4298 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
|
4299 "\"proxy_redirect default\" should be placed " |
509 | 4300 "after the \"proxy_pass\" directive"); |
4301 return NGX_CONF_ERROR; | |
4302 } | |
4303 | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
4304 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
|
4305 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
4306 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
|
4307 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4308 ngx_memzero(&pr->replacement, sizeof(ngx_http_complex_value_t)); |
1658 | 4309 |
4310 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
|
4311 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
|
4312 pr->replacement.value = plcf->location; |
653 | 4313 |
4314 } else { | |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
4315 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
|
4316 |
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
4317 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
|
4318 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
|
4319 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
|
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 |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
4322 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
|
4323 |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
4324 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
|
4325 *p = '/'; |
f4c49c9e4bb5
always test proxy_redirect with slash, this fixes a case when nginx uses
Igor Sysoev <igor@sysoev.ru>
parents:
3734
diff
changeset
|
4326 |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4327 ngx_str_set(&pr->replacement.value, "/"); |
653 | 4328 } |
509 | 4329 |
4330 return NGX_CONF_OK; | |
4331 } | |
4332 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4333 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4334 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
|
4335 value[1].len--; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4336 value[1].data++; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4337 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4338 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
|
4339 value[1].len--; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4340 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
|
4341 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4342 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
|
4343 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
|
4344 } |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4345 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4346 } else { |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4347 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
|
4348 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
|
4349 } |
4336
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 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4352 } else { |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4353 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4354 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
|
4355 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4356 ccv.cf = cf; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4357 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
|
4358 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
|
4359 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4360 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
|
4361 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
|
4362 } |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4363 |
4461
103587c7ae5f
Proxy: renamed some "proxy_redirect" related declarations to a more general and
Valentin Bartenev <vbart@nginx.com>
parents:
4422
diff
changeset
|
4364 pr->handler = ngx_http_proxy_rewrite_complex_handler; |
509 | 4365 } |
4366 | |
4336
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4367 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4368 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
|
4369 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4370 ccv.cf = cf; |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4371 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
|
4372 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
|
4373 |
99437094e86f
Proxy: added variables and regexp support to the first parameter of
Valentin Bartenev <vbart@nginx.com>
parents:
4276
diff
changeset
|
4374 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { |
509 | 4375 return NGX_CONF_ERROR; |
4376 } | |
4377 | |
507 | 4378 return NGX_CONF_OK; |
4379 } | |
4380 | |
4381 | |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4382 static char * |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4383 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
|
4384 { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4385 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
|
4386 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4387 ngx_str_t *value; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4388 ngx_http_proxy_rewrite_t *pr; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4389 ngx_http_compile_complex_value_t ccv; |
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 if (plcf->cookie_domains == NULL) { |
7714
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4392 return "is duplicate"; |
4465
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 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4395 value = cf->args->elts; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4396 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4397 if (cf->args->nelts == 2) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4398 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4399 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
|
4400 |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4401 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
|
4402 return "is duplicate"; |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4403 } |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4404 |
4465
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4405 plcf->cookie_domains = NULL; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4406 return NGX_CONF_OK; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4407 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4408 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4409 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
|
4410 "invalid parameter \"%V\"", &value[1]); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4411 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4412 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4413 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4414 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
|
4415 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
|
4416 sizeof(ngx_http_proxy_rewrite_t)); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4417 if (plcf->cookie_domains == NULL) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4418 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4419 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4420 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4421 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4422 pr = ngx_array_push(plcf->cookie_domains); |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4423 if (pr == NULL) { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4424 return NGX_CONF_ERROR; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4425 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4426 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4427 if (value[1].data[0] == '~') { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4428 value[1].len--; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4429 value[1].data++; |
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 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
|
4432 return NGX_CONF_ERROR; |
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 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4435 } else { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4436 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4437 if (value[1].data[0] == '.') { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4438 value[1].len--; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4439 value[1].data++; |
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 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4442 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
|
4443 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4444 ccv.cf = cf; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4445 ccv.value = &value[1]; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4446 ccv.complex_value = &pr->pattern.complex; |
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 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
|
4449 return NGX_CONF_ERROR; |
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 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4452 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
|
4453 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4454 if (value[2].data[0] == '.') { |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4455 value[2].len--; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4456 value[2].data++; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4457 } |
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 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4460 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
|
4461 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4462 ccv.cf = cf; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4463 ccv.value = &value[2]; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4464 ccv.complex_value = &pr->replacement; |
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 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
|
4467 return NGX_CONF_ERROR; |
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 return NGX_CONF_OK; |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4471 } |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4472 |
8293fc2d802b
Proxy: added the "proxy_cookie_domain" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4463
diff
changeset
|
4473 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4474 static char * |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4475 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
|
4476 { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4477 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
|
4478 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4479 ngx_str_t *value; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4480 ngx_http_proxy_rewrite_t *pr; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4481 ngx_http_compile_complex_value_t ccv; |
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 if (plcf->cookie_paths == NULL) { |
7714
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4484 return "is duplicate"; |
4466
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 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4487 value = cf->args->elts; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4488 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4489 if (cf->args->nelts == 2) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4490 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4491 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
|
4492 |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4493 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
|
4494 return "is duplicate"; |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4495 } |
8dbc9ee97998
Proxy: strengthen syntax checking for some directives.
Ruslan Ermilov <ru@nginx.com>
parents:
7677
diff
changeset
|
4496 |
4466
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4497 plcf->cookie_paths = NULL; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4498 return NGX_CONF_OK; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4499 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4500 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4501 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
|
4502 "invalid parameter \"%V\"", &value[1]); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4503 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4504 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4505 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4506 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
|
4507 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
|
4508 sizeof(ngx_http_proxy_rewrite_t)); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4509 if (plcf->cookie_paths == NULL) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4510 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4511 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4512 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4513 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4514 pr = ngx_array_push(plcf->cookie_paths); |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4515 if (pr == NULL) { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4516 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4517 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4518 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4519 if (value[1].data[0] == '~') { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4520 value[1].len--; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4521 value[1].data++; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4522 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4523 if (value[1].data[0] == '*') { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4524 value[1].len--; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4525 value[1].data++; |
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 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
|
4528 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4529 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4530 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4531 } else { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4532 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
|
4533 return NGX_CONF_ERROR; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4534 } |
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 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4537 } else { |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4538 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4539 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
|
4540 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4541 ccv.cf = cf; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4542 ccv.value = &value[1]; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4543 ccv.complex_value = &pr->pattern.complex; |
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 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
|
4546 return NGX_CONF_ERROR; |
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 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
|
4550 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4551 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4552 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
|
4553 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4554 ccv.cf = cf; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4555 ccv.value = &value[2]; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4556 ccv.complex_value = &pr->replacement; |
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 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
|
4559 return NGX_CONF_ERROR; |
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 return NGX_CONF_OK; |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4563 } |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4564 |
b404f34b5cb8
Proxy: added the "proxy_cookie_path" directive.
Valentin Bartenev <vbart@nginx.com>
parents:
4465
diff
changeset
|
4565 |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4566 static char * |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4567 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
|
4568 { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4569 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
|
4570 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4571 ngx_str_t *value; |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4572 ngx_uint_t i; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4573 ngx_http_complex_value_t *cv; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4574 ngx_http_proxy_cookie_flags_t *pcf; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4575 ngx_http_compile_complex_value_t ccv; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4576 #if (NGX_PCRE) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4577 ngx_regex_compile_t rc; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4578 u_char errstr[NGX_MAX_CONF_ERRSTR]; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4579 #endif |
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 if (plcf->cookie_flags == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4582 return "is duplicate"; |
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 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4585 value = cf->args->elts; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4586 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4587 if (cf->args->nelts == 2) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4588 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4589 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
|
4590 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4591 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
|
4592 return "is duplicate"; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4593 } |
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 plcf->cookie_flags = NULL; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4596 return NGX_CONF_OK; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4597 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4598 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4599 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
|
4600 "invalid parameter \"%V\"", &value[1]); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4601 return NGX_CONF_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4602 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4603 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4604 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
|
4605 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
|
4606 sizeof(ngx_http_proxy_cookie_flags_t)); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4607 if (plcf->cookie_flags == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4608 return NGX_CONF_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4609 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4610 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4611 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4612 pcf = ngx_array_push(plcf->cookie_flags); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4613 if (pcf == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4614 return NGX_CONF_ERROR; |
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 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4617 pcf->regex = 0; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4618 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4619 if (value[1].data[0] == '~') { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4620 value[1].len--; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4621 value[1].data++; |
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 #if (NGX_PCRE) |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4624 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
|
4625 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4626 rc.pattern = value[1]; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4627 rc.err.len = NGX_MAX_CONF_ERRSTR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4628 rc.err.data = errstr; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4629 rc.options = NGX_REGEX_CASELESS; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4630 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4631 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
|
4632 if (pcf->cookie.regex == NULL) { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4633 return NGX_CONF_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4634 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4635 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4636 pcf->regex = 1; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4637 #else |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4638 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
|
4639 "using regex \"%V\" requires PCRE library", |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4640 &value[1]); |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4641 return NGX_CONF_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4642 #endif |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4643 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4644 } else { |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4645 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4646 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
|
4647 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4648 ccv.cf = cf; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4649 ccv.value = &value[1]; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4650 ccv.complex_value = &pcf->cookie.complex; |
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 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
|
4653 return NGX_CONF_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4654 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4655 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4656 |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4657 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
|
4658 sizeof(ngx_http_complex_value_t)) |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4659 != NGX_OK) |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4660 { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4661 return NGX_CONF_ERROR; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4662 } |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4663 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4664 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
|
4665 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4666 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
|
4667 if (cv == NULL) { |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4668 return NGX_CONF_ERROR; |
7716
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4669 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4670 |
7786
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4671 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
|
4672 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4673 ccv.cf = cf; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4674 ccv.value = &value[i]; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4675 ccv.complex_value = cv; |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4676 |
529b73f75d19
Proxy: variables support in "proxy_cookie_flags" flags.
Ruslan Ermilov <ru@nginx.com>
parents:
7760
diff
changeset
|
4677 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
|
4678 return NGX_CONF_ERROR; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4679 } |
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 return NGX_CONF_OK; |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4683 } |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4684 |
d6a5e14aa3e4
Proxy: added the "proxy_cookie_flags" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
7715
diff
changeset
|
4685 |
4463
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4686 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
|
4687 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
|
4688 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
|
4689 { |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4690 #if (NGX_PCRE) |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4691 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
|
4692 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
|
4693 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4694 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
|
4695 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4696 rc.pattern = *regex; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4697 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
|
4698 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
|
4699 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4700 if (caseless) { |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4701 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
|
4702 } |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4703 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4704 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
|
4705 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
|
4706 return NGX_ERROR; |
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 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4709 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
|
4710 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4711 return NGX_OK; |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4712 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4713 #else |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4714 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4715 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
|
4716 "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
|
4717 return NGX_ERROR; |
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 #endif |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4720 } |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4721 |
a068ec122f17
Proxy: generic regex related code from the "proxy_redirect" directive moved
Valentin Bartenev <vbart@nginx.com>
parents:
4462
diff
changeset
|
4722 |
507 | 4723 static char * |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4724 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
|
4725 { |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4726 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
|
4727 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4728 ngx_str_t *value; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4729 ngx_http_script_compile_t sc; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4730 |
5947
d9025ea1f5a5
Upstream: simplified proxy_store and friends configuration code.
Valentin Bartenev <vbart@nginx.com>
parents:
5940
diff
changeset
|
4731 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
|
4732 return "is duplicate"; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4733 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4734 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4735 value = cf->args->elts; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4736 |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
4737 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
|
4738 plcf->upstream.store = 0; |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4739 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4740 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4741 |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
4742 #if (NGX_HTTP_CACHE) |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
4743 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
|
4744 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
|
4745 } |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
4746 #endif |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
4747 |
5947
d9025ea1f5a5
Upstream: simplified proxy_store and friends configuration code.
Valentin Bartenev <vbart@nginx.com>
parents:
5940
diff
changeset
|
4748 plcf->upstream.store = 1; |
d9025ea1f5a5
Upstream: simplified proxy_store and friends configuration code.
Valentin Bartenev <vbart@nginx.com>
parents:
5940
diff
changeset
|
4749 |
2895
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
4750 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
|
4751 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4752 } |
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 /* include the terminating '\0' into script */ |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4755 value[1].len++; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4756 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4757 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
|
4758 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4759 sc.cf = cf; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4760 sc.source = &value[1]; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4761 sc.lengths = &plcf->upstream.store_lengths; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4762 sc.values = &plcf->upstream.store_values; |
1563
022ec9420f80
style fix: remove double semicolons
Igor Sysoev <igor@sysoev.ru>
parents:
1488
diff
changeset
|
4763 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
|
4764 sc.complete_lengths = 1; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4765 sc.complete_values = 1; |
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 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
|
4768 return NGX_CONF_ERROR; |
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 return NGX_CONF_OK; |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4772 } |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4773 |
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4774 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4775 #if (NGX_HTTP_CACHE) |
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 static char * |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4778 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
|
4779 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4780 ngx_http_proxy_loc_conf_t *plcf = conf; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4781 |
5951
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4782 ngx_str_t *value; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4783 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
|
4784 ngx_http_compile_complex_value_t ccv; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4785 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4786 value = cf->args->elts; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4787 |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
4788 if (plcf->upstream.cache != NGX_CONF_UNSET) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4789 return "is duplicate"; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4790 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4791 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4792 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
|
4793 plcf->upstream.cache = 0; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4794 return NGX_CONF_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4795 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4796 |
5947
d9025ea1f5a5
Upstream: simplified proxy_store and friends configuration code.
Valentin Bartenev <vbart@nginx.com>
parents:
5940
diff
changeset
|
4797 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
|
4798 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
|
4799 } |
d65e58a8d3a4
report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
Igor Sysoev <igor@sysoev.ru>
parents:
2894
diff
changeset
|
4800 |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
4801 plcf->upstream.cache = 1; |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
4802 |
5951
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4803 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
|
4804 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4805 ccv.cf = cf; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4806 ccv.value = &value[1]; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4807 ccv.complex_value = &cv; |
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 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
|
4810 return NGX_CONF_ERROR; |
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 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4813 if (cv.lengths != NULL) { |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4814 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4815 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
|
4816 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
|
4817 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
|
4818 return NGX_CONF_ERROR; |
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 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4821 *plcf->upstream.cache_value = cv; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4822 |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4823 return NGX_CONF_OK; |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4824 } |
610832763648
Upstream: added variables support to proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5949
diff
changeset
|
4825 |
5949
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
4826 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
|
4827 &ngx_http_proxy_module); |
634da79665d3
Upstream: refactored proxy_cache and friends.
Valentin Bartenev <vbart@nginx.com>
parents:
5948
diff
changeset
|
4828 if (plcf->upstream.cache_zone == NULL) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4829 return NGX_CONF_ERROR; |
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 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4832 return NGX_CONF_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4833 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4834 |
2672 | 4835 |
4836 static char * | |
4837 ngx_http_proxy_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
4838 { | |
4839 ngx_http_proxy_loc_conf_t *plcf = conf; | |
4840 | |
4841 ngx_str_t *value; | |
4842 ngx_http_compile_complex_value_t ccv; | |
4843 | |
4844 value = cf->args->elts; | |
4845 | |
4947
4251e72b8bb4
Allow the complex value to be defined as an empty string.
Ruslan Ermilov <ru@nginx.com>
parents:
4927
diff
changeset
|
4846 if (plcf->cache_key.value.data) { |
2672 | 4847 return "is duplicate"; |
4848 } | |
4849 | |
4850 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
4851 | |
4852 ccv.cf = cf; | |
4853 ccv.value = &value[1]; | |
4854 ccv.complex_value = &plcf->cache_key; | |
4855 | |
4856 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
4857 return NGX_CONF_ERROR; | |
4858 } | |
4859 | |
4860 return NGX_CONF_OK; | |
4861 } | |
4862 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4863 #endif |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4864 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
4865 |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4866 #if (NGX_HTTP_SSL) |
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 static char * |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4869 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
|
4870 { |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4871 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
|
4872 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4873 ngx_str_t *value; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4874 |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
4875 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
|
4876 return "is duplicate"; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4877 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4878 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4879 value = cf->args->elts; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4880 |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
4881 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
|
4882 |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
4883 if (plcf->upstream.ssl_passwords == NULL) { |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4884 return NGX_CONF_ERROR; |
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 return NGX_CONF_OK; |
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 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4890 #endif |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4891 |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
4892 |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
4893 static char * |
507 | 4894 ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data) |
4895 { | |
4896 #if (NGX_FREEBSD) | |
4897 ssize_t *np = data; | |
4898 | |
673 | 4899 if ((u_long) *np >= ngx_freebsd_net_inet_tcp_sendspace) { |
507 | 4900 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
4901 "\"proxy_send_lowat\" must be less than %d " | |
4902 "(sysctl net.inet.tcp.sendspace)", | |
4903 ngx_freebsd_net_inet_tcp_sendspace); | |
4904 | |
4905 return NGX_CONF_ERROR; | |
4906 } | |
4907 | |
4908 #elif !(NGX_HAVE_SO_SNDLOWAT) | |
4909 ssize_t *np = data; | |
4910 | |
4911 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
4912 "\"proxy_send_lowat\" is not supported, ignored"); | |
4913 | |
4914 *np = 0; | |
4915 | |
4916 #endif | |
4917 | |
4918 return NGX_CONF_OK; | |
4919 } | |
884 | 4920 |
4921 | |
1658 | 4922 #if (NGX_HTTP_SSL) |
4923 | |
7730
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4924 static char * |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4925 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
|
4926 { |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4927 #ifndef SSL_CONF_FLAG_FILE |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4928 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
|
4929 #else |
7ce28b4cc57e
SSL: fixed build by Sun C with old OpenSSL versions.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7786
diff
changeset
|
4930 return NGX_CONF_OK; |
7730
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4931 #endif |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4932 } |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4933 |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
4934 |
1658 | 4935 static ngx_int_t |
8053
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4936 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
|
4937 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
|
4938 { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4939 ngx_uint_t preserve; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4940 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4941 if (conf->ssl_protocols == 0 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4942 && conf->ssl_ciphers.data == NULL |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4943 && 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
|
4944 && 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
|
4945 && 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
|
4946 && 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
|
4947 && 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
|
4948 && conf->ssl_trusted_certificate.data == NULL |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4949 && conf->ssl_crl.data == NULL |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4950 && 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
|
4951 && 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
|
4952 { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4953 if (prev->upstream.ssl) { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4954 conf->upstream.ssl = prev->upstream.ssl; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4955 return NGX_OK; |
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 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4958 preserve = 1; |
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 } else { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4961 preserve = 0; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4962 } |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4963 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4964 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
|
4965 if (conf->upstream.ssl == NULL) { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4966 return NGX_ERROR; |
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 conf->upstream.ssl->log = cf->log; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4970 |
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 * 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
|
4973 * 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
|
4974 */ |
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 if (preserve) { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4977 prev->upstream.ssl = conf->upstream.ssl; |
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 return NGX_OK; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4981 } |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4982 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4983 |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4984 static ngx_int_t |
1658 | 4985 ngx_http_proxy_set_ssl(ngx_conf_t *cf, ngx_http_proxy_loc_conf_t *plcf) |
4986 { | |
4987 ngx_pool_cleanup_t *cln; | |
4988 | |
8053
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4989 if (plcf->upstream.ssl->ctx) { |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4990 return NGX_OK; |
9d98d524bd02
Upstream: optimized use of SSL contexts (ticket #1234).
Maxim Dounin <mdounin@mdounin.ru>
parents:
8042
diff
changeset
|
4991 } |
1658 | 4992 |
5385
7c1f4977d8a0
Proxy: added the "proxy_ssl_protocols" directive.
Andrei Belov <defan@nginx.com>
parents:
5359
diff
changeset
|
4993 if (ngx_ssl_create(plcf->upstream.ssl, plcf->ssl_protocols, NULL) |
1658 | 4994 != NGX_OK) |
4995 { | |
4996 return NGX_ERROR; | |
4997 } | |
4998 | |
5659
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
4999 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
|
5000 if (cln == NULL) { |
7473
8981dbb12254
SSL: fixed potential leak on memory allocation errors.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7371
diff
changeset
|
5001 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
|
5002 return NGX_ERROR; |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
5003 } |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
5004 |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
5005 cln->handler = ngx_ssl_cleanup_ctx; |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
5006 cln->data = plcf->upstream.ssl; |
3fb6615bb87f
Upstream: plugged potential memory leak on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5575
diff
changeset
|
5007 |
7904
419c066cb710
SSL: ciphers now set before loading certificates (ticket #2035).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
5008 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
|
5009 != NGX_OK) |
419c066cb710
SSL: ciphers now set before loading certificates (ticket #2035).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
5010 { |
419c066cb710
SSL: ciphers now set before loading certificates (ticket #2035).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
5011 return NGX_ERROR; |
419c066cb710
SSL: ciphers now set before loading certificates (ticket #2035).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
5012 } |
419c066cb710
SSL: ciphers now set before loading certificates (ticket #2035).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7884
diff
changeset
|
5013 |
8042
c7e25324be11
Upstream: handling of certificates specified as an empty string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8033
diff
changeset
|
5014 if (plcf->upstream.ssl_certificate |
c7e25324be11
Upstream: handling of certificates specified as an empty string.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8033
diff
changeset
|
5015 && 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
|
5016 { |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5017 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
|
5018 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
|
5019 "no \"proxy_ssl_certificate_key\" is defined " |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5020 "for certificate \"%V\"", |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5021 &plcf->upstream.ssl_certificate->value); |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5022 return NGX_ERROR; |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5023 } |
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 if (plcf->upstream.ssl_certificate->lengths |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5026 || plcf->upstream.ssl_certificate_key->lengths) |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5027 { |
7833
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5028 plcf->upstream.ssl_passwords = |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5029 ngx_ssl_preserve_passwords(cf, plcf->upstream.ssl_passwords); |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5030 if (plcf->upstream.ssl_passwords == NULL) { |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5031 return NGX_ERROR; |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5032 } |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5033 |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5034 } else { |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5035 if (ngx_ssl_certificate(cf, plcf->upstream.ssl, |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5036 &plcf->upstream.ssl_certificate->value, |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5037 &plcf->upstream.ssl_certificate_key->value, |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5038 plcf->upstream.ssl_passwords) |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5039 != NGX_OK) |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5040 { |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5041 return NGX_ERROR; |
3ab8e1e2f0f7
Upstream: variables support in certificates.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7831
diff
changeset
|
5042 } |
5900
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5043 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5044 } |
20d966ad5e89
Upstream: add "proxy_ssl_certificate" and friends.
Piotr Sikora <piotr@cloudflare.com>
parents:
5883
diff
changeset
|
5045 |
5661
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5046 if (plcf->upstream.ssl_verify) { |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5047 if (plcf->ssl_trusted_certificate.len == 0) { |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5048 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
|
5049 "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
|
5050 return NGX_ERROR; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5051 } |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5052 |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5053 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
|
5054 &plcf->ssl_trusted_certificate, |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5055 plcf->ssl_verify_depth) |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5056 != NGX_OK) |
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 return NGX_ERROR; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5059 } |
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 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
|
5062 return NGX_ERROR; |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5063 } |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5064 } |
060c2e692b96
Upstream: proxy_ssl_verify and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5660
diff
changeset
|
5065 |
7320
696df3ac27ac
SSL: save sessions for upstream peers using a callback function.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7271
diff
changeset
|
5066 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
|
5067 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
|
5068 != NGX_OK) |
696df3ac27ac
SSL: save sessions for upstream peers using a callback function.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7271
diff
changeset
|
5069 { |
696df3ac27ac
SSL: save sessions for upstream peers using a callback function.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7271
diff
changeset
|
5070 return NGX_ERROR; |
696df3ac27ac
SSL: save sessions for upstream peers using a callback function.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7271
diff
changeset
|
5071 } |
696df3ac27ac
SSL: save sessions for upstream peers using a callback function.
Sergey Kandaurov <pluknet@nginx.com>
parents:
7271
diff
changeset
|
5072 |
7730
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
5073 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
|
5074 != NGX_OK) |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
5075 { |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
5076 return NGX_ERROR; |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
5077 } |
1a719ee45526
Upstream: proxy_ssl_conf_command and friends.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7728
diff
changeset
|
5078 |
1658 | 5079 return NGX_OK; |
5080 } | |
5081 | |
5082 #endif | |
5083 | |
5084 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
5085 static void |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
5086 ngx_http_proxy_set_vars(ngx_url_t *u, ngx_http_proxy_vars_t *v) |
1658 | 5087 { |
2203
8e5bf1bc87e2
*) refactor ngx_parse_inet_url()
Igor Sysoev <igor@sysoev.ru>
parents:
2184
diff
changeset
|
5088 if (u->family != AF_UNIX) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
5089 |
1658 | 5090 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
|
5091 |
1658 | 5092 v->host_header = u->host; |
5093 | |
5094 if (u->default_port == 80) { | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
5095 ngx_str_set(&v->port, "80"); |
1658 | 5096 |
5097 } else { | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
5098 ngx_str_set(&v->port, "443"); |
1658 | 5099 } |
5100 | |
5101 } 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
|
5102 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
|
5103 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
|
5104 v->port = u->port_text; |
1658 | 5105 } |
5106 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
5107 v->key_start.len += v->host_header.len; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
5108 |
1658 | 5109 } else { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
5110 ngx_str_set(&v->host_header, "localhost"); |
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3477
diff
changeset
|
5111 ngx_str_null(&v->port); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2430
diff
changeset
|
5112 v->key_start.len += sizeof("unix:") - 1 + u->host.len + 1; |
1658 | 5113 } |
5114 | |
5115 v->uri = u->uri; | |
5116 } |