I have the following example

           location / {
                    proxy_read_timeout 2000;
                    proxy_next_upstream error;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header Host $http_host;
                    proxy_pass_header X_CUSTOM_HEADER;
                    proxy_redirect off;
                    proxy_max_temp_file_size 0;
                    proxy_pass https://prod;
                    break;
            }

Now when i use the following curl line

curl --head -H "X_CUSTOM_HEADER: foo" http://domain.com/api/test

Now that does not work.. the apache/php on the backend doesn't see the header. If I bypass nginx it works

curl --head -H "X_CUSTOM_HEADER: foo" http://web1.domain.com/api/test
link|improve this question

feedback

2 Answers

up vote 2 down vote accepted

You should use underscores_in_headers on directive which is off by default.

link|improve this answer
that was it! thanks! – Mike Aug 5 '11 at 12:54
feedback

You should use proxy_set_header for all headers you wish to forward to the backend servers. So instead of proxy_pass_header ... line:

proxy_set_header X_CUSTOM_HEADER $http_x_custom_header;
link|improve this answer
I have tried that and it doesn't set the header correctly, If i replace $http_x_custom_header with "foo" it works – Mike Aug 3 '11 at 21:23
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.