我随机看到没有路线匹配[GET]" /"应用日志中的错误。这是输出。
[LG53P2]2016-10-25 02:46:20 +0000 severity=FATAL, ActionController::RoutingError (No route matches [GET] "/"): FATAL
[LG53P2] actionpack (4.2.7.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
[LG53P2] actionpack (4.2.7.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
[LG53P2] railties (4.2.7.1) lib/rails/rack/logger.rb:38:in `call_app'
[LG53P2] railties (4.2.7.1) lib/rails/rack/logger.rb:22:in `call'
[LG53P2] actionpack (4.2.7.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
[LG53P2] rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
[LG53P2] rack (1.6.4) lib/rack/runtime.rb:18:in `call'
[LG53P2] activesupport (4.2.7.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
[LG53P2] actionpack (4.2.7.1) lib/action_dispatch/middleware/static.rb:120:in `call'
[LG53P2] rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
[LG53P2] actionpack (4.2.7.1) lib/action_dispatch/middleware/ssl.rb:24:in `call'
[LG53P2] skylight (0.10.5) lib/skylight/middleware.rb:61:in `call'
[LG53P2] railties (4.2.7.1) lib/rails/engine.rb:518:in `call'
[LG53P2] railties (4.2.7.1) lib/rails/application.rb:165:in `call'
[LG53P2] puma (3.4.0) lib/puma/configuration.rb:224:in `call'
[LG53P2] puma (3.4.0) lib/puma/server.rb:569:in `handle_request'
[LG53P2] puma (3.4.0) lib/puma/server.rb:406:in `process_client'
[LG53P2] puma (3.4.0) lib/puma/server.rb:271:in `block in run'
[LG53P2] puma (3.4.0) lib/puma/thread_pool.rb:114:in `call'
[LG53P2] puma (3.4.0) lib/puma/thread_pool.rb:114:in `block in spawn_thread'
该应用程序是私有的,并且由极少数人使用,并且没有用户遇到此错误(无法访问root_path)。我从来没有在日志之外看到它。我认为这可能是一个机器人进行扫描。
routes.rb
文件包含正确的信息:
constraints subdomain: "the_subdomain" do
scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
root to: 'my_controller/static#home'
end
.... other routes
end
rake路线输出似乎正常:
root GET /(:locale)(.:format) my_controller/static#home
此时应用程序经常被使用,这个bug只是日志中的一个小故障而已。但我认为值得一提!
有关可能导致此错误的原因以及我是否可以对此做些什么的任何想法?
答案 0 :(得分:1)
使用给定的信息,nginx代理对Rails应用程序的所有请求。如果通过IP地址或自定义DNS条目直接访问主机,则第一个应用程序将获取请求。
由于root_path
仅限于子域,因此会出现给定的路由错误。
有多种解决方案。首先,限制nginx仅将已知子域路由到Rails应用程序。其次,在约束之外添加路由,并使用特殊的控制器和操作记录此类请求。第三,将未知子域重定向到特殊站点。