2014-10-09 40 views
0

我已經構建了一個rails應用並通過heroku將其推向了生產環境。默認地址以https而不是http開頭。我可以強制它以http開頭嗎?在我production.rb文件,我有以下幾點:http替代了heroku站點的https

config.force_ssl = false 

我也試着註釋掉該行,但它仍然無法正常工作。還有什麼我需要做的?

+0

你有SSL證書嗎? – rogelio 2014-10-09 05:31:02

+0

不再。我曾經擁有它,但我最近擺脫了證書,並刪除了ssl – user3575214 2014-10-09 05:44:21

+0

看到我的答案,非常重要有一個,如果你需要這樣做。 – rogelio 2014-10-09 05:58:07

回答

0

你需要做的基本步驟:

  • 購買SSL證書
  • 提供的SSL:端點插件heroku addons:add ssl:endpoint
  • 上傳您的證書
  • 更新您的DNS
  • 配置你的Rails應用程序config.force_ssl = true

欲瞭解更多信息,請參閱this official guidethis another

0

當我得到這個權利,你想強制使用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