如何将SSL添加到Rails应用程序?

Kam*_*esh 5 ssl ruby-on-rails

在我的项目中,我只想让我的每一个请求都通过SSL完成.怎么实现这个?我的意思是如何将SSL添加到Rails应用程序?

我尝试添加

   config.force_ssl = true
Run Code Online (Sandbox Code Playgroud)

到application.rb.但它显示我这样的错误.

请求无效:HTTP格式无效,解析失败.

/home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/thin-1.6.1/lib/thin/request.rb:84:in `execute'
/home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/thin-1.6.1/lib/thin/request.rb:84:in `parse'
/home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/thin-1.6.1/lib/thin/connection.rb:41:in `receive_data'
/home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
/home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
/home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/thin-1.6.1/lib/thin/backends/base.rb:73:in `start'
/home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/thin-1.6.1/lib/thin/server.rb:162:in `start'
/home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/rack-1.5.2/lib/rack/handler/thin.rb:16:in `run'
/home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/rack-1.5.2/lib/rack/server.rb:264:in `start'
/home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands/server.rb:84:in `start'
/home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:76:in `block in <top (required)>'
/home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
/home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Run Code Online (Sandbox Code Playgroud)

Soo*_*ndu 0

我使用 Rack::SslEnforcer 将 SSL 添加到我的 Rails 应用程序中

机架::SslEnforcer 宝石