【发布时间】:2010-12-07 04:25:04
【问题描述】:
在生产中部署我的 rails 3 应用程序后,我注意到路径并不总是显示在浏览器窗口中。例如,登录或 my_profile 链接仍将仅显示 http://my_app.com 而不是预期的 http://my_app.com/login 或 http://my_app.com/my_profile。这些观点确实发生了变化并且是有效的。我还可以看到数据库被命中并从日志中呈现视图(这让我相信这不是一个简单的浏览器缓存问题)。直接转到http://my_app.com/login 是可行的,但是,使用应用程序中的链接会将我带到预期的位置,同时显示登录 url。我在几个浏览器(firefox、opera 和 chrome)中尝试了它并得到了相同的行为。该应用程序部署在 nginx + 乘客和后来的 nginx + 瘦集群下。我的问题是,发生了什么事?可能是 nginx 设置还是我的生产环境设置?我不知道从哪里开始。
运行 curl -v my_app.com 显示
* About to connect() to my_app.com port 80 (#0)* Trying xx.xx.xx.xx... connected* Connected to my_app.com (xx.xx.xx.xx) port 80 (#0)> GET / HTTP/1.1> User-Agent: curl/7.21.1 (x86_64-apple-darwin10.4.0) libcurl/7.21.1 OpenSSL/1.0.0a zlib/1.2.5 libidn/1.19> Host: my_app.com> Accept: */*
@987654333 @* HTTP 1.0, assume close after body< HTTP/1.0 200 OK< Set-Cookie: ARPT=PKKIKIS10.0.81.64CKILJ; path=/< Content-Type: text/html; charset=utf-8< Status: 200< X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 2.2.5< ETag: "fce6dec3543058bec16175466020a906"< X-Runtime: 7< Content-Length: 787< Cache-Control: private, max-age=0, must-revalidate< Server: nginx/0.7.62 + Phusion Passenger 2.2.4 (mod_rails/mod_rack)< P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"< X-Cache: MISS from server.com< Via: 1.0 server.com:8080< Connection: close<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd"><html><head><title>http://my_app.com/</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /><meta name="generator" content="Hover Redirect Service"></head><frameset framespacing="0" rows="100%,*" cols="100%" frameborder="no" border="0">
@987654358 @<frame name="DDIRECTXYZZY" scrolling="no" noresize><noframes><h1><a href="http://xxx.xx.xxx.xxx">http://my_app.com/</a></h1><p>Please <a href="http://xxx.xx.xxx.xxx">click here</a> to view the non-framed versi
on.</p></noframes></frameset></html>
所以这显然是一个问题。整个事情都被 DNS 重定向框住了?设置不是 Phusion Passenger + nginx。它最初是,但现在它的瘦 + nginx。此外,当直接访问应用程序的 IP 地址时,一切都很好。去域名的时候,我得到的是框架版。 curl -v 只是 IP 地址的响应看起来也很正常(就像它加载整个页面一样)。
【问题讨论】:
-
(非)格式的问题太伤眼了。
-
curl -v http://my_app.com返回什么?
标签: ruby-on-rails path nginx routes production-environment