Just out of curiosity, have you tried proxying your requests from Apache to Mongrel without using the Proxy Balancer?  In other words, taking the balancer out of the equation by just:

ProxyPass /rails  http://localhost:3000/

Granted I'm not using SSL, but I am in the process of setting up Apache/mod_proxy/Mongrel and everything works great if I just do a direct ProxyPass.  When I try to use the balancer things go haywire...

I don't have any answers, I just read your post and noticed that you were using the balancer and having problems.  Removing the balancer from the setup might be an interesting troubleshooting exercise...

Jeremy

On 5/10/06, Paul Wright <[EMAIL PROTECTED]> wrote:
On 10/05/06, Zed Shaw <[EMAIL PROTECTED]> wrote:
> On Mon, 2006-05-08 at 15:58 +0100, Paul Wright wrote:
> > Hi all,
> >
> <snip>
>
> > I've seen in a few places [1][2] that the trailing slash is important
> > on the ProxyPass directive but if I include that then I get a BAD
> > CLIENT error in mongrel due to too many  slashes:
> >
> This is really weird that you have to add the //.  That type of URL is
> rejected because it violates the actual URI grammar (from what I
> understand of it).  If balancer needs this, then I'm curious why it's
> bleeding that // to the backend.
>
> I'll check it out to find out why this is the accepted wisdom.

I personally don't have to add the trailing slash to the setup and,
after going back over the places I saw it mentioned only one of them
claimed it needed to be there.  The other was warning against it.  So
just discard the above.  I think.

> > The two main problems I have now is that all rendered links are
> > missing the sub-directory and if any redirects are issued then they
> > are for http://admin.example.com:12345/ instead of the ssl version
> > https://admin.example.com:12345/ - is this because mongrel/rails is
> > only seeing a http request?  And if so is it possible to let the app
> > know that it's actually https and in a subdirectory?
>
> I'll have to look at this.  It might be that mongrel will have to detect
> that the request was secured and add the https, but I really think Rails
> should do this since this is where the redirect is generated.
>
> Take a look at the headers that Mongrel receives and see if you are
> getting the header that indicates the request was secured.  If you are
> then Rails must not be honoring it.  If not then you need to tell your
> web server to start sending it.

Having run mongrel in debug mode I've looked at the headers and
there's nothing there to suggest that Apache has proxied a https
connection.  Looking through the Rails source[1] I see that there are
two situations where Rails will generate https links

153         def ssl?
154           @env['HTTPS'] == 'on' || @env['HTTP_X_FORWARDED_PROTO'] == 'https'
155         end

I had thought that I could used the [E=VAR:VAL] flag on a Rewrite rule
but then I remembered that we're proxying to an independant http
server (mongrel) so it wouldn't make it across.  I've got it working
by adding RequestHeader directive to my Rewrite rules:

RewriteEngine On
# Punt any pontential 404s to the proxy
RewriteCond %{REQUEST_FILENAME} ^/rails/.*
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RequestHeader set X_FORWARDED_PROTO 'https'
RewriteRule ^/rails/(.*)$ balancer://proxy_group/$1            [proxy]

(I don't know apache well enough to know whether the RequestHeader
will fire only apply when the RewriteCond or for every request to this
VirtualHost but I'm confident it won't hurt non-rails requests.)

All that's left now is working out how to set the environment variable
RAILS_RELATIVE_URL_ROOT...  Any clues?

Paul.

[1] - http://dev.rubyonrails.org/browser/trunk/actionpack/lib/action_controller/request.rb

_______________________________________________
Mongrel-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/mongrel-users

_______________________________________________
Mongrel-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/mongrel-users

Reply via email to