簡體   English   中英

對於heroku網站,使用http而不是https

[英]http instead of https for heroku sites

我已經構建了一個Rails應用程序,並通過heroku將其推向生產。 默認地址以https而不是http開頭。 我可以強迫它以http開頭嗎? 在我的production.rb文件中,我具有以下內容:

config.force_ssl = false

我也嘗試注釋掉該行,但仍然無法正常工作。 我還有什么需要做的嗎?

您需要執行以下基本步驟:

  • 購買SSL證書
  • 設置ssl:endpoint插件heroku addons:add ssl:endpoint
  • 上載您的證書
  • 更新您的DNS
  • 使用config.force_ssl = true配置您的Rails應用

有關更多信息,請參閱此官方指南其他 指南

當我理解正確時,您想強制使用http而不是https。 我不知道您為什么要這樣做,我也不建議這樣做,但是您可以使用以下答案中的代碼示例:

class ApplicationController < ActionController::Base
  before_filter do
    if request.ssl? && Rails.env.production?
      redirect_to :protocol => 'http://', :status => :moved_permanently
    end
  end
end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM