# HG changeset patch # User Sergey Kandaurov # Date 1466523512 -10800 # Node ID 2bbab9bd73e5628273526e31e4845907043e2b9a # Parent e9064d6917900eaa25168630a35c7550720b0112 Tests: added proxy_bind test with port. diff --git a/proxy_bind.t b/proxy_bind.t --- a/proxy_bind.t +++ b/proxy_bind.t @@ -26,7 +26,7 @@ plan(skip_all => 'win32') if $^O eq 'MSW 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/)->plan(4) +my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(5) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -63,6 +63,12 @@ http { proxy_bind $arg_b; proxy_pass http://127.0.0.1:%%PORT_1%%/; } + + location /port { + proxy_bind 127.0.0.2:$remote_port; + proxy_pass http://127.0.0.1:%%PORT_1%%/; + add_header X-Client-Port $remote_port; + } } server { @@ -71,6 +77,7 @@ http { location / { add_header X-IP $remote_addr; + add_header X-Port $remote_port; } } } @@ -87,4 +94,11 @@ like(http_get('/inherit'), qr/X-IP: 127. like(http_get('/off'), qr/X-IP: 127.0.0.1/, 'bind off'); like(http_get('/var?b=127.0.0.2'), qr/X-IP: 127.0.0.2/, 'bind var'); +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.11.2'); + +like(http_get('/port'), qr/Port: (\d+)(?!\d).*Port: \1/s, 'bind port'); + +} + ###############################################################################