2014-01-14 4 views
1

Я хочу отключить методы отслеживания и отслеживания с помощью htaccess.Как отклонить запросы трассировки через htaccess?

С следующий фрагмент кода в моей Htaccess:

RewriteCond %{REQUEST_METHOD} ^TRAC[EK] 
RewriteRule .* - [L,R=405] 

Я получаю следующие ответы

url -v -X TRACK obscuredurl* Adding handle: conn: 0x7f8c43004400 
* Adding handle: send: 0 
* Adding handle: recv: 0 
* Curl_addHandleToPipeline: length: 1 
* - Conn 0 (0x7f8c43004400) send_pipe: 1, recv_pipe: 0 
* About to connect() to obscuredurl port 80 (#0) 
* Trying xx.xx.xxx.xx... 
* Connected to obscuredurl (xx.xx.xxx.xx) port 80 (#0) 
> TRACK/HTTP/1.1 
> User-Agent: curl/7.30.0 
> Host: obscuredurl 
> Accept: */* 
> 
< HTTP/1.1 405 Method Not Allowed 
< Date: Tue, 14 Jan 2014 09:53:45 GMT 
* Server Apache is not blacklisted 
< Server: Apache 
< Allow: TRACE 
< Content-Length: 296 
< Connection: close 
< Content-Type: text/html; charset=iso-8859-1 
< 
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> 
<html><head> 
<title>405 Method Not Allowed</title> 
</head><body> 
<h1>Method Not Allowed</h1> 
<p>The requested method TRACK is not allowed for the URL /.</p> 
<hr> 
<address>Apache Server at obscuredurl Port 80</address> 
</body></html> 
* Closing connection 0 

И

curl -v -X TRACE obscuredurl 
* Adding handle: conn: 0x7ff339004400 
* Adding handle: send: 0 
* Adding handle: recv: 0 
* Curl_addHandleToPipeline: length: 1 
* - Conn 0 (0x7ff339004400) send_pipe: 1, recv_pipe: 0 
* About to connect() to obscuredurl port 80 (#0) 
* Trying xx.xx.xxx.xx... 
* Connected to obscuredurl (xx.xx.xxx.xx) port 80 (#0) 
> TRACE/HTTP/1.1 
> User-Agent: curl/7.30.0 
> Host: obscuredurl 
> Accept: */* 
> 
< HTTP/1.1 200 OK 
< Date: Tue, 14 Jan 2014 09:55:15 GMT 
* Server Apache is not blacklisted 
< Server: Apache 
< Connection: close 
< Transfer-Encoding: chunked 
< Content-Type: message/http 
< 
TRACE/HTTP/1.1 
User-Agent: curl/7.30.0 
Host: obscuredurl 
Accept: */* 

* Closing connection 0 

Так что, похоже на работу с треком, но не со следом. Также работают два отдельных условия.

Как его отладить?

Благодаря

+0

Чтобы ответить на фактический вопрос: отлаживайте правила перезаписи, включив «RewriteLog» и повысив уровень журнала. Вы также можете просто положить 'TraceEnable off' в глобальный' httpd.conf'. –

+0

[Этот вопрос подразумевает, что ваш подход должен работать нормально] (http://superuser.com/q/655446). –

+0

Я не могу изменить httpd.conf на этом сервере. Это не мое. Возможно ли, что «traceEnable On» в httpd.conf перекрывает htaccess? – noeden

ответ

0

Разница в Apache обработке TRACE и TRACK методов запроса. Как вы заметили TRACK запрос обрабатываются надлежащим образом mod_rewrite правила в Apache, но TRACE обрабатывается Apache на гораздо более высокий уровень даже перед чтением .htacess Вы можете убедиться в том, что, поставив некоторый мусор текст в .htaccess, а затем вызов TRACE запроса, чтобы получить правильный ответ вместо ожидаемого 500 (Internal Server Error).

Вы, возможно, потребуется запросить у администратора сервера, чтобы добавить это в конфигурации сервера Apache:

TraceEnable Off 

выключить TRACE.