# HTTP\_REFERER + apache + mongrel\_cluster

**URL:** <https://www.ruby-forum.com/t/http-referer-apache-mongrel-cluster/103806>\
**Category:** Deployment\
**Created:** [May 10, 2007, 3:14pm UTC](https://www.ruby-forum.com/t/http-referer-apache-mongrel-cluster/103806 "2007-05-10T15:14:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pidja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@pidja](https://www.ruby-forum.com/u/pidja)\
**Post date:** [May 10, 2007, 3:14pm UTC](https://www.ruby-forum.com/t/http-referer-apache-mongrel-cluster/103806/1 "2007-05-10T15:14:09Z")

</div>

Hi, I’m using configuration Apache 2.2 + Mongrel cluster  
and I can not obtain information in my Rails app from  
@request.env[“HTTP\_REFERER”]

Does anybody know how to setup apache.conf to pass http referer to  
mongrel cluster.  
This works for webrick but not in Apache+mongrel\_cluster configuration.

This is my current apache conf.

\<VirtualHost 192.168.1.5\>  
ServerName [domain.com](http://domain.com)  
#NameVirtualHost [domain.com](http://domain.com)  
ServerAlias [www.domain.com](http://www.domain.com)

DocumentRoot /var/www/apps/domain.com/current/public

# I use utf-8 for all my projects, so I force apache to send the good

charset by default.

# This is needed if you use page caching and want apache serves these

with the good charset.

# 

AddDefaultCharset utf-8

# Do not allow open proxying, allow only requests starting with a /

\<LocationMatch “^[^/]”\>  
Deny from all

# Avoid open you server to proxying

ProxyRequests Off

# Let apache pass the original host not the ProxyPass one

ProxyPreserveHost On

\<Directory /var/www/apps/lovcicen\_frontend/current/public\>  
Options FollowSymLinks  
AllowOverride None  
Order allow,deny  
Allow from all

# Configure mongrel\_cluster

\<Proxy balancer://lovcicen\_frontend\_cluster\>  
BalancerMember [http://127.0.0.1:8005](http://127.0.0.1:8005)  
BalancerMember [http://127.0.0.1:8006](http://127.0.0.1:8006)

RewriteEngine On  
…  
…

---

<div class="post-metadata">

**Author:** ![pidja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@pidja](https://www.ruby-forum.com/u/pidja)\
**Post date:** [May 11, 2007, 11:19pm UTC](https://www.ruby-forum.com/t/http-referer-apache-mongrel-cluster/103806/2 "2007-05-11T23:19:31Z")

</div>

It’s not exactly the answer you need, but I had to figure out something  
similar for REMOTE\_USER and eventually ended up with:

```
            RewriteEngine On
            RewriteCond %{LA-U:REMOTE_USER} (.+)
            RewriteRule . - [E=RU:%1]
            RequestHeader add X-Forwarded-User %{RU}e

```

So replace REMOTE\_USER with HTTP\_REFERER and X-Forwarded-User with  
X-Forwarded-Referer (or whatever).

You may not even need to get this fancy, as REMOTE\_USER is somewhat  
special  
and you need some extra mod\_rewrite voodoo to get it early enough.

Your app will need to be able to deal w/ either  
@request.env[“HTTP\_REFERER”]  
or @request.env[“HTTP\_X\_FORWARDED\_REFERER”]
