Forum: Rails deployment Deploying Lots of Rails Apps to the Same Domain

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
9df8f9dbe504e069fa70c1e2d19a18df?d=identicon&s=25 jc (Guest)
on 2007-05-11 07:35
(Received via mailing list)
Hi. I have a dedicated server (linux / rails / mongrel) that I'm
deploying to. I am able to deploy different applications to different
domains/subdomains just fine using the standard rails / mongrel /
apache config (as instructed from agile web second edition).

However, the kink is I need to deploy lots of rails applications under
the same domain. The reason for this is the applications need to be
directly callable from the parent application (at the root domain) via
AJAX so they need to be on the same domain. Calling an ajax request on
sub-domains fail. I know there are a bunch of javascript hacks, but
for now I'd like to just deploy the apps to the same domain (using
virtual folders to identify them).

Here is what I'm after:

http://[domain]         -> Rails Parent App (mongrel ports 8000-8001)
http://[domain]/app1/ -> Rails Child App 1 (mongrel ports 8010-8011)
http://[domain]/app2/ -> Rails Child App 2 (mongrel ports 8020-8021)

The mongrel instances are set up fine for all my apps. I just need to
fix up the mod_rewrite in order to forward the requests based on
folder name to different mongrel instances. I don't mind putting the
child app names and paths statically into the config for now.

What I have tried so far is using a rewrite rule that picks the
http://[domain]/app1/[rails path] and forwards it to the mongrel
cluster defined by app1_cluster.
RewriteRule ^/(.*)/app1/(.*)$ balancer://app1_cluster%{REQUEST_URI}

Needless to say, it doesn't work. I don't think the RewriteRule is
being hit because I cant get the /app1/ requests to hit the right
mongrel cluster. All I get is 404s. The parent rails app works fine at
the root of the domain. I'm guessing my RewriteRule is probably way

Thanks in advance for any help you can offer.


Here is my full apache virtual server config file. Its mostly standard
issue from:

  DocumentRoot /var/www/apps/youcomics/current/public

  <Directory "/var/www/apps/youcomics/current/public">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

  # Configure Mongrel Cluster
  <Proxy balancer://youcomics_cluster>

  <Proxy balancer://app1_cluster>

  RewriteEngine On

  # Prevent access to .svn directories
  RewriteRule ^(.*/)?\.svn/ - [F,L]
  ErrorDocument 403 "Access Forbidden"

  # Check for maintenance file and redirect all requests
  RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteRule ^.*$ /system/maintenance.html [L]

  # Rewrite index to check for static
  RewriteRule ^/$ /index.html [QSA]

  # Rewrite to check for Rails cached page
  RewriteRule ^([^.]+)$ $1.html [QSA]

  # Redirect all non-static requests to cluster

  RewriteRule ^/(.*)/app1/(.*)$ balancer://app1_cluster%{REQUEST_URI}

  #main dashboard
  RewriteRule ^/(.*)$ balancer://youtcomics_cluster%{REQUEST_URI}

  # Deflate
  AddOutputFilterByType DEFLATE text/html text/plain text/xml
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

  ErrorLog logs/
  CustomLog logs/ combined

36af61ea50e1720c96f04bf807c377e8?d=identicon&s=25 Randall Potter (Guest)
on 2007-05-11 23:51
(Received via mailing list)
I do something similar.  I can't really help you with the
mod_proxy_balance part as I'm using Apache 2.0.  Here's how I run it;

Apache -> nginx -> mongrel_cluster
each nginx/mongrel stack has a port different port and I spawn the
mongrels with the --prefix=/foo option.

Apache mod_proxy looks like this
  ProxyPass /app1/ http://hostname:8000/app1/
  ProxyPassReverse http://hostname:8000/app1/ /app1/

  ProxyPass /app2/ http://hostname:8100/app2/
  ProxyPassReverse http://hostname:8100/app2/ /app2/

et al.

I don't use an application bound to / just a static landing page for
simplicity and speed.

hope this helps or at least gives you a direction to try....

This topic is locked and can not be replied to.