# HG changeset patch # User Andrey Zelenkov # Date 1441985768 -10800 # Node ID a894f041244e39bd7acefb22ea6d0ef715b10a31 # Parent 26f58787c6b4052f17f53c4e29a5fe8d4c9f646b Tests: corrected simple realip tests. First realip test was changed to real_ip_header directive test with default value. Added real_ip_header test with custom string value. diff --git a/realip.t b/realip.t --- a/realip.t +++ b/realip.t @@ -36,21 +36,25 @@ http { %%TEST_GLOBALS_HTTP%% add_header X-IP $remote_addr; - real_ip_header X-Forwarded-For; + set_real_ip_from 127.0.0.1/32; + set_real_ip_from 10.0.1.0/24; server { listen 127.0.0.1:8080; server_name localhost; + location / { } + location /custom { + real_ip_header X-Real-IP-Custom; + } + location /1 { - set_real_ip_from 127.0.0.1/32; - set_real_ip_from 10.0.1.0/24; + real_ip_header X-Forwarded-For; real_ip_recursive off; } location /2 { - set_real_ip_from 127.0.0.1/32; - set_real_ip_from 10.0.1.0/24; + real_ip_header X-Forwarded-For; real_ip_recursive on; } } @@ -58,18 +62,33 @@ http { EOF +$t->write_file('index.html', ''); +$t->write_file('custom', ''); $t->write_file('1', ''); $t->write_file('2', ''); $t->run(); plan(skip_all => 'no 127.0.0.1 on host') - if http_get('/1') !~ /X-IP: 127.0.0.1/m; + if http_get('/') !~ /X-IP: 127.0.0.1/m; -$t->plan(6); +$t->plan(7); ############################################################################### -like(http_xff('/1', '192.0.2.1'), qr/^X-IP: 192.0.2.1/m, 'realip'); +like(http(<