[Mongrel] Session problem mongrel behind Apache proxy

Nicolas St-Laurent nstlaurent at wantedtech.com
Tue Apr 17 15:44:31 EDT 2007


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>

     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

     # 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  
     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 ****



More information about the Mongrel-users mailing list