nginx ajax 上传文件问题

August 19th, 2010 by admin Leave a reply »

proxy_hide_header Content-Type;

本行注销掉,否则,firefox和chrome ajax上传会出错误。

需要注意的是这部分

#Forward PHP Request TO Apache Server
location ~ \.php$ {
proxy_pass
http://127.0.0.1:81;
proxy_redirect          off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_hide_header Content-Type;
}

作用是将PHP的请求转发给Apache2处理。和DZ商业区的那篇文章区别在于,我将最后一行注释掉了。这一个问题困扰了我一天多。

如果不注释掉的话,结果就是会将Content-type传递给Apache2。

而Discuz!的Ajax功能,用到了/templates/default/header_ajax.htm这个文件,这个文件很奇怪,虽然是.htm,但是在内容里却包含了
{eval @header(“Content-type: application/xml; charset=$charset”);}
具体的用意不知道,但是肯定是和这个Content-Type有关的。结果就是传递出错,造成Discuz!所有使用到AJAX的功能均不正常,包括表情、投票贴内容、评分等等。

注释掉这一段即OK。

Advertisement

Leave a Reply