giorgio <george.peverell@...> writes:

> 
> I get lots of stuff in my logs like:
> ActionController::UnknownHttpMethod (PROPFIND, accepted HTTP methods
> are get, head, put, post, delete, and options):
> 
> I'd like to reject this stuff before it hits rails and clogs passenger
> and then the error log.
> 
> How can I make Apache reject some urls/requests before passing them on
> to Rails.
> 
> I'm sure I can stick something in .htaccess with mod_rewrite or
> something but I dont want to do it by trail and error if there is a
> good recipe somewhere.
> 
> It wont get all of them but I get hundreds of attempts at /
> manager.html and /phppgadmin and stuff like that that fills the rails
> log and obscures more valuable log entries.
> 
> Cheers
> George
> 

Sounds like a good job for a Rack filter.  Something like:

config.middleware.use 'HttpVerbResponder',
  'PROPFIND' => [404, {}, 'Not supported'],
  'PURGE' => [404, {}, 'Not supported'],
  'OPTIONS' => [200, {"Access-Control-Allow-Origin" => "*", "Access-Control-
Max-Age" => '1000'},'OK"]


class HttpVerbResponder
  def initialize(app, options={})
    @app = app
    @options = options
  end

  def call(env, options={})
    if response = @options[env['REQUEST_METHOD']]
      response
    else
      @app.call(env)
    end
  end
end


From: http://grosser.it/2011/04/07/custom-response-for-weird-http-vers-like-
profind-purge-options-etc/



-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to