Opened 22 months ago

Last modified 21 months ago

#1936 closed defect

'set_real_ip_from' in location section is not processed before REWRITE_PHASE — at Version 1

Reported by: p01arbear@… Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.17.x
Keywords: realip_module Cc:
uname -a:
nginx -V: 1.17.8

Description (last modified by p01arbear@…)

For the confuguration

    server {
        listen 1024 proxy_protocol;
        location / {
            real_ip_header proxy_protocol;
            set_real_ip_from 0.0.0.0/0;
            return 200 remote_addr=$remote_addr;
        }       
    } 

response on request

echo -en "PROXY TCP4 4.4.4.4 5.5.5.5 1234 80\r\nGET / \n\n" | nc -q-1 0 1024

is

remote_addr=127.0.0.1

It is wrong address. The same in the access log.

Moving real_ip* directives into the server section or removing 'return' provide the correct result.

    server {
        listen 1024 proxy_protocol;
        real_ip_header proxy_protocol;
        set_real_ip_from 0.0.0.0/0;
        location / {
            return 200 remote_addr=$remote_addr;
        }       
    } 
remote_addr=4.4.4.4

This happens due to missing call of ngx_http_realip_handler() with config of a location on PREACCESS_PHASE.
Because 'return' works off on REWRITE_PHASE.

Change History (1)

comment:1 by p01arbear@…, 22 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.