incoming X-Forwarded-For in conditional evaulation

Andrey Semyonov gatekeeper.mail at
Wed Oct 27 14:38:35 MSD 2010


I've set up nginx as a front-end for apache with mod_rpaf.

My config (parts that are meaningful for this thread) is:
http {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $remote_addr;

    server {
        listen 80;
        server_name ~^www\.domain\.com$;
        location / {
This works fine. But now I need to bypass original incoming
X-Forwarded-For without change if it equals to '' or ''.

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?

More information about the nginx mailing list