Reputation: 2558
We have an web application build using node js (express js), which is behind nginx.
For a particular API, we want to have the content-type response header as "text/plain". For this following code is there in controller.
res.setHeader('Content-Type', 'text/plain'); res.send(response);
This works when the server is not behind nginx. But when the server is behind nginx, the response headers are still 'application/json'
nginx configuration is pasted below:
#kZyguser www-data;
user root;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 20000;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
Upvotes: 0
Views: 1704
Reputation: 13809
Have you tried using proxy_pass_header
in nginx?
proxy_pass_header Content-Type;
http://wiki.nginx.org/HttpProxyModule
btw - it seems like your nginx configuration may not be complete in your question.
Upvotes: 1