[Mongrel] mongrel cluster (+ Apache 2.2.4 + proxy balancer) not redirecting correctly

ripta.pasay at lunarpages.com ripta.pasay at lunarpages.com
Wed Jan 17 02:26:58 EST 2007

I'm in the process of setting up a mongrel cluster at the moment, and I'm
running into a bit of an issue. Even worse is that I'm not sure whether
this is a mongrel thing, or an Apache thing. While I'm inclined to think
that this might be a balancer thing, I decided there was a higher chance
hearing back from mongrel-users than from apache-users, so I'd try this
list first.

So, I'm using mongrel with cluster 0.2.1 running rails 1.1.6 on
ruby 1.8.5, and the following Apache (v2.2.4) configuration for the
virtual host (domain and usernames changed):

<VirtualHost *:443>
        ServerName server.domain.com:443
        ServerAdmin me at domain.com
        DocumentRoot /home/desq/deployment/current
        #RequestHeader set X_FORWARDED_PROTO 'https'

        <Directory "/home/user/deployment/current">
                Options FollowSymLinks
                AllowOverride None
                Order allow,deny
                Allow from all

        <Proxy balancer://mongrel_cluster>

        RewriteEngine On

        RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
        RewriteCond %{SCRIPT_FILENAME} !maintenance.html

        RewriteRule ^/$ /index.html [QSA]

        RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
        RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI}

        CustomLog logs/desq-access.log common
        ErrorLog logs/desq-error.log

        SSLEngine on
        SSLCertificateFile /home/user/ssl.crt
        SSLCertificateKeyFile /home/user/ssl.key

<VirtualHost *:80>
        ServerName server.domain.com
        Redirect permanent / https://server.domain.com

Also, the cluster YML file:

port: 3000
pid_file: log/mongrel.pid
servers: 2
cwd: /home/user/deployment/current
user: user
group: user
environment: production

Now (almost) everything works perfectly. Sessions are great, requests are
passed on, spread between the instances of mongrel. Sadly, HTTP redirects
are not correctly passed somewhere.

If I were to connect to the mongrel instances on port 3000 or 3001
directly, the HTTP redirects are correctly processed. With the balancer,
it's not.

For example, if going to https://server.domain.com:3000/admin/home
redirects to https://server.domain.com:3000/users/login (works without
balancer), then going to https://server.domain.com/admin/home redirects to
https://server.domain.comusers/login (missing the "/" between the host
name and the request URI, thus not working with balancer).

I would appreciate any comments or suggestions on how to further hunt this
issue down.



More information about the Mongrel-users mailing list