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