force_ssl导致永无止境的重定向

Rails 3.1.3

有了force_ssl,我就会一遍又一遍地重定向,它永远不会结束。 我要去httpsurl,所以我不确定为什么它会抱怨。 想法?

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 

这里回答: 为什么我在Rails应用程序中使用force_ssl获得无限重定向循环?

Spoiler:将其添加到您的nginx配置文件中:

 proxy_set_header X-Forwarded-Proto $scheme; 

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

在你的nginx配置更改:

 listen 443 default ssl; 

至:

 listen 443; ssl on; 

对pjammer的信用: Nginx配置导致无限重定向循环