Skip to content

Commit 14b7e5b

Browse files
committed
Tests: added realip test on http post read phase.
1 parent 00e2425 commit 14b7e5b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

realip.t

+15-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use Test::Nginx;
2121
select STDERR; $| = 1;
2222
select STDOUT; $| = 1;
2323

24-
my $t = Test::Nginx->new()->has(qw/http realip/);
24+
my $t = Test::Nginx->new()->has(qw/http realip rewrite/);
2525

2626
$t->write_file_expand('nginx.conf', <<'EOF');
2727
@@ -41,8 +41,13 @@ http {
4141
4242
server {
4343
listen 127.0.0.1:8080;
44+
listen 127.0.0.1:8081;
4445
server_name localhost;
4546
47+
if ($server_port = 8081) {
48+
return 204;
49+
}
50+
4651
location / { }
4752
location /custom {
4853
real_ip_header X-Real-IP-Custom;
@@ -71,7 +76,7 @@ $t->run();
7176
plan(skip_all => 'no 127.0.0.1 on host')
7277
if http_get('/') !~ /X-IP: 127.0.0.1/m;
7378

74-
$t->plan(7);
79+
$t->plan(8);
7580

7681
###############################################################################
7782

@@ -113,6 +118,14 @@ X-Forwarded-For: 127.0.0.1
113118
114119
EOF
115120

121+
my $s = IO::Socket::INET->new('127.0.0.1:' . port(8081));
122+
like(http(<<EOF, socket => $s), qr/ 204 .*192.0.2.1/s, 'realip post read');
123+
GET / HTTP/1.0
124+
Host: localhost
125+
X-Real-IP: 192.0.2.1
126+
127+
EOF
128+
116129
###############################################################################
117130

118131
sub http_xff {

0 commit comments

Comments
 (0)