How to set content-type in proxy_pass? How to set content-type in proxy_pass? json json

How to set content-type in proxy_pass?


I think that the problem here is that you doing a add_header and add_header seems add that header to the response (when request come back from backends to your client), and you want set for your backends.

Syntax:     add_header name value [always];Default:Context:    http, server, location, if in locationAdds the specified field to a response header provided that the response code equals 200, 201, 204, 206, 301, 302, 303, 304, or 307. A value can contain variables. 

You should this line in your conf

proxy_set_header content-type "application/json";

all proxy_* will set for the request (from client to backend way)

Syntax: proxy_set_header field value;Default:

proxy_set_header Host $proxy_host;

proxy_set_header Connection close;Context:    http, server, locationAllows redefining or appending fields to the request header passed to the proxied server. The value can contain text, variables, and their combinations. These directives are inherited from the previous level if and only if there are no proxy_set_header directives defined on the current level. By default, only two fields are redefined: