Vishal
Vishal

Reputation: 10964

Adding http request headers in NGINX

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.

Upvotes: 2

Views: 8952

Answers (1)

Vishal
Vishal

Reputation: 10964

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.

Upvotes: 3

Related Questions