我已经构建了一个rails应用并通过heroku将其推向了生产环境。默认地址以https而不是http开头。我可以强制它以http开头吗?在我production.rb文件,我有以下几点:http替代了heroku站点的https
config.force_ssl = false
我也试着注释掉该行,但它仍然无法正常工作。还有什么我需要做的?
我已经构建了一个rails应用并通过heroku将其推向了生产环境。默认地址以https而不是http开头。我可以强制它以http开头吗?在我production.rb文件,我有以下几点:http替代了heroku站点的https
config.force_ssl = false
我也试着注释掉该行,但它仍然无法正常工作。还有什么我需要做的?
你需要做的基本步骤:
heroku addons:add ssl:endpoint
config.force_ssl = true
欲了解更多信息,请参阅this official guide或this another:
当我得到这个权利,你想强制使用HTTP来代替https的。我不知道你为什么要这样做,我不建议这样做,但你可以使用this answer的代码示例:
class ApplicationController < ActionController::Base
before_filter do
if request.ssl? && Rails.env.production?
redirect_to :protocol => 'http://', :status => :moved_permanently
end
end
end
你有SSL证书吗? – rogelio 2014-10-09 05:31:02
不再。我曾经拥有它,但我最近摆脱了证书,并删除了ssl – user3575214 2014-10-09 05:44:21
看到我的答案,非常重要有一个,如果你需要这样做。 – rogelio 2014-10-09 05:58:07