Phusion Passenger - 路线存在但不匹配(改为 404)
我在 phusion 乘客环境(CentOS、apache)的根级别运行 Rails 3 应用程序,尽管 rake paths
正确显示了路线,但很难让乘客找到一些路线。开发中一切正常(即使用rails server
而不是apache中的phusion Passenger)。
我的应用程序有一个带有登录页面的管理部分。应用程序的主要部分可以工作,但管理部分下的所有内容都无法访问,因为我得到的是 404 而不是登录页面(当我禁用登录时,我可以访问管理页面)。我的apache配置是
<VirtualHost *:80>
ServerName foo.bar.com
DocumentRoot /var/www/apps/myapp/current/public
<Directory /var/www/apps/myapp/current/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
我的登录过程是作为管理控制器中的before_filter实现的:
class Admin::AdminController < ApplicationController
# login disabled for testing
before_filter :require_login
def require_login
@current_user ||= User.find_by_id(session[:user_id])
redirect_to admin_login_path unless @current_user
end
end
我的路由文件有
Mpf::Application.routes.draw do
secure_protocol = "https://"
...
namespace "admin" do
...
match "login" => "user_sessions#new", :as => :login, :constraints => { :protocol => secure_protocol }
...
end
...
end
,当我运行rake路由时,我得到
admin_login /admin/login(.:format) {:protocol=>"http://", :action=>"new", :controller=>"admin/user_sessions"}
但是当我尝试访问http://foo.bar.com/admin 我收到 404 错误,日志显示
Started GET "/admin/login" for iii.iii.iii.iii at 2011-07-13 07:20:41 -0400
ActionController::RoutingError (No route matches "/admin/login"):
据我所知它应该可以工作......除了它的事实不是。任何帮助将不胜感激!
I'm running a rails 3 app at the root level in a phusion passenger environment (CentOS, apache) and having difficulty getting passenger to find some routes, although rake routes
shows the routes correctly. Everything works fine in development (i.e. using rails server
instead of phusion passenger in apache).
I have an admin section to my app with a login page. The main part of the app works, but everything under the admin section is inaccessible because I get a 404 instead of the login page (when I disable login I can access the admin pages). My apache config is
<VirtualHost *:80>
ServerName foo.bar.com
DocumentRoot /var/www/apps/myapp/current/public
<Directory /var/www/apps/myapp/current/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
My login process is implemented as a before_filter in an admin controller:
class Admin::AdminController < ApplicationController
# login disabled for testing
before_filter :require_login
def require_login
@current_user ||= User.find_by_id(session[:user_id])
redirect_to admin_login_path unless @current_user
end
end
My routes file has
Mpf::Application.routes.draw do
secure_protocol = "https://"
...
namespace "admin" do
...
match "login" => "user_sessions#new", :as => :login, :constraints => { :protocol => secure_protocol }
...
end
...
end
and when I run rake routes I get
admin_login /admin/login(.:format) {:protocol=>"http://", :action=>"new", :controller=>"admin/user_sessions"}
BUT when I try to access http://foo.bar.com/admin I get a 404 and the log shows
Started GET "/admin/login" for iii.iii.iii.iii at 2011-07-13 07:20:41 -0400
ActionController::RoutingError (No route matches "/admin/login"):
As far as I can tell it should be working... except for the fact that it's not. Any help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过使用
https://
访问?您似乎提供了限制来阻止从http://
以及您发布的引用引用http://
的链接进行访问。Have you tried accessing with
https://
? It looks like you provided constraints to prevent access fromhttp://
and the link you posted referenceshttp://
.