无需插入以下中间件:仅在使用Nginx

如何解决无需插入以下中间件:仅在使用Nginx

我正在尝试将Nginx与docker容器中的乘客一起使用。 如果我使用乘客独立启动Rails应用程序,它将正常运行:

bundle exec passenger start --engine=builtin --max-pool-size=6 --min-instances=3

但是,如果我尝试将Nginx用于同一rails应用程序,则会出现此错误

App 21674 output: Using /usr/local/rvm/gems/ruby-2.6.6
App 21674 output: I,[2020-09-14T05:02:50.855329 #21674]  INFO -- sentry: ** [Raven] Raven 2.13.0 ready to catch errors
App 21674 output: I,[2020-09-14T05:02:51.103254 #21674]  INFO -- : Installing Passenger worker loop.
App 21674 output: Error: The application encountered the following error: No such middleware to insert before: Actiondispatch::Static (RuntimeError)
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/actionpack-5.2.4.1/lib/action_dispatch/middleware/stack.rb:108:in `assert_index'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/actionpack-5.2.4.1/lib/action_dispatch/middleware/stack.rb:75:in `insert'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/configuration.rb:71:in `block in merge_into'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/configuration.rb:70:in `each'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/configuration.rb:70:in `merge_into'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/engine.rb:509:in `block in app'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/engine.rb:506:in `synchronize'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/engine.rb:506:in `app'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/initializable.rb:32:in `instance_exec'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/initializable.rb:32:in `run'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/initializable.rb:61:in `block in run_initializers'
App 21674 output:     /usr/local/rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
App 21674 output:     /usr/local/rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
App 21674 output:     /usr/local/rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
App 21674 output:     /usr/local/rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
App 21674 output:     /usr/local/rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:347:in `each'
App 21674 output:     /usr/local/rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:347:in `call'
App 21674 output:     /usr/local/rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
App 21674 output:     /usr/local/rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
App 21674 output:     /usr/local/rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/initializable.rb:60:in `run_initializers'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/application.rb:361:in `initialize!'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/railtie.rb:190:in `public_send'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/railtie.rb:190:in `method_missing'
App 21674 output:     /home/app/webapp/config/environment.rb:7:in `<top (required)>'
App 21674 output:     config.ru:3:in `require'
App 21674 output:     config.ru:3:in `block in <main>'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/rack-2.1.2/lib/rack/builder.rb:71:in `instance_eval'
App 21674 output:     /home/app/webapp/vendor/ruby/2.6.0/gems/rack-2.1.2/lib/rack/builder.rb:71:in `initialize'
App 21674 output:     config.ru:1:in `new'
App 21674 output:     config.ru:1:in `<main>'
App 21674 output:     /usr/share/passenger/helper-scripts/rack-preloader.rb:101:in `eval'
App 21674 output:     /usr/share/passenger/helper-scripts/rack-preloader.rb:101:in `preload_app'
App 21674 output:     /usr/share/passenger/helper-scripts/rack-preloader.rb:189:in `block in <module:App>'
App 21674 output:     /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:378:in `run_block_and_record_step_progress'
App 21674 output:     /usr/share/passenger/helper-scripts/rack-preloader.rb:188:in `<module:App>'
App 21674 output:     /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
App 21674 output:     /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'
[ E 2020-09-14 05:02:52.8967 20550/Tt age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /home/app/webapp: The application encountered the following error: No such middleware to insert before: Actiondispatch::Static (RuntimeError)
  Error ID: 24ac5443
  Error details saved to: /tmp/passenger-error-iabMgj.html

[ E 2020-09-14 05:02:52.9028 20550/Tc age/Cor/Con/CheckoutSession.cpp:276 ]: [Client 3-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 24ac5443. Please see earlier logs for details about the error.

我的Nginx webapp.conf:

server {
    listen 80 default_server;

    root /home/app/webapp/public;
    
    passenger_app_env production;
    passenger_enabled on;
    passenger_user app;
    
    passenger_ruby /usr/bin/ruby2.6;
    
}

有什么主意吗?

编辑

oot@0c78d3e01f5b:/home/app/webapp# bundle exec rake middleware
I,[2020-09-14T08:22:47.642428 #27056]  INFO -- sentry: ** [Raven] Raven 2.13.0 ready to catch errors
use Raven::Rack
use Rack::Sendfile
use FontAssets::Middleware
use Actiondispatch::Static
use Actiondispatch::Executor
use Dragonfly::CookieMonster
use ActiveSupport::Cache::Strategy::LocalCache::Middleware
use Rack::Runtime
use Rack::Methodoverride
use Actiondispatch::RequestId
use Actiondispatch::RemoteIp
use Rails::Rack::Logger
use Actiondispatch::ShowExceptions
use Actiondispatch::DebugExceptions
use Actiondispatch::Callbacks
use Actiondispatch::Cookies
use Actiondispatch::Session::CookieStore
use Actiondispatch::Flash
use Actiondispatch::ContentSecurityPolicy::Middleware
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
use Rack::TempfileReaper
use Warden::Manager
use Rack::Deflater
use GitRevisionMiddleware
use ScoutApm::Middleware
use OmniAuth::Builder
use OmniAuth::Builder
use OmniAuth::Strategies::Facebook
run MYRAILSAPP::Application.routes
root@0c78d3e01f5b:/home/app/webapp# RAILS_ENV=production bundle exec rake middleware
I,[2020-09-14T08:23:09.023311 #27289]  INFO -- sentry: ** [Raven] Raven 2.13.0 ready to catch errors
use Raven::Rack
use Rack::Sendfile
use FontAssets::Middleware
use Actiondispatch::Static
use Actiondispatch::Executor
use Dragonfly::CookieMonster
use ActiveSupport::Cache::Strategy::LocalCache::Middleware
use Rack::Runtime
use Rack::Methodoverride
use Actiondispatch::RequestId
use Actiondispatch::RemoteIp
use Rails::Rack::Logger
use Actiondispatch::ShowExceptions
use Actiondispatch::DebugExceptions
use Actiondispatch::Callbacks
use Actiondispatch::Cookies
use Actiondispatch::Session::CookieStore
use Actiondispatch::Flash
use Actiondispatch::ContentSecurityPolicy::Middleware
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
use Rack::TempfileReaper
use Warden::Manager
use Rack::Deflater
use GitRevisionMiddleware
use ScoutApm::Middleware
use OmniAuth::Builder
use OmniAuth::Builder
use OmniAuth::Strategies::Facebook
run MYRAILSAPP::Application.routes

解决方法

删除font_assets宝石。

发生这种情况是因为在ActionDisptach:Static之前调用了font_assets RackMiddleWare。

还请注意,fon_assets gem仅在资产未在生产中进行预编译时才有效。请参考https://github.com/ericallam/font_assets#important。如果使用nginx对资产进行了预编译和服务,请参考nginx config

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?