| # Tests for http proxy_bind transparent. |
| ############################################################################### |
| BEGIN { use FindBin; chdir($FindBin::Bin); } |
| ############################################################################### |
| plan(skip_all => 'win32') if $^O eq 'MSWin32'; |
| plan(skip_all => 'must be root') if $> != 0; |
| plan(skip_all => '127.0.0.2 local address required') |
| unless defined IO::Socket::INET->new( LocalAddr => '127.0.0.2' ); |
| my $t = Test::Nginx->new()->has(qw/http proxy/) |
| ->write_file_expand('nginx.conf', <<'EOF'); |
| proxy_bind 127.0.0.2 transparent; |
| proxy_pass http://127.0.0.1:8081/; |
| add_header X-IP $remote_addr; |
| $t->write_file('index.html', ''); |
| $t->try_run('no proxy_bind transparent')->plan(1); |
| ############################################################################### |
| like(http_get('/'), qr/X-IP: 127.0.0.2/, 'transparent'); |
| ############################################################################### |