我的rails应用程序在我的笔记本电脑上工作正常,但它在亚马逊服务器上不起作用。我用chrome打开它,浏览器什么都没显示,HTTP标题如下:
HTTP/1.1 200
Content-Type: text/html; charset=utf-8
Content-Length: 0
Connection: keep-alive
Status: 302
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.7
如果我运行rails server
,它确实有效,我可以获得正确的HTML。 Nginx无法生成正确的content-length
?
nginx config
server {
listen 8000;
server_name xxxx;
root /xxx/xxx/public;
passenger_enabled on;
rails_env development;
location = /favicon.ico {
expires max;
add_header Cache-Control public;
}
location ~* \.(png|gif|jpg|jpeg|css|js|swf|ico)(\?[0-9]+)?$ {
access_log off;
expires max;
add_header Cache-Control public;
}
}
http原始消息在
下面返回总共3496个字节,内容长度错误,所以浏览器会读取其余的html
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 0
Connection: keep-alive
Status: 200
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.7
X-UA-Compatible: IE=Edge
ETag: "12aa68a45bf774886311f827d2149cbe"
Cache-Control: max-age=0, private, must-revalidate
X-Runtime: 0.499998
Server: nginx/1.1.6 + Phusion Passenger 3.0.7 (mod_rails/mod_rack)
<!DOCTYPE html>
<html>
<head>
<title>xxxx</title>
......
答案 0 :(得分:0)
HTTP状态302通常是重定向。还有其他标题或正文内容吗?我希望有一个位置标题告诉浏览器重定向到哪里。