本文介绍了10内部重定向 - 可这个限制提高?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户端运行到一些500错误使用CDN的时候。这些错误表明有太多的内部重定向,我们的研究证实了这一点。客户端不希望调整其内部重定向,并希望以另一种方式来解决这个问题。

I have a client running into some 500 errors when using a CDN. These errors indicate that there are too many internal redirects, and our research confirms that. The client does not want to adjust their internal redirects, and wants to address this problem in another way.

根据我的研究,到目前为止,这似乎是一个硬工资帽这不是针对任何一个类型的Web服务器,并在地方,以避免无休止的循环。话虽这么说,有什么办法来提高此限制 - 例如20,而不是10

Based on my research so far, this seems like a hard cap which is not specific to any one type of web server, and is in place to avoid endless loops. That being said, is there any way to raise this limit - for instance to 20 instead of 10?

例如:结果
1)浏览器>> 9重定向>>产地200页(9重定向总)结果
2)浏览器>> 9重定向>>起源提供自定义的404页(+1重定向定制404 - 10重定向总)结果
3)浏览器>> CDN(从自定义规则+1重定向)>> 9重定向>>产地200页(10重定向总)结果
4)浏览器>> CDN(+1从自定义规则重定向)>> 9重定向>>原产自定义给出了404页(+1重定向定制404 - 11重定向计)

Example:
1) Browser >>9 redirects>> Origin 200 page (9 redirects total)
2) Browser >>9 redirects>> Origin gives custom 404 page (+1 redirect for custom 404 - 10 redirects total)
3) Browser >> CDN (+1 redirect from custom rule) >>9 redirects>> Origin 200 page (10 redirects total)
4) Browser >> CDN (+1 redirect from custom rule) >>9 redirects>> Origin gives custom 404 page (+1 redirect for custom 404 - 11 redirects total)

唯一的例子4给出了一个500错误。不调整重定向配置或删除CDN,有没有什么办法来解决这个问题? (不幸的是,我不能在重定向,我向你道歉的详细信息提供htaccess的)。

Only example 4 gives a 500 error. Without adjusting the redirect configuration or removing the CDN, is there any way to get around this? (Unfortunately, I cannot provide htaccess for more info on the redirects, my apologies).

推荐答案

不幸的是谁决定多少重定向它愿意遵循HTTP客户端。你看到的限制,从最初在在:

Unfortunately it is the HTTP client who decides how many redirects it is willing to follow. The limitation you see stems from a recommendation originally given in RFC 2068, sec 10.3 and quoted again in RFC 7231, sec 6.4:

本规范的早期版本,建议最多五个重定向[...]内容开发者需要注意,一些客户可能会实现这样一个固定的限制。

多少重定向会打的浏览器限制粗略估计可以在this回答。大多数浏览器允许配置此限制(如Firefox是露出设置)。

A rough estimate on how many redirects are going to hit the limit for browsers can be found in this answer. Most browsers allow to configure this limit (e.g. Firefox is exposing the network.http.redirection-limit setting).

Web服务器则是一个不同的问题:看来阿帕奇不得不为的 RewriteOptions 指令中的 MaxRedirects 选项HREF =htt​​p://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#RewriteOptions相对=nofollow> v2.0.45 和的。该设置似乎已经接管了这一点。我一直无法找到nginx的等效设置。

Webservers then are a different matter: It appears Apache had the MaxRedirects option for the RewriteOptions directive between v2.0.45 and 2.1. The LimitInternalRecursion setting seems to have taken over for this. I've been unable to find an equivalent setting for nginx.

最后要注意:如果你真的看到这么多的内部的重定向(即重定向那些只重写引擎内执行,并不会导致真正的HTTP立即重定向),这可能是一个强大的指标来修改你的重写规则。

As a final note: If you are really seeing this many internal redirects (i.e. redirects that are only performed within the rewrite engine and do not lead to real HTTP redirects immediately), this may be a strong indicator to revise your rewrite rules.

这篇关于10内部重定向 - 可这个限制提高?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 07:55
查看更多