在将hero_ssl设为false后,如何清除无限重定向循环? [英] How to remove infinite redirect loop after I set force_ssl to false in heroku?

查看:130
本文介绍了在将hero_ssl设为false后,如何清除无限重定向循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Rails 3.1.0应用程序,需要根据用户在某些页面中具有ssl。

I'm working on a Rails 3.1.0 app that needs to have ssl in some pages depending on the user.

我在config / enviroments / staging.rb中将config.force_ssl设置为false。添加一个以前的过滤器,决定是否重定向到http。如果我清理缓存,重定向工作在开发中。

I setted config.force_ssl to false in config/enviroments/staging.rb. Added a before filter that decides whether or not to redirect to http. The redirect works in development if I clean the cache.

事情正在进行,它会导致重定向循环。我相信force_ssl使用永久重定向,因此当DNS被问及我的应用程序中的页面时,它仍然尝试使用ssl重定向到该页面。这是否有意义?

The thing is in staging, it results in a redirect loop. I believe that force_ssl uses a permanent redirect, therefore when the DNS is asked about a page in my app, it still tries to redirect to the page with ssl. Does this make any sense?

我有什么选择?

编辑

我清理缓存。这只能在第一次进入页面时解决问题。让我说我刷新所有缓存并进入http页面。这将显示http页面。当我退出页面时,输入另一个有ssl的页面,并尝试返回到http页面,无限重新导向重新开始。

I cleaned the cache. This only solves the problem the first time I enter the page. Lets say I refresh all cache and enter the http page. This displays the http page. When I exit the page, enter another page that has ssl and try to go back to the http page, the infinite redirect starts again.

我实现的解决方案是重定向到不安全的子域。让我们称之为不安全。所以当我需要重定向到一个http页面时,我重定向到 http://unsafe.mydomain.com 。这解决了无限重定向,但是一些https页面仍然被缓存。

The solution I implemented was to redirect to a unsafe subdomain. Let's call it 'unsafe'. So when I need to redirect to a http page, I redirect to http://unsafe.mydomain.com. This solves the infinite redirect, but some https pages are still being cached.

我想真正的问题是什么时候使用它是有用的:status =>:moved_permanently因为它似乎它导致页面缓存,清理这个缓存变得很难?

I guess the real question is when is it useful to use :status => :moved_permanently because It seems it causes the page to cache and it becomes dificult to clean this cache?

推荐答案

首先,你为什么不强制SSL对于所有页面?只有很少的性能开销,但以混合模式运行,您会引入潜在的泄漏,如果您不小心,您认为是安全的cookie。 SSL无处不在:)

Firstly, why are you not just forcing SSL for all pages? There is very little performance overhead but running in mixed mode you introduce a the potential of leaking what you thought were secure cookies if you're not careful. SSL everywhere :)

现在您的问题,我怀疑这与DNS有关系,更有可能与模式匹配逻辑的正则表达式重定向。是否包含主机名/域名?如果是这样,它与您在分期中运行的域匹配?

Now to your question, I doubt this has anything to do with DNS and is more likely to do with the regex of pattern matching logic around when it should redirect. Does it include the hostname/domain? If so does it match the domain you run as in staging?

这篇关于在将hero_ssl设为false后,如何清除无限重定向循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆