Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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;
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.