Mercurial > hg > nginx-tests
annotate proxy_protocol_ipv6.t @ 1021:ebdf239722b9
Tests: relaxed proxy_cache_lock.t nolock tests to fix on Solaris.
Assumed that the order of responses being arrived in nolock case may be ignored.
An important part of such case is that the only last response should be cached.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 02 Sep 2016 12:17:35 +0300 |
parents | 196d33c2bb45 |
children | cf14cfe9ec8c |
rev | line source |
---|---|
811
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for haproxy protocol on IPv6 listening socket. |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
815
9f5f604a840e
Tests: skip proxy_protocol_ipv6.t on hosts without IPv6 support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
811
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http ipv6 realip stream/); |
811
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 $t->write_file_expand('nginx.conf', <<'EOF'); |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 http { |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
40 listen [::1]:%%PORT_8080%% proxy_protocol; |
811
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server_name localhost; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 add_header X-IP $remote_addr; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 add_header X-PP $proxy_protocol_addr; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 real_ip_header proxy_protocol; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 location / { } |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 location /pp { |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 set_real_ip_from ::1/128; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 error_page 404 =200 /t; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 } |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 } |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 } |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 stream { |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
57 listen 127.0.0.1:8080; |
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
58 proxy_pass [::1]:%%PORT_8080%%; |
811
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 proxy_protocol on; |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 } |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 } |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 EOF |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 $t->write_file('t', 'SEE-THIS'); |
815
9f5f604a840e
Tests: skip proxy_protocol_ipv6.t on hosts without IPv6 support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
811
diff
changeset
|
67 $t->try_run('no inet6 support')->plan(3); |
811
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 ############################################################################### |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 my $r = http_get('/t'); |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 like($r, qr/X-IP: ::1/, 'realip'); |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 like($r, qr/X-PP: 127.0.0.1/, 'proxy protocol'); |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 $r = http_get('/pp'); |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 like($r, qr/X-IP: 127.0.0.1/, 'proxy protocol realip'); |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
dba758c045ed
Tests: proxy protocol tests on IPv6 socket.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 ############################################################################### |