Opened 4 years ago

Last modified 4 years ago

#1936 closed defect

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

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

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 behaviour.

    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' is works off on REWRITE_PHASE.

Change History (0)

Note: See TracTickets for help on using tickets.