Mercurial > hg > nginx-tests
annotate proxy_if.t @ 1324:918bf90466e0
Tests: hide startup warnings about deprecated ssl.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 08 May 2018 13:59:22 +0300 |
parents | 0af58b78df35 |
children | dbce8fb5f5f8 |
rev | line source |
---|---|
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for http proxy module related to use with the "if" directive. |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 # See http://wiki.nginx.org/IfIsEvil for more details. |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 ############################################################################### |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use warnings; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 use strict; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 use Test::More; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use lib 'lib'; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 use Test::Nginx; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 ############################################################################### |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 |
535
ee7a6a144437
Tests: added openssl prerequisite in proxy_if.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
514
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http proxy rewrite http_ssl/) |
ee7a6a144437
Tests: added openssl prerequisite in proxy_if.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
514
diff
changeset
|
26 ->has_daemon('openssl')->plan(15); |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 |
592
355f2d5ff60f
Tests: catch nginx alerts on exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
568
diff
changeset
|
28 $t->write_file_expand('nginx.conf', <<'EOF')->todo_alerts(); |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 daemon off; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 events { |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 http { |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
41 listen 127.0.0.1:8080; |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 server_name localhost; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 location / { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
45 proxy_pass http://127.0.0.1:8081/; |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 |
514
42d447013553
Tests: proxy_if.t TODOs adjusted.
Maxim Dounin <mdounin@mdounin.ru>
parents:
510
diff
changeset
|
48 # request was sent to backend without uri changed |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 # to '/' due to if |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 location /proxy-pass-uri { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
52 proxy_pass http://127.0.0.1:8081/replacement; |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 if ($arg_if) { |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 # nothing |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 location /proxy-pass-uri/inner { |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 # no proxy_pass here, static |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 if ($arg_if) { |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 # nothing |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 # same as the above, but there is a special handling |
514
42d447013553
Tests: proxy_if.t TODOs adjusted.
Maxim Dounin <mdounin@mdounin.ru>
parents:
510
diff
changeset
|
68 # in configuration merge; it used to do wrong things with |
42d447013553
Tests: proxy_if.t TODOs adjusted.
Maxim Dounin <mdounin@mdounin.ru>
parents:
510
diff
changeset
|
69 # nested locations though |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 location /proxy-pass-uri-lmt { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
72 proxy_pass http://127.0.0.1:8081/replacement; |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 limit_except POST { |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 # nothing |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 location /proxy-pass-uri-lmt/inner { |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 # no proxy_pass here, static |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 limit_except POST { |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 # nothing |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 location /proxy-pass-uri-lmt-different { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
88 proxy_pass http://127.0.0.1:8081/replacement; |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 limit_except POST { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
91 proxy_pass http://127.0.0.1:8081; |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 # segmentation fault in old versions, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 # fixed to return 500 Internal Error in nginx 1.3.10 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 location /proxy-inside-if-crash { |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 set $true 1; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 if ($true) { |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 # proxy_pass inside if |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
104 proxy_pass http://127.0.0.1:8081; |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 if ($true) { |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 # no handler here |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 # normal proxy_pass and proxy_pass with variables |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 # use distinct field, and inheritance should be mutually |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 # exclusive |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 location /variables { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
117 proxy_pass http://127.0.0.1:8081/outer/$host; |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 if ($arg_if) { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
120 proxy_pass http://127.0.0.1:8081; |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 location /variables/inner { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
124 proxy_pass http://127.0.0.1:8081; |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 # ssl context shouldn't be inherited into nested |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 # locations with different proxy_pass, but should |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 # be correctly inherited into if's |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 location /ssl { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
133 proxy_pass https://127.0.0.1:8082/outer; |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 if ($arg_if) { |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 # inherited from outer |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
137 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 location /ssl/inner { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
140 proxy_pass http://127.0.0.1:8081; |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
146 listen 127.0.0.1:8081; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
147 listen 127.0.0.1:8082 ssl; |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 server_name localhost; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
149 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 ssl_certificate localhost.crt; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
151 ssl_certificate_key localhost.key; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 return 200 "uri:$uri\n"; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 EOF |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
158 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
159 $t->write_file('openssl.conf', <<EOF); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 [ req ] |
1116
8ef51dbb5d69
Tests: reduced OpenSSL default key length to 1024.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
161 default_bits = 1024 |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
162 encrypt_key = no |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
163 distinguished_name = req_distinguished_name |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
164 [ req_distinguished_name ] |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
165 EOF |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
166 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
167 my $d = $t->testdir(); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
168 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
169 foreach my $name ('localhost') { |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
170 system('openssl req -x509 -new ' |
1220
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
171 . "-config $d/openssl.conf -subj /CN=$name/ " |
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1116
diff
changeset
|
172 . "-out $d/$name.crt -keyout $d/$name.key " |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
173 . ">>$d/openssl.out 2>&1") == 0 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
174 or die "Can't create certificate for $name: $!\n"; |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 } |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
176 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
177 $t->run(); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
178 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
179 ############################################################################### |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
180 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
181 like(http_get('/'), qr!uri:/$!, 'proxy request'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
182 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
183 like(http_get('/proxy-pass-uri'), qr!uri:/replacement$!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
184 'proxy_pass uri changed'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
185 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
186 # due to missing information about an original location where |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
187 # proxy_pass was specified, this used to pass request with |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
188 # original unmodified uri |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
189 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
190 like(http_get('/proxy-pass-uri?if=1'), qr!uri:/replacement$!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
191 'proxy_pass uri changed in if'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
192 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
193 like(http_get('/proxy-pass-uri/inner'), qr!404 Not Found!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
194 'proxy_pass uri changed inner'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
195 like(http_get('/proxy-pass-uri/inner?if=1'), qr!404 Not Found!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
196 'proxy_pass uri changed inner in if'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
197 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
198 # limit_except |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
199 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
200 like(http_get('/proxy-pass-uri-lmt'), qr!uri:/replacement$!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
201 'proxy_pass uri and limit_except'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
202 |
514
42d447013553
Tests: proxy_if.t TODOs adjusted.
Maxim Dounin <mdounin@mdounin.ru>
parents:
510
diff
changeset
|
203 # special handling of limit_except resulted in wrong handling |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
204 # of requests in nested locations |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
205 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
206 like(http_get('/proxy-pass-uri-lmt/inner'), qr!404 Not Found!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
207 'proxy_pass uri and limit_except, inner'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
208 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
209 like(http_get('/proxy-pass-uri-lmt-different'), |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
210 qr!uri:/proxy-pass-uri-lmt-different!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
211 'proxy_pass and limit_except with different proxy_pass'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
212 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
213 # segmentation fault in old versions, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
214 # fixed to return 500 Internal Error in nginx 1.3.10 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
215 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
216 like(http_get('/proxy-inside-if-crash'), qr!500 Internal Server Error!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
217 'proxy_pass inside if'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
218 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
219 # normal proxy_pass and proxy_pass with variables |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
220 # use distinct field, and inheritance should be mutually |
510
4892d701d558
Tests: fixed ticket number in proxy_if.t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
509
diff
changeset
|
221 # exclusive, see ticket #645 |
509
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
222 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
223 like(http_get('/variables'), qr!uri:/outer!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
224 'proxy_pass variables'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
225 like(http_get('/variables?if=1'), qr!uri:/variables!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
226 'proxy_pass variables if'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
227 like(http_get('/variables/inner'), qr!uri:/variables/inner!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
228 'proxy_pass variables nested'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
229 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
230 # ssl context shouldn't be inherited into nested |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
231 # locations with different proxy_pass, but should |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
232 # be correctly inherited into if's |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
233 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
234 like(http_get('/ssl'), qr!uri:/outer!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
235 'proxy_pass ssl'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
236 like(http_get('/ssl?if=1'), qr!uri:/outer!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
237 'proxy_pass ssl inside if'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
238 like(http_get('/ssl/inner'), qr!uri:/ssl/inner!, |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
239 'proxy_pass nossl inside ssl'); |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
240 |
f135127e97af
Tests: various proxy_pass + if tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
241 ############################################################################### |