Handling 404 with mongrel + proxy

Hi!

I have a site built on rails 2 and I want to put into production with
Apache 2 + mod_proxy + mongrel instances.

The problem is that, when I hit a non existing page, I expected
mongrel to render the /404.html file for me. Since this did’t work, I
put the “ErrorDocument /404.html” on my Apache 2 config but Apache
seems to ignore it, since mongrel answers 404 with some HTML content
(with the failing routing match).

Can you help me with this? I expected that mongrel rendered /404.html
and /500.html as soon as I indicated I’m in production environment.
Is this a mongrel responsibility or Apache?

Thank you

depends on your setup.

The ideal configuration most of the time is to have Apache serve all
static files and have mongrel serve the dispatch.rb/cgi/fcgi file.

You need to configure apache to say “if there is no matching file proxy
to mogrel”

then have your app say "if route not found redirect_to ‘/404’

start with your app:

there is a rescue method for controllers (check the api for the name) i
believe its called “rescue_action” were you can say “if route not found
redirect else call the super” in your application controller

On 2008/01/21, at 09:52, Ruben F. wrote:

(with the failing routing match).

Can you help me with this? I expected that mongrel rendered /404.html
and /500.html as soon as I indicated I’m in production environment.
Is this a mongrel responsibility or Apache?

I was using exception_notification plugin, and the problem was that
exception_notifiacation looks at the requests from the Apache (proxy)
as local (yah… he’s right…)

The solution was to include in app/controllers/application.rb:

after “include ExceptionNotifiable”
local_addresses.clear

Now it works :slight_smile: Cheers,
Ruben

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs