ruby-on-rails – 带有Ruby on Rails的SSL

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 带有Ruby on Rails的SSL前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要做什么来获取流量到我的 ruby在rails应用程序使用https?我安装了一个证书,如果在访问该网站时手动输入地址栏中的“https://”,则会出现小锁图标,但是只需手动访问我的浏览器中的www.example-app.com就可以通过http ://.

有一些单行配置还是比这更复杂?我从来没有必须处理过SSL,所以请原谅我,如果我听起来不知道发生了什么.

我在MediaTemple的主持人(gs),如果重要或任何人有这样的设置的经验.

解决方法

查看 ssl_requirement宝石.

它允许您在控制器中指定哪些操作应通过https提供,哪些操作可以通过https提供.然后,它将重新定位从http到https,反之亦然.

从文档:

  1. class ApplicationController < ActiveRecord::Base
  2. include SslRequirement
  3. end
  4.  
  5. class AccountController < ApplicationController
  6. ssl_required :signup,:payment
  7. ssl_allowed :index
  8.  
  9. def signup
  10. # Non-SSL access will be redirected to SSL
  11. end
  12.  
  13. def payment
  14. # Non-SSL access will be redirected to SSL
  15. end
  16.  
  17. def index
  18. # This action will work either with or without SSL
  19. end
  20.  
  21. def other
  22. # SSL access will be redirected to non-SSL
  23. end
  24. end

猜你在找的Ruby相关文章