【问题标题】:Rails - Account Activation not redirecting to httpsRails - 帐户激活未重定向到 https
【发布时间】:2015-10-20 22:15:56
【问题描述】:

我让我的邮件发送一个帐户激活链接,如下所示:

edit_account_activation_url(@user.activation_token,电子邮件:@user.email)

制作:

http://MYAPPHOST/account_activation/7Apxg0G5t2V5tHrO2tatPQ/edit?email=sdf%40oiu.com

当我将它更改为 https 但它没有被重定向时有效。我已经有 config.force_ssl = true 所以我不确定如何启用这个重定向。任何帮助表示赞赏。

每当我转到 http://MYAPP 时,我都会被重定向到 about:blank

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-4 railstutorial.org


    【解决方案1】:

    我假设这是在您的生产环境中?您使用的是什么托管服务提供商和/或服务器(Heroku、AWS 和 Apache、NGINX 等)。

    检查您的网络服务器的 SSL 设置,尤其是 X-Forwarded-Proto 标头。当 HTTPS 请求到达 Apache/NGINX 时,它们将终止 SSL 连接并向 Unicorn/Puma/Thin/Webrick 发送 HTTP 请求。除非您设置 X-Forwarded-Proto 标头,否则您的 Rails 服务器将看到 protocol=HTTP。这将导致您的 x_y_z_url 助手返回 http://... 而不是 https://...

    例如,在 NGINX 中:

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-13
      • 1970-01-01
      • 2016-03-11
      相关资源
      最近更新 更多