我有这个问题与Web应用程序检查软件。 build议在Web服务器上禁用OPTION METHODS 。
经研究。 我已经包含这个片段在我的httpd.conf然后重新启动服务器。
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so RewriteEngine On RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS) RewriteRule .* - [F]
我如何validation代码是否被实现,并将阻止所有的选项请求?
我已经试过了
curl --request OPTIONS http://10.1.1.1/mysite
但是我所得到的是301被Permantently移动
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>301 Moved Permanently</title> </head><body> <h1>Moved Permanently</h1> <p>The document has moved <a href="http://10.1.1.1/mysite">here</a>.</p> <hr> <address>Apache/2.2.22 (Ubuntu) Server at 10.1.1.1 Port 80</address> </body></html>
而不是使用mod_rewrite,你应该能够使用Limit或LimitExcept指令来禁止任意方法, 这些指令只是为了你想要的。
您可以使用nc或telnet来testing直接与httpd进程交谈
$ nc yourhost.tld 80 OPTIONS / HTTP/1.1 Host: yourhost.tld (press enter a couple of times here and the server responds) HTTP/1.1 200 OK Date: Mon, 16 Dec 2013 09:16:40 GMT Server: Apache Allow: GET,HEAD,POST,OPTIONS,TRACE Content-Length: 0 Connection: close Content-Type: text/html; charset=UTF-8 $