# Protecting a Mongrel site with Apache htauth

**URL:** <https://www.ruby-forum.com/t/protecting-a-mongrel-site-with-apache-htauth/104985>\
**Category:** Rails\
**Created:** [May 24, 2007, 5:02pm UTC](https://www.ruby-forum.com/t/protecting-a-mongrel-site-with-apache-htauth/104985 "2007-05-24T17:02:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gareth\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@Gareth\_A](https://www.ruby-forum.com/u/Gareth_A)\
**Post date:** [May 24, 2007, 5:02pm UTC](https://www.ruby-forum.com/t/protecting-a-mongrel-site-with-apache-htauth/104985/1 "2007-05-24T17:02:20Z")

</div>

Hi,

We have a mongrel site running behind Apache using ProxyBalancer to  
manage our  
cluster. We would like to use HTTP Authentication to restrict access to  
the  
site, but Apache’s mod\_auth only protects a directory - this is a  
problem  
because ProxyBalancer siphons off all the Rails requests before mod\_auth  
has a  
chance to kick in.

Is it possible to restrict access to the site with our current setup?

Thanks,  
Gareth

---

<div class="post-metadata">

**Author:** ![Gareth\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@Gareth\_A](https://www.ruby-forum.com/u/Gareth_A)\
**Post date:** [May 25, 2007, 6:46pm UTC](https://www.ruby-forum.com/t/protecting-a-mongrel-site-with-apache-htauth/104985/2 "2007-05-25T18:46:22Z")

</div>

Is it not possible to have a Location directive instead of Directory  
to apply auth to all requests? A while ago I got something like the  
following working:

\<Location / \>  
AllowOverride None  
AuthName “My Rails App”  
AuthType Basic  
AuthUserFile “/path/to/file”

 require valid-user 

Paul.
