File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ use Test::Nginx;
21
21
select STDERR ; $| = 1;
22
22
select STDOUT ; $| = 1;
23
23
24
- my $t = Test::Nginx-> new()-> has(qw/ http realip/ );
24
+ my $t = Test::Nginx-> new()-> has(qw/ http realip rewrite / );
25
25
26
26
$t -> write_file_expand(' nginx.conf' , <<'EOF' );
27
27
@@ -41,8 +41,13 @@ http {
41
41
42
42
server {
43
43
listen 127.0.0.1:8080;
44
+ listen 127.0.0.1:8081;
44
45
server_name localhost;
45
46
47
+ if ($server_port = 8081) {
48
+ return 204;
49
+ }
50
+
46
51
location / { }
47
52
location /custom {
48
53
real_ip_header X-Real-IP-Custom;
@@ -71,7 +76,7 @@ $t->run();
71
76
plan(skip_all => ' no 127.0.0.1 on host' )
72
77
if http_get(' /' ) !~ / X-IP: 127.0.0.1/m ;
73
78
74
- $t -> plan(7 );
79
+ $t -> plan(8 );
75
80
76
81
# ##############################################################################
77
82
@@ -113,6 +118,14 @@ X-Forwarded-For: 127.0.0.1
113
118
114
119
EOF
115
120
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
+
116
129
# ##############################################################################
117
130
118
131
sub http_xff {
You can’t perform that action at this time.
0 commit comments