【发布时间】:2012-12-16 14:36:30
【问题描述】:
我们有一个使用 node js(express js)构建的 web 应用程序,它位于 nginx 后面。
对于特定的 API,我们希望内容类型响应标头为“text/plain”。控制器中有以下代码。
res.setHeader('Content-Type', 'text/plain'); res.send(响应);
这在服务器不在 nginx 后面时有效。但是当服务器在 nginx 后面时,响应头仍然是 'application/json'
nginx配置贴在下面:
#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;
【问题讨论】: