Client-IP HTTP header to X-Forwarded-For
is at rambler-co.ru
Thu May 3 19:23:16 MSD 2007
On Thu, May 03, 2007 at 03:31:44PM +0100, Mike wrote:
> Client requests are through virtual IP's that are handled by a hardware
> load balancer, and then passed onto the real servers on the backend. The
> source IP from the client is NAT'd so that all IP's appear to originate
> from the load balancer. Responses from the real servers are sent back
> via the load balancer to the client.
> On the load balancer, I have enabled, in the configuration, that a
> header be added by the load balancer and passed onto the server that is
> running Nginx (version 0.5.19). The request header that is added and
> passed out to the real server, is as follows:
> Client-IP: myip
> Is there any way to get Nginx to log this IP as the remote_addr or as
> X-Forwarded-For so that the PHP application that Nginx is passing
> requests to will log the real source IP? I realise that there have been
> posts in the past but I have not been able to figure this out.
This header is available in nginx as $http_client_ip.
You can describe it in log_format instead of $remote_ip
and you pass it to FastCGI:
fastcgi_param REMOTE_ADDR $http_client_ip;
More information about the nginx