为什么 Django/mod_wsgi 在某些 URL 长度上会崩溃?

发布于 2024-09-24 08:09:50 字数 494 浏览 2 评论 0原文

我在这里遇到了一个奇怪的问题:当提供给 Apache 的 URL 的路径部分的长度在 [23..26,30..33] 中时,我从为 Django 1.1 应用程序提供服务的 Apache 收到 500 错误代码。例如, http://server/012345678901234567890123 会导致 500 错误,而 http://server/012345678901234567 没有。

每个 500 错误还会导致“无法验证请求来源”。日志中来自 mod_wsgi 的错误消息。该错误不会发生在仅限 Apache 的 URL(例如图像)上,只会发生在 Django 上。

知道为什么会发生这种情况吗?

I've got a weird problem here: I'm getting a 500 error code from Apache serving a Django 1.1 application when the length of the path part of the URL given to Apache is in [23..26,30..33]. For example, http://server/012345678901234567890123 results in a 500 error while http://server/012345678901234567 does not.

Each 500 error also results in a "Request origin could not be validated." error message from mod_wsgi in the logs. The error doesn't occur on Apache-only URLs, like images, it only happens with Django.

Any idea why this could be happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三生路 2024-10-01 08:09:50

将其带到 Google 网上论坛上正确的 mod_wsgi 列表,并详细说明您正在使用的 Apache、Python 和 mod_wsgi 版本。还要指出您正在使用哪个 Apache MPM 以及您正在使用的任何其他非标准 Apache 模块。可能是一个想法,说明是否也使用 32 位或 64 位应用程序。

此错误特定于守护程序模式,并且在它到达您的 WSGI 应用程序之前发生。坦率地说,该错误永远不应该发生,除非发生一定程度的内存损坏或一些非常微妙的一次性错误,而由于某种原因,大量现有用户从未发生过这种错误。

近日,又有人报道此事。不过,您似乎已经能够将其与特定的 URL 长度联系起来,这之前没有建议过,但至少是一个线索。

请注意,马上就要放假了。你只有不到 8 个小时的时间让我再认真地看一下它,在那之后我会很难回来。

Take this to the proper mod_wsgi list on Google Groups and detail what versions of Apache, Python and mod_wsgi you are using. Also indicate which Apache MPM you are using and any other non standard Apache modules you are using. Might be an idea to state whether using 32 bit or 64 bit applications as well.

This error is specific to daemon mode and occurs before it even gets to your WSGI application. Frankly the error should never happen unless there is a measure of memory corruption occurring or some very subtle one off error which for some reason has never occurred with the huge number of existing users.

There has been one other person report this recently. You though seem to have been able to tie it to a specific URL length, which hasn't been suggested before and is a clue at least.

Do note, about to go on holidays. You have less that 8 hours for me to have another serious look at it and after that going to be really hard until I get back.

执妄 2024-10-01 08:09:50

这是否可能是您的应用程序代码中的某个错误?

更改站点的 apache 设置,以便 WSGI 创建自己的错误日志

LogLevel info
ErrorLog /tmp/error_log

然后运行

tail -f /tmp/error_log

​​并尝试加载您的长 URL 之一。希望错误消息会出现在日志文件中。至少,它应该查明真正的错误是什么。

Is it possible that this is an error somewhere in your app's code?

Change your apache settings for the site so that WSGI creates its own error log

LogLevel info
ErrorLog /tmp/error_log

Then run

tail -f /tmp/error_log

And try loading in one of your long URLs. Hopefully the error message will come up in the log file. At the very least, it should pinpoint what the real error is.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文