2

Is there any way to add in request header while sending it to proxy server? I tried using add_header as well as proxy_set_header but it did not work for me.

Below is the headers.conf file content I tried:

Trial1:

proxy_set_header X-Name "Vishal";

Trial2:

add_header X-Name "Vishal";

My nginx\conf\includes\proxy.conf:

location /api/mysvc/v1 {

        proxy_pass "https://mockable.io/mysvc/v1/";
        proxy_pass_request_headers      on;
        proxy_set_header X-Name "Vishal";

}

I want to pass along this request header in every ajax request my app makes.

4
  • 1
    proxy_set_header is the correct directive to use. Where is headers.conf included? What does the block containing the proxy_pass statement look like? Commented May 1, 2018 at 9:28
  • @RichardSmith updated answer Commented May 1, 2018 at 9:45
  • It works for me. Commented May 1, 2018 at 10:27
  • @RichardSmith just realised I should not add the proxy_set_header in my headers.conf file. Had to keep only in proxy.conf file for it to work. More so, these headers are not logged in browser debugging tool. Thanks much! Commented May 1, 2018 at 10:38

1 Answer 1

3

Just realised I should not add the proxy_set_header in my headers.conf file. Had to keep only in proxy.conf file for it to work. More so, these headers are not logged in browser debugging tool.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.