One server with two rails applications

Hello all,

I have one machine and two ruby applications, app1 and app2.
Currently, I have an Apache server and a mongrel server. Apache runs
on port 80 and proxies to mongrel on port 3001, which runs app1. But
I wish to run both applications on the one machine. There is
documentation that suggests clustering. But each application will
need it’s own URL, http://localhost/app1 and http://localhost/app2.
Can anyone direct me on how to do this?

Thanks,

j

[email protected] wrote:

Hello all,

I have one machine and two ruby applications, app1 and app2.
Currently, I have an Apache server and a mongrel server. Apache runs
on port 80 and proxies to mongrel on port 3001, which runs app1. But
I wish to run both applications on the one machine. There is
documentation that suggests clustering. But each application will
need it’s own URL, http://localhost/app1 and http://localhost/app2.
Can anyone direct me on how to do this?

Apache rewrite rules that rewrites urls matching /app1 to the balancer
(or the single instance if you’re not using mod_proxy_balancer) for the
first mongrel and similarly for the second ?

Fred

On 26-Sep-07, at 11:37 AM, Frederick C. wrote:

Can anyone direct me on how to do this?

Apache rewrite rules that rewrites urls matching /app1 to the balancer
(or the single instance if you’re not using mod_proxy_balancer) for
the
first mongrel and similarly for the second ?

Fred

John - you’re gonna want to look into virtual hosts.

Virtual hosts allow you to serve multiple sites from one IP address.

Here’s a sample server_one.com vhost. Sending server_one.com requests
to a cluster of 4 mongrels- Duplicate it, and change for a second to
answer on the same ip. Not the below may need some more params to
work plus the correct mods installed.

ServerName www. server_one.com

ServerAlias www. server_one.com server_one.com

DocumentRoot /var/www/apps/server_one/current/public

<Proxy balancer://server_one_cluster>
BalancerMember http://127.0.0.1:6000
BalancerMember http://127.0.0.1:6001
BalancerMember http://127.0.0.1:6002
BalancerMember http://127.0.0.1:6003

Jodi

On 9/26/07, Frederick C. [email protected] wrote:

Apache rewrite rules that rewrites urls matching /app1

But neither app1 nor app2 will have URLs like that by default.

How do you configure Rails to prepend “/app1” to every URL that it
creates?


Hassan S. ------------------------ [email protected]

Hassan S. wrote:

On 9/26/07, Frederick C. [email protected] wrote:

Apache rewrite rules that rewrites urls matching /app1

But neither app1 nor app2 will have URLs like that by default.

How do you configure Rails to prepend “/app1” to every URL that it
creates?

You could fix that with routing I think. Or you could go the virtual
host way (my preference)

Fred

Try this guide for full setup of Apache (with virtual hosts) and a
mongrel cluster.
http://blog.codahale.com/2006/06/19/time-for-a-grown-up-server-rails-mongrel-apache-capistrano-and-you/

Helzer

On 9/26/07, Frederick C. [email protected] wrote:

How do you configure Rails to prepend “/app1” to every URL that it
creates?

You could fix that with routing I think.

? Can you be more explicit?

Or you could go the virtual host way (my preference)

But that’s not what the OP asked for.

And for future reference I’d also like to know if it’s possible…


Hassan S. ------------------------ [email protected]

I changed map.connect ‘:controller/:action/:id’ to
map.connect ‘foo/:controller/:action/:id’
and restarted the server.

See also
http://greg.agiletortoise.com/2006/08/23/set-base-path-for-rails-app/

Fred

On 9/26/07, Frederick C. [email protected] wrote:

I changed map.connect ‘:controller/:action/:id’ to
map.connect ‘foo/:controller/:action/:id’
and restarted the server.

See also
http://greg.agiletortoise.com/2006/08/23/set-base-path-for-rails-app/

Both good info, thanks!


Hassan S. ------------------------ [email protected]

On 28 Sep 2007, at 15:35, [email protected] wrote:

If you choose this approach you are, as far as I can gather, forced to
change all your hrefs & forms in the applications to mimic this sort
of set up.
I.e application: test, controller: teams, action: list
URL: http://localhost/test/teams/list
But it is quite a job to rename all the URLs in the application.

Is there another way around this?

Setting the routes as I did should automatically prepend test/ to
urls generated from url_for (or the things that use it (form_tag/for,
link_to etc…); at least it did when I tried it.

Fred

I use this setup, just pass --prefix=/app1 or --prefix=/app2 into
mongrel. The only changes you will need to make are image urls in
your stylesheets.

On Sep 28, 8:39 am, Frederick C. [email protected]

If you choose this approach you are, as far as I can gather, forced to
change all your hrefs & forms in the applications to mimic this sort
of set up.
I.e application: test, controller: teams, action: list
URL: http://localhost/test/teams/list
But it is quite a job to rename all the URLs in the application.

Is there another way around this?

On Sep 26, 5:07 pm, “Hassan S.” [email protected]