comparison proxy_bind_transparent.t @ 915:1ffb16747167

Tests: proxy_bind transparent tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Sat, 23 Apr 2016 11:03:54 +0300
parents
children 6af0421615ea
comparison
equal deleted inserted replaced
914:3ac4036b139d 915:1ffb16747167
1 #!/usr/bin/perl
2
3 # (C) Sergey Kandaurov
4 # (C) Nginx, Inc.
5
6 # Tests for http proxy_bind transparent.
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 => 'win32') if $^O eq 'MSWin32';
26 plan(skip_all => '127.0.0.2 local address required')
27 unless defined IO::Socket::INET->new( LocalAddr => '127.0.0.2' );
28
29 my $t = Test::Nginx->new()->has(qw/http proxy/)
30 ->write_file_expand('nginx.conf', <<'EOF');
31
32 %%TEST_GLOBALS%%
33
34 daemon off;
35
36 events {
37 }
38
39 http {
40 %%TEST_GLOBALS_HTTP%%
41
42 server {
43 listen 127.0.0.1:8080;
44 server_name localhost;
45
46 location / {
47 proxy_bind 127.0.0.2 transparent;
48 proxy_pass http://127.0.0.1:8081/;
49 }
50 }
51
52 server {
53 listen 127.0.0.1:8081;
54 server_name localhost;
55
56 location / {
57 add_header X-IP $remote_addr;
58 }
59 }
60 }
61
62 EOF
63
64 $t->write_file('index.html', '');
65 $t->try_run('no proxy_bind transparent')->plan(1);
66
67 ###############################################################################
68
69 like(http_get('/'), qr/X-IP: 127.0.0.2/, 'transparent');
70
71 ###############################################################################