nginx and thttpd + cgi, remote_addr =

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


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
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:' 
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:'
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 ""?
using apache httpd as backend will be huge performance impact.
Thanks in advance.



More information about the nginx mailing list