nginx and thttpd + cgi, remote_addr = 127.0.0.1

Кирюшкин Владимир vk at jasystem.net
Wed Oct 26 15:49:34 UTC 2011


Hello,

during applying the patch i've got these warnings:

# patch mini_httpd.c -i realip.patch
patching file mini_httpd.c
patching file mini_httpd.c
Hunk #1 FAILED at 27.
Hunk #2 FAILED at 163.
2 out of 2 hunks FAILED -- saving rejects to file mini_httpd.c.rej

so i've added failed hunks manually.
after installing and configuring i've checked the output from env-script, but REMOTE_ADDR still was 127.0.0.1.
also when i'm requesting that script without any additional headers, it's ok, but when i add "X-Real-IP" it looks like mini-httpd just closes the connection:

# curl -H 'X-Real-IP: 127.0.0.2' http://127.0.0.1:8000/index.cgi 
curl: (52) Empty reply from server

then i've changed "X-Real-IP" to "X-Forwarded-For" in mini_httpd.c:

  else if ( strncasecmp( line, "X-Forwarded-For:", 16 ) == 0 )                     
      {                                                                            
      if ( strcmp(remote_addr, xrealip ) == 0 )                                    
      {                                                                            
    cp = &line[16];                                                                
    cp += strspn( cp, " \t" );                                                     
    remote_addr = cp;                                                              
    }                                                                              
   } 

and after compiling there is same result:

# curl -H 'X-Forwarded-For: 127.0.0.2' http://127.0.0.1:8000/index.cgi
curl: (52) Empty reply from server

with no additional headers script works ok.

Could you please suggest me any other way to run cgi programs with nginx, but with getting real IPs from clients, not "127.0.0.1"?
using apache httpd as backend will be huge performance impact.
Thanks in advance.


Cheers,

Vladimir



More information about the nginx mailing list