5 messages in ru.sysoev.nginxRe: Client-IP HTTP header to X-Forwar...
FromSent OnAttachments
MikeMay 3, 2007 7:31 am 
Igor SysoevMay 3, 2007 8:22 am 
MikeMay 3, 2007 10:07 am 
Igor SysoevMay 3, 2007 11:53 am 
MikeMay 3, 2007 12:35 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Client-IP HTTP header to X-Forwarded-ForActions...
From:Mike (list@public.gmane.org)
Date:May 3, 2007 10:07:14 am
List:ru.sysoev.nginx

Igor Sysoev wrote:

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;

Hi Igor

Thanks for the fast and accurate response.

I did a search against the $http_client_ip string on the wiki and nothing showed up, so unless anyone has any objections, I'll add this with my use-case scenario.