atom feed2 messages in ru.sysoev.nginxRe: incoming X-Forwarded-For in condi...
FromSent OnAttachments
Andrey SemyonovOct 27, 2010 3:38 am 
Francis DalyOct 27, 2010 4:48 am 
Subject:Re: incoming X-Forwarded-For in conditional evaulation
From:Francis Daly (fran@daoine.org)
Date:Oct 27, 2010 4:48:23 am
List:ru.sysoev.nginx

On Wed, Oct 27, 2010 at 02:38:35PM +0400, Andrey Semyonov wrote:

Hi there,

I've tried to filter like this: if ($http_X-Forwarded-For = "1.2.3.4") { proxy_set_header X-Forwarded-For "1.2.3.4"; } but that didn't work. How do I evaluate incoming custom HTTP headers (those not having their own dedicated variables like $content_length and others) in config file?

Without having tested whether this if/set works here:

http://wiki.nginx.org/HttpRewriteModule#if gives some examples like

if ($http_user_agent ~ MSIE) {

and

if ($http_cookie ~* "id=([^;] +)(?:;|$)" ) {

which suggest the pattern used; while

http://wiki.nginx.org/HttpCoreModule#Variables says

""" $http_HEADER

The value of the HTTP header HEADER when converted to lowercase and with 'dashes' converted to 'underscores', e.g. $http_user_agent, $http_referer...; """

All the best,

f