apache 可以配置为忽略 OPTIONS 请求吗?

发布于 2024-08-21 12:04:57 字数 455 浏览 9 评论 0原文

我为工作中的几个部门运行一个小型网络应用程序,该应用程序的流量非常低,并且没有那么多用户。它构建在 Django 之上,并使用 apache 作为 Web 服务器。 我配置了一些东西,可以在发生任何错误时向我发送电子邮件,直到昨天这还是一件很棒的事情 - 错误不多,但有时用户在遇到问题时不会说出来,因此它使我能够掌握最新情况。

昨天我们有了一个新用户,我开始收到大量错误电子邮件。他不知道出了什么问题,所以我认为这是幕后的事情。当我查看日志时,它们是使用“Microsoft 数据访问 Internet 发布提供商协议”和“Microsoft Office 协议发现”的 HTTP OPTIONS 请求。在那之前我从未听说过这个,但它似乎是某种 MS Web 文件夹/webDAV 的东西。

一个选择是弄清楚他如何关闭它并告诉他停止这样做,但我宁愿在这里砍掉头并做一些类似让 apache 不将这些请求传递给 Django 的事情有没有一种方法可以这可以处理吗?

I run a small webapp for a couple of departments at work, which is very low traffic and doesn't have that many users. It's built on top of Django and uses apache as the web server.
I have things configured to email me when any errors occur which until yesterday was a great thing - there aren't many errors, but sometimes the users don't speak up when they encounter problems, so it allows me to stay on top of things.

Yesterday we had a new user, and I started getting tons of error emails. He had no idea that anything was wrong, so I figured it was something behind the scenes. When I looked at the logs, they are HTTP OPTIONS requests which are using the "Microsoft Data Access Internet Publishing Provider Protocol" and "Microsoft Office Protocol Discovery". I'd never heard of this until that point, but it appears to be some sort of MS web folders/webDAV thing.

One option is to figure out how he can turn that off and tell him to stop doing that, but I'd rather just cut the head off here and do something like have apache just not pass on those requests to Django Is there a way that this can be handled?

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

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

发布评论

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

评论(3

黒涩兲箜 2024-08-28 12:04:57

重写选项很好,“Apache Way”可能更像是:

<LimitExcept GET POST>
deny from all
</LimitExcept>

或者......

<Limit OPTIONS>
deny from all
</Limit>

The rewrite option is good, the 'Apache Way' is probably more like:

<LimitExcept GET POST>
deny from all
</LimitExcept>

or...

<Limit OPTIONS>
deny from all
</Limit>
烟沫凡尘 2024-08-28 12:04:57

我找到了一个由不同框架使用的解决方案并移植到 Django。我将其放置在生成带有 .XLS 或 .DOC 文件链接的 HTML 的任何视图的顶部:

if request.method == 'OPTIONS':
    response = HttpResponse()
    response['Allow'] = 'GET, HEAD, POST'
    return response

不过,我更喜欢 Apache 解决方案...假设它不会在 Windows 方面造成问题。

I found a solution used by a different framework and ported to Django. I place this at the top of any view that generate HTML with links to .XLS or .DOC files:

if request.method == 'OPTIONS':
    response = HttpResponse()
    response['Allow'] = 'GET, HEAD, POST'
    return response

I like Apache solution better though... assuming it doesn't cause problems on the Windows side of things.

夜吻♂芭芘 2024-08-28 12:04:57

怎么样:(

RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^OPTION
RewriteRule .* - [F]

启用mod_rewrite。)

How about:

RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^OPTION
RewriteRule .* - [F]

(With mod_rewrite enabled.)

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