How to protect directory in Mongrel

Hi Rails Gurus,

I just noticed that mongrel does not process .htaccess.
How can I password protect a directory in mongrel then?
I’ve search everyone and cannot find an answer. Please help!!!

Mongdar wrote:

Hi Rails Gurus,

I just noticed that mongrel does not process .htaccess.
How can I password protect a directory in mongrel then?
I’ve search everyone and cannot find an answer. Please help!!!

I don’t believe you can.


Michael W.

On 19 Sep 2007, at 08:15, Mongdar wrote:

I just noticed that mongrel does not process .htaccess.
How can I password protect a directory in mongrel then?
I’ve search everyone and cannot find an answer. Please help!!!

You can’t do it so easily.

You have a few options:

  • Put Apache in front of mongrel and password protect the directory
    using Apache
  • Make a controller in Rails with the same name as your directory to
    protect (if it’s in the /public/ folder) and deny access that way
  • If the chance that they’ll guess the name of the files is almost
    non-existant, you can just put an index.html file in the folder
  • If you want a dialog box to pop up for login into your app,
    restful_authentication has some example code on how to handle this
    (it uses it for authenticated XML requests)

Best regards

Peter De Berdt