繁体   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