Forum: Mongrel VirtualHost like in the Apache-PHP world

Posted by Nagy Tamás (Guest)
on 2010-03-24 20:36
(Received via mailing list)
How to make virtual hosts in mongrel?

::how to serve example1.tld, example2.tld, .. exampleN.tld's 
different ruby apps?

thanks in advence
frikazojd.

<a 
href="http://ad.adverticum.net/b/cl,1,73468,1598288,1592... 
target="_blank">________________________________________________________<br>Újdonság! 
Megérkezett a RIGHT GUARD férfi testápolási termékcsalád! Most 25% 
kedvezménnyel!
Akár 48 órás hatásos védelem a testszag ellen!<br></a>
Posted by Jonathan Rochkind (jrochkind)
on 2010-03-24 21:38
(Received via mailing list)
You do it all in Apache.  Typical way to deploy mongrel is fronted with
an Apache reverse proxy. You need to set up everything in Apache, and
have the right requests proxied to the right mongrel. It's all about
apache, no config in Mongrel.

You may also want to consider mod_rails/passenger instead of mongrel, it
seems to be more popular these days for Rails deployment, and you may
find it easier to set up the way you want.

Jonathan
Posted by Nagy Tamás (Guest)
on 2010-03-24 23:05
(Received via mailing list)
Thank you, Jonathan! but i&#39;d like to try out Mongrel..so, I set the 
apache with mod_proxy.. i think it should forward the request to 
mongrel, localhost:3000.. but how will the mongrel figure out where are 
the ruby apps? it will get a request for example.tld or example6.tld and 
example4.tld at the same time.. .. ??

Jonathan Rochkind <rochkind@jhu.edu> írta:
> 
<a 
href="http://ad.adverticum.net/b/cl,1,73468,1598288,1592... 
target="_blank">________________________________________________________<br>Újdonság! 
Megérkezett a RIGHT GUARD férfi testápolási termékcsalád! Most 25% 
kedvezménnyel!
Akár 48 órás hatásos védelem a testszag ellen!<br></a>
Posted by Hassan Schroeder (Guest)
on 2010-03-24 23:45
(Received via mailing list)
2010/3/24 Nagy Tamás <frikazojd@freemail.hu>:

> but i'd like to try out Mongrel..
> so, I set the apache with mod_proxy.. i think it should forward the request
> to mongrel, localhost:3000.. but how will the mongrel figure out where are
> the ruby apps? it will get a request for example.tld or example6.tld and
> example4.tld at the same time.. .. ??

You need to have at least one mongrel instance per domain, and set
up your httpd proxy accordingly.
Posted by James Tucker (Guest)
on 2010-03-25 09:48
(Received via mailing list)
On 24 Mar 2010, at 22:13, Hassan Schroeder wrote:

> 2010/3/24 Nagy Tamás <frikazojd@freemail.hu>:
> 
>> but i'd like to try out Mongrel..
>> so, I set the apache with mod_proxy.. i think it should forward the request
>> to mongrel, localhost:3000.. but how will the mongrel figure out where are
>> the ruby apps? it will get a request for example.tld or example6.tld and
>> example4.tld at the same time.. .. ??
> 
> You need to have at least one mongrel instance per domain, and set
> up your httpd proxy accordingly.

Actually, you can use rack to do it:

map "http://domain1/" do
  run App1
end

map "http://domain2/" do
  run App2
end

Then specify multiple vhost aliases in the apache proxy configuration
Posted by Nagy Tamás (Guest)
on 2010-03-25 15:44
(Received via mailing list)
Thank you Hassan, James!

So i will need one mongrel per domain. I think I can&#39;t carry out 
this because I have a thousands of domains.

I think i will try the rack-thing James mentioned. I assume i can&#39;t 
run individual ruby script files but whole apps, one app for one domain.

ooohh so hard.. :)

<a 
href="http://ad.adverticum.net/b/cl,1,73468,1598288,1592... 
target="_blank">________________________________________________________<br>Újdonság! 
Megérkezett a RIGHT GUARD férfi testápolási termékcsalád! Most 25% 
kedvezménnyel!
Akár 48 órás hatásos védelem a testszag ellen!<br></a>
Posted by James Tucker (Guest)
on 2010-03-25 16:32
(Received via mailing list)
On 25 Mar 2010, at 14:34, Nagy Tamás wrote:

> Thank you Hassan, James!
> 
> So i will need one mongrel per domain. I think I can't carry out this because I have a thousands of domains.

That sounds like a recipe for out of memory errors and cross-application 
errors taking down the whole set at the same time. It also sounds like 
it's better suited to passenger.

> I think i will try the rack-thing James mentioned. I assume i can't run individual ruby script files but whole apps, one app for one domain.

You can load whatever you like, and run anything that responds to #call, 
in the standard rack manner. What you won't be able to do, is load 
different versions of dependencies into the same process and expect to 
be bug free.
Posted by Jonathan Rochkind (jrochkind)
on 2010-03-25 17:04
(Received via mailing list)
Do you want a seperate app per domain, or do you want one app handling
multiple domains?

If you want a seperate app per domain, I think you'd need a mongrel per
domain too, I don't see any other way to do it.

If you want one app that handles multiple domains, than it's up to you
to write an app that can do that, and it's not a mongrel issue.

Jonathan
Posted by James Tucker (Guest)
on 2010-03-25 22:17
(Received via mailing list)
On 25 Mar 2010, at 14:52, Jonathan Rochkind wrote:

> Do you want a seperate app per domain, or do you want one app handling multiple domains?
> 
> If you want a seperate app per domain, I think you'd need a mongrel per domain too, I don't see any other way to do it.

map "http://domain1.com/" do
  run App1.new
end

map "http://domain2.com/" do
  run App2.new
end

I see a way to do it.
Posted by Hassan Schroeder (Guest)
on 2010-03-25 23:09
(Received via mailing list)
On Thu, Mar 25, 2010 at 2:04 PM, James Tucker <jftucker@gmail.com> 
wrote:

> map "http://domain1.com/" do
>  run App1.new
> end
>
> map "http://domain2.com/" do
>  run App2.new
> end
>
> I see a way to do it.

OK, I've never  used Rack as a standalone entity; how exactly does
this work in a Rails context?

Say, I have a directory structure like

  /webapps/app1
  /webapps/app2

where both app1 and app2 are Rails apps.

Where does the above code go, and what exactly would I be invoking?
Posted by Nagy Tamás (Guest)
on 2010-03-26 10:13
(Received via mailing list)
Ok, then it will be Rack. anyway, i want to use the whole ruby as php: 
example.tld/rubyscript1.rbexample.tld/rubyscript2.rbexample2.tld/rubyappexample2.tld/rubyapp/rubyscript.rb 
where also works any Rails app..

<a 
href="http://ad.adverticum.net/b/cl,1,73468,1598288,1592... 
target="_blank">________________________________________________________<br>Újdonság! 
Megérkezett a RIGHT GUARD férfi testápolási termékcsalád! Most 25% 
kedvezménnyel!
Akár 48 órás hatásos védelem a testszag ellen!<br></a>
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.