[Mongrel] Rails app in a subdirectory via Mongrel

Scott Laird scott at sigkill.org
Mon Jul 10 19:11:43 EDT 2006


On 7/10/06, Zed Shaw <zedshaw at zedshaw.com> wrote:
>
>
> I imagine previously that's what your apache config with fastcgi was
> doing.  There just isn't any other way to do it outside of rails.  This
> also means that your previous config was horribly inefficient.
>
> Snoop around on the interwebs and google for this magic config.  I'm
> pretty sure I'm not crazy, but it's something like:


ActionController::AbstractRequest.relative_url_root = "/myappliveshere".
Amazingly enough, it's special-cased for Apache with FastCGI--if it spots
dispatch.[f]cgi in the right environment variable, then it sets
relative_url_root automatically.  That's why it works with Apache most of
the time :-).  That's the magic I was missing this morning.

So, if you add relative_url_root to environment.rb (or $RELATIVE_URL_ROOT to
the environment) to '/blog', then you can proxy from
http://real-server:80/blog to http://localhost:4123/ (running Mongrel) and
all of the generated URLs work.  But, you won't be able to access the
backend directly for debugging, because it'll be expecting urls that start
at / and generating urls that start with /blog/.

I have a little patch that adds a --prefix flag to Mongrel that sets the
Rails handler URI as well as relative_url_root.  As I mentioned above, it's
not strictly needed, but it'll make life a bit easier for people.  Would
this be something that you'd be interested in applying, or should I go tweak
the Typo docs to explain it away?


Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20060710/5deade88/attachment.html 


More information about the Mongrel-users mailing list