# How to protect with password apache2.2.4+mogrel?

**URL:** <https://www.ruby-forum.com/t/how-to-protect-with-password-apache2-2-4-mogrel/113109>\
**Category:** Deployment\
**Created:** [August 27, 2007, 7:15pm UTC](https://www.ruby-forum.com/t/how-to-protect-with-password-apache2-2-4-mogrel/113109 "2007-08-27T19:15:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rafa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e495f1/32.png) [@rafa](https://www.ruby-forum.com/u/rafa)\
**Post date:** [August 27, 2007, 7:15pm UTC](https://www.ruby-forum.com/t/how-to-protect-with-password-apache2-2-4-mogrel/113109/1 "2007-08-27T19:15:00Z")

</div>

Hello,

```
I need protect a rails application. I have the application in a

```

virtual host(see below) in their configuration I used Auth\* directives  
but don’t work fine.It ask for the user/pass but If I cancel it show the  
page without images, css, … (all hosted in public directory).

How I can protect all my application?

Thanks!

=======================  
virtual host config file:

\<Proxy balancer://foobar\_cluster\>  
BalancerMember [http://127.0.0.1:7995](http://127.0.0.1:7995)

# Setup the VirtualHost for your Rails application

\<VirtualHost \*:80\>  
ServerAdmin removed\_email\_address@domain.invalid  
ServerName [foobar.com](http://foobar.com)  
ServerAlias \*.foobar.com  
DocumentRoot /home/foobar/current/public  
\<Directory ‘/home/foobar/current/public’\>  
Options FollowSymLinks  
AllowOverride None  
Order allow,deny  
Allow from all

```
AuthType Basic
AuthName "Realm..."
AuthUserFile /usr/local/apache2/conf/.passwd_web
Require valid-user

```

# Not supported on Mac OS X.

EnableSendfile On

# Allow Rails to delegate the service of static resources.

XSendFile on  
XSendFileAllowAbove on

# Setup your Rewrite rules here

RewriteEngine On

# This rewrites all dynamic requests to /system/maintenance.html if

that

# file exists, this file is created by Capistrano’s disable task.

RewriteCond %{DOCUMENT\_ROOT}/system/maintenance.html -f  
RewriteCond %{SCRIPT\_FILENAME} !maintenance.html  
RewriteRule ^.\*$ /system/maintenance.html [L]

# Rewrite to check for Rails cached page, we don’t use caches at this

moment

# RewriteRule ^([^.]+)$ $1.html [QSA]

# Redirect all non-static requests to the cluster.

RewriteCond %{DOCUMENT\_ROOT}%{REQUEST\_FILENAME} !-f  
RewriteRule ^/(.\*)$ balancer://foobar\_cluster%{REQUEST\_URI} [P,QSA,L]

# Compress common non-binary content.

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css  
application/x-javascript

# Error logs

ErrorLog “|/usr/local/apache2/bin/rotatelogs  
/usr/local/apache2/logs/foobar\_error\_log\_%Y%m%d 86400”  
CustomLog “|/usr/local/apache2/bin/rotatelogs  
/usr/local/apache2/logs/foobar\_access\_log\_%Y%m%d 86400” combined  
env=!dontlog

#Fix for Apache bug 39499  
SetEnv force-proxy-request-1.0 1  
SetEnv proxy-nokeepalive 1

---

<div class="post-metadata">

**Author:** ![rafa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e495f1/32.png) [@rafa](https://www.ruby-forum.com/u/rafa)\
**Post date:** [August 28, 2007, 6:24pm UTC](https://www.ruby-forum.com/t/how-to-protect-with-password-apache2-2-4-mogrel/113109/2 "2007-08-28T18:24:51Z")

</div>

Hi,

You need to specify the same Authorization directives in your Proxy  
definition:

\<Proxy balancer://foobar\_cluster\>  
BalancerMember [http://127.0.0.1:7995](http://127.0.0.1:7995)  
AuthType Basic  
AuthName “Realm…”  
AuthUserFile /usr/local/apache2/conf/.passwd\_web  
Require valid-user

Best,

n.

---

<div class="post-metadata">

**Author:** ![rafa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e495f1/32.png) [@rafa](https://www.ruby-forum.com/u/rafa)\
**Post date:** [August 29, 2007, 11:45am UTC](https://www.ruby-forum.com/t/how-to-protect-with-password-apache2-2-4-mogrel/113109/3 "2007-08-29T11:45:51Z")

</div>

Nate Perry-Thistle  
escribió:\> Hi,

> Best,
> 
> n.

Thanks Nate!
