我已經構建了一個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