【问题标题】:HTTPS Redirect in puma only working for the base URLpuma 中的 HTTPS 重定向仅适用于基本 URL
【发布时间】:2019-10-23 21:11:52
【问题描述】:

我的 puma 服务器从 http -> https(开发中)重定向,但只有一个 URL:localhost:3000。一旦我在末尾添加任何内容(即localhost:3000/index),它就不再重定向(并且页面错误)。

我是否缺少配置选项(或需要注释掉)?我目前有:
ssl_bind 'localhost', '3000' { ... } 在 config/puma.rb 和
force_ssl = true 在 config/environments/development.rb。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-5 puma puma-dev


    【解决方案1】:

    force_ssl 应该将所有来自 http 端口的请求重定向到 https,当您尝试通过 http 连接到 https 端口时,它无法执行任何操作。

    http 和 https 应该绑定到不同的端口(@98​​7654322@ 和 ssl_bind 选项)。习惯上在 3000 端口有 http 开发服务器,所以在其他一些端口绑定 ssl(例如 - 8443,https 的标准是 443,但它是特权)

    还为开发指定用于重定向的 ssl_options:

    config.ssl_options = {  redirect: { status: 307, port: 8443 } }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-11
      • 1970-01-01
      • 2012-10-09
      • 2016-07-15
      • 2021-01-30
      • 2015-12-23
      • 2012-03-14
      • 2014-10-28
      相关资源
      最近更新 更多