繁体   English   中英

在 Apache 服务器上禁用 OPTIONS HTTP

[英]Disable OPTIONS HTTP on Apache Server

Request:
OPTIONS / HTTP/1.1
Host: webcat.staci.com
Connection: Keep-alive
Accept-Encoding: gzip,deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.21 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.21
Accept: */*

Response:
HTTP/1.1 200 OK
Date: Thu, 01 Oct 2015 12:24:59 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Allow: GET,HEAD,POST,OPTIONS,TRACE
Vary: Accept-Encoding,User-Agent
Content-Length: 0
Keep-Alive: timeout=7, max=95
Connection: Keep-Alive
Content-Type: httpd/unix-directory
Set-Cookie: BIGipServerwebcat-ssl=192938503.47873.0000; path=/; httponly; secure

我想在我的 Apache 服务器上禁用 HTTP 选项,但我想保留GETPOST并且我想PING我的服务器。

我怎么能那样做?

我的 httpd.conf:

RewriteEngine On
RewriteCond %{REQUEST_METHOD} !^ (GET,POST,HEAD)
RewriteRule .* – [R=405,L]

无法使用 RewriteCond 禁用 OPTIONS 方法。 您必须使用 LimitExcept 指令禁用。

以下是可以在 Apache 配置之外添加的代码段:

<Location />
    <LimitExcept GET POST>
        order deny,allow
        deny from all
    </LimitExcept>
</Location>

请不要忘记重新启动 Web 服务器 :)

如果您想将其应用于特定项目:

只需将这些行添加到.htaccess文件对我.htaccess

RewriteCond %{REQUEST_METHOD} ^(OPTIONS)
RewriteRule .* - [F]

为此,请确保您已启用mod_rewrite并在这些行之前使用RewriteEngine On

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM