incoming X-Forwarded-For in conditional evaulation

Francis Daly francis at
Wed Oct 27 15:48:46 MSD 2010

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 = "") { proxy_set_header
> X-Forwarded-For ""; }
> 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: gives some examples like

  if ($http_user_agent ~ MSIE) {


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

which suggest the pattern used; while says


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

All the best,

Francis Daly        francis at

More information about the nginx mailing list