# Session problem mongrel behind Apache proxy

**URL:** <https://www.ruby-forum.com/t/session-problem-mongrel-behind-apache-proxy/92442>\
**Category:** Rails\
**Created:** [April 19, 2007, 3:17pm UTC](https://www.ruby-forum.com/t/session-problem-mongrel-behind-apache-proxy/92442 "2007-04-19T15:17:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/cc9497/32.png) [@nist](https://www.ruby-forum.com/u/nist)\
**Post date:** [April 19, 2007, 3:17pm UTC](https://www.ruby-forum.com/t/session-problem-mongrel-behind-apache-proxy/92442/1 "2007-04-19T15:17:40Z")

</div>

Hi,

I’ve configured mongrel\_clusters behind an Apache 2.2 proxy using  
named virtual host. Session are saved as ActiveRecordSession. But the  
cookies created on client side doesn’t correspond to session data  
saved in database (keys are different). The RoR app react just like it  
doesn’t have a session at all.

If I don’t use Apache as a proxy/load balancer and call directly  
Mongrel\_cluster, everything works well.

What should I do to get session working with Mongrel behind an Apache  
proxy/load balancer ?

\*\*\*\* Extract of my Apache config \*\*\*\*\*

# Setup a cluster for each application

\<Proxy balancer://myapp\>  
BalancerMember [http://10.1.4.22:3000](http://10.1.4.22:3000)  
BalancerMember [http://10.1.4.22:3001](http://10.1.4.22:3001)  
BalancerMember [http://10.1.4.22:3002](http://10.1.4.22:3002)

\<VirtualHost 10.1.4.22:80\>  
ServerName myapp.xxxxxxxx.yyy  
DocumentRoot /srv/www/rails/myapp/public

```
<Directory "/srv/www/rails/myapp/public">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

# The root of this virtual host redirect to Portal application
ProxyPass / balancer://myapp/
ProxyPassReverse / balancer://myapp/
ProxyPreserveHost on

# Make all of the /public/images directory served by Apache
ProxyPass /images !
Alias /images /srv/www/rails/myapp/public/images

# Setup your Rewrite rules here
RewriteEngine On

# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]

# Send all requests that are not found as existing files to the

```

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

```
# Error logs
ErrorLog /var/log/apache2/myapp_error_log
CustomLog /var/log/apache2/myapp_access_log combined

```

\>

\*\*\*\* END \*\*\*\*

Thanks,

Nist
