comparison stream_proxy_bind.t @ 622:b241c3c0119b

Tests: stream proxy_bind test.
author Andrey Zelenkov <zelenkov@nginx.com>
date Sun, 28 Jun 2015 20:16:21 +0300
parents
children 5f9dfe85a1f2
comparison
equal deleted inserted replaced
621:884b2f0c173f 622:b241c3c0119b
1 #!/usr/bin/perl
2
3 # (C) Andrey Zelenkov
4 # (C) Nginx, Inc.
5
6 # Test for stream proxy_bind directive.
7
8 ###############################################################################
9
10 use warnings;
11 use strict;
12
13 use Test::More;
14
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
16
17 use lib 'lib';
18 use Test::Nginx;
19
20 ###############################################################################
21
22 select STDERR; $| = 1;
23 select STDOUT; $| = 1;
24
25 plan(skip_all => '127.0.0.2 local address required')
26 unless defined IO::Socket::INET->new( LocalAddr => '127.0.0.2' );
27
28 my $t = Test::Nginx->new()->has(qw/http proxy stream/)->plan(1)
29 ->write_file_expand('nginx.conf', <<'EOF');
30
31 %%TEST_GLOBALS%%
32
33 daemon off;
34
35 events {
36 }
37
38 stream {
39 server {
40 listen 127.0.0.1:8081;
41 proxy_bind 127.0.0.2;
42 proxy_pass 127.0.0.1:8082;
43 }
44 }
45
46 http {
47 %%TEST_GLOBALS_HTTP%%
48
49 server {
50 listen 127.0.0.1:8080;
51 server_name localhost;
52
53 location / {
54 proxy_pass http://127.0.0.1:8081;
55 }
56 }
57
58 server {
59 listen 127.0.0.1:8082;
60
61 location / {
62 add_header X-IP $remote_addr;
63 }
64 }
65 }
66
67 EOF
68
69 $t->write_file('index.html', '');
70 $t->run();
71
72 ###############################################################################
73
74 like(http_get('/'), qr/X-IP: 127.0.0.2/, 'bind');
75
76 ###############################################################################