nginx and thttpd + cgi, remote_addr =

Francis Daly francis at
Tue Oct 25 22:10:11 UTC 2011

On Wed, Oct 26, 2011 at 01:11:40AM +0400, Кирюшкин Владимир wrote:

Hi there,

> /etc/nginx/proxy.conf has such options among others:
> proxy_set_header        X-Real-IP       $remote_addr; 
> proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

That should cause two variables HTTP_X_REAL_IP and HTTP_X_FORWARDED_FOR
to be visible in the CGI output.

> and I have patched latest thttpd ( with this patch:

That patch looks like it will write the value of the X-Forwarded-For
header into something internal to thttpd.

> #!/bin/sh
> echo "Content-type: text/html; charset=UTF-8";
> echo;
> echo "i am cgi script<br><br>";
> echo "env: <br><br>";
> env

What are HTTP_X_REAL_IP and HTTP_X_FORWARDED_FOR in the output of this
cgi script?

If they are not what you expect, check what nginx is doing.

If they are what you expect, check what your patched thttpd is doing.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list