Mercurial > hg > nginx-tests
annotate proxy_protocol2.t @ 1797:0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
author | Eugene Grebenschikov <e.grebenshchikov@f5.com> |
---|---|
date | Wed, 12 Oct 2022 11:55:32 -0700 |
parents | 88a098b00534 |
children | 7102245abedf |
rev | line source |
---|---|
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for haproxy protocol. |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http access realip/); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
1797
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
27 $t->write_file_expand('nginx.conf', <<'EOF')->plan(32); |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 http { |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
39 log_format pp $remote_addr:$remote_port; |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
1794
64f19063adfe
Tests: merged tests for proxy protocol server variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1526
diff
changeset
|
41 add_header X-IP $remote_addr!$remote_port; |
64f19063adfe
Tests: merged tests for proxy protocol server variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1526
diff
changeset
|
42 add_header X-PP $proxy_protocol_addr!$proxy_protocol_port; |
64f19063adfe
Tests: merged tests for proxy protocol server variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1526
diff
changeset
|
43 add_header X-PPS $proxy_protocol_server_addr!$proxy_protocol_server_port; |
1797
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
44 add_header X-TL $proxy_protocol_tlv_0x3-$proxy_protocol_tlv_0x0000ae-$proxy_protocol_tlv_0x0f; |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
45 add_header X-NT $proxy_protocol_tlv_unique_id-$proxy_protocol_tlv_ssl_cn-$proxy_protocol_tlv_ssl_0x22-$proxy_protocol_tlv_ssl_verify; |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
46 add_header X-NT2 $proxy_protocol_tlv_unique_id-$proxy_protocol_tlv_ssl_version-$proxy_protocol_tlv_ssl_0x21-$proxy_protocol_tlv_ssl_verify; |
1794
64f19063adfe
Tests: merged tests for proxy protocol server variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1526
diff
changeset
|
47 |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 server { |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 listen 127.0.0.1:8080 proxy_protocol; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 server_name localhost; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 set_real_ip_from 127.0.0.1/32; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 location /pp { |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 real_ip_header proxy_protocol; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 error_page 404 =200 /t1; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 location /pp_4 { |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 deny 192.0.2.1/32; |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
60 access_log %%TESTDIR%%/pp4.log pp; |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 } |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
62 |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 location /pp_6 { |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 deny 2001:DB8::1/128; |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
65 access_log %%TESTDIR%%/pp6.log pp; |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 } |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 } |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
68 |
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
69 location / { } |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 } |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 } |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 EOF |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 $t->write_file('t1', 'SEE-THIS'); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 $t->run(); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 ############################################################################### |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 my $p = pack("N3C", 0x0D0A0D0A, 0x000D0A51, 0x5549540A, 0x21); |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
81 my $tcp4 = $p . pack("CnN2n2", 0x11, 12, 0xc0000201, 0xc0000202, 123, 5678); |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 my $tcp6 = $p . pack("CnNx8NNx8Nn2", 0x21, 36, |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
83 0x20010db8, 0x00000001, 0x20010db8, 0x00000002, 123, 5678); |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 my $unk1 = $p . pack("Cxx", 0x01); |
1797
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
85 my $tlv = $p . pack("CnN2n2N3", 0x11, 24, 0xc0000201, 0xc0000202, 123, 5678, |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
86 0x03000141, 0xAE000531, 0x32333435); |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
87 my $tlv2 = $p . pack("CnN2n2N7", 0x11, 40, 0xc0000201, 0xc0000202, 123, 5678, |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
88 0x05000555, 0x4E495151,0x20001100, 0xdeadbeef, 0x22000966, 0x6f6f2e62, |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
89 0x61727272); |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
90 my $tlv3 = $p . pack("CnN2n2N5", 0x11, 32, 0xc0000201, 0xc0000202, 123, 5678, |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
91 0x05000555, 0x4E495151,0x20000900, 0x00000000, 0x23000132); |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 my $unk2 = $p . pack("CnC4", 0x41, 4, 1, 2, 3, 4); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 my $r; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 # no realip, just PROXY header parsing |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 $r = pp_get('/t1', $tcp4); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 like($r, qr/SEE-THIS/, 'tcp4 request'); |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
99 like($r, qr/X-PP: 192.0.2.1!123\x0d/, 'tcp4 proxy'); |
1795
88a098b00534
Tests: fixed previous commit mismerge.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1794
diff
changeset
|
100 like($r, qr/X-PPS: 192.0.2.2!5678\x0d/, 'tcp4 proxy server'); |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
101 unlike($r, qr/X-IP: (192.0.2.1|[^!]+!123\x0d)/, 'tcp4 client'); |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 $r = pp_get('/t1', $tcp6); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 like($r, qr/SEE-THIS/, 'tcp6 request'); |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
105 like($r, qr/X-PP: 2001:DB8::1!123\x0d/i, 'tcp6 proxy'); |
1795
88a098b00534
Tests: fixed previous commit mismerge.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1794
diff
changeset
|
106 like($r, qr/X-PPS: 2001:DB8::2!5678\x0d/i, 'tcp6 proxy server'); |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
107 unlike($r, qr/X-IP: (2001:DB8::1|[^!]+!123\x0d)/i, 'tcp6 client'); |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 $r = pp_get('/t1', $tlv); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 like($r, qr/SEE-THIS/, 'tlv request'); |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
111 like($r, qr/X-PP: 192.0.2.1!123\x0d/, 'tlv proxy'); |
1795
88a098b00534
Tests: fixed previous commit mismerge.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1794
diff
changeset
|
112 like($r, qr/X-PPS: 192.0.2.2!5678\x0d/, 'tlv proxy server'); |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
113 unlike($r, qr/X-IP: (192.0.2.1|[^!]+!123\x0d)/, 'tlv client'); |
1797
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
114 like($r, qr/X-TL: A-12345-\x0d/, 'tlv raw variables'); |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
115 like($r, qr/X-NT: ---\x0d/, 'tlv missing variables'); |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
116 |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
117 $r = pp_get('/t1', $tlv2); |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
118 like($r, qr/X-NT: UNIQQ-foo.barrr-foo.barrr-3735928559\x0d/, |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
119 'tlv named variables'); |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
120 |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
121 $r = pp_get('/t1', $tlv3); |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
122 like($r, qr/X-NT2: UNIQQ-2-2-0\x0d/, |
0b06942f0b8b
Tests: http resolver with ipv4/ipv6 parameters.
Eugene Grebenschikov <e.grebenshchikov@f5.com>
parents:
1795
diff
changeset
|
123 'tlv named variables'); |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
125 $r = pp_get('/t1', $unk1); |
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
126 like($r, qr/SEE-THIS/, 'unknown request 1'); |
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
127 like($r, qr/X-PP: !\x0d/, 'unknown proxy 1'); |
1794
64f19063adfe
Tests: merged tests for proxy protocol server variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1526
diff
changeset
|
128 like($r, qr/X-PPS: !\x0d/, 'unknown proxy server 1'); |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
129 |
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
130 $r = pp_get('/t1', $unk2); |
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
131 like($r, qr/SEE-THIS/, 'unknown request 2'); |
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
132 like($r, qr/X-PP: !\x0d/, 'unknown proxy 2'); |
1794
64f19063adfe
Tests: merged tests for proxy protocol server variables.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1526
diff
changeset
|
133 like($r, qr/X-PPS: !\x0d/, 'unknown proxy server 2'); |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 # realip |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 $r = pp_get('/pp', $tcp4); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 like($r, qr/SEE-THIS/, 'tcp4 request realip'); |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
139 like($r, qr/X-PP: 192.0.2.1!123\x0d/, 'tcp4 proxy realip'); |
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
140 like($r, qr/X-IP: 192.0.2.1!123\x0d/, 'tcp4 client realip'); |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 $r = pp_get('/pp', $tcp6); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 like($r, qr/SEE-THIS/, 'tcp6 request realip'); |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
144 like($r, qr/X-PP: 2001:DB8::1!123\x0d/i, 'tcp6 proxy realip'); |
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
145 like($r, qr/X-IP: 2001:DB8::1!123\x0d/i, 'tcp6 client realip'); |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 # access |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 $r = pp_get('/pp_4', $tcp4); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 like($r, qr/403 Forbidden/, 'tcp4 access'); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 $r = pp_get('/pp_6', $tcp6); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 like($r, qr/403 Forbidden/, 'tcp6 access'); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 # client address in access.log |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 $t->stop(); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 |
1526
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
159 is($t->read_file('pp4.log'), "192.0.2.1:123\n", 'tcp4 log'); |
b3bbb59dc324
Tests: merged $proxy_protocol_port tests with the rest for brevity.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1381
diff
changeset
|
160 is($t->read_file('pp6.log'), "2001:db8::1:123\n", 'tcp6 log'); |
1309
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 ############################################################################### |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 sub pp_get { |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 my ($url, $proxy) = @_; |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 return http($proxy . <<EOF); |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 GET $url HTTP/1.0 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 Host: localhost |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 EOF |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 } |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 |
3eb1de7e3b41
Tests: proxy protocol v2 tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 ############################################################################### |