【问题标题】:force_ssl causes never-ending redirectsforce_ssl 导致永无止境的重定向
【发布时间】:2012-03-05 06:45:23
【问题描述】:

Rails 3.1.3

使用 force_ssl 我一遍又一遍地得到这个重定向,它永远不会结束。我要去 https url,所以我不确定它为什么会抱怨。想法?

Started GET "/app/admin/calendar" for 69.64.227.254 at 2012-02-13 19:52:44 +0000
  Processing by Admin::CalendarsController#show as HTML
  User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 21 ORDER BY lower(first) ASC LIMIT 1
  Account Load (0.6ms) SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = 23 AND (accounts.deleted_at IS NULL) LIMIT 1
Redirected to https://www.mydomain.net/app/admin/calendar
Completed 301 Moved Permanently in 4ms

【问题讨论】:

  • 您用于运行应用程序的网络服务器是什么?
  • 请发布您的 nginx 配置。
  • 谢谢大家,我现在似乎可以通过在 nginx 中完成所有工作并从 rails 中删除 force_ssl 来实现它。

标签: ruby-on-rails ruby-on-rails-3 ssl


【解决方案1】:

如果您使用config.force_ssl = true 并最终陷入无限循环,请尝试以下操作:

在您的 nginx 配置更改中:

listen 443 default ssl;

到:

listen 443;
ssl on;

感谢 pjammer:Nginx configuration leads to endless redirect loop

【讨论】:

  • 这对我不起作用,请参阅下面的答案,其中链接到另一个确实解决了问题的 Stack Overflow 问题。
【解决方案2】:

在这里回答:Why am I getting infinite redirect loop with force_ssl in my Rails app?

剧透:将此添加到您的 nginx 配置文件中:

proxy_set_header X-Forwarded-Proto $scheme;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-18
    • 1970-01-01
    • 1970-01-01
    • 2011-12-06
    • 1970-01-01
    • 1970-01-01
    • 2011-11-22
    相关资源
    最近更新 更多