# Multiple apps, one host (mongrel, apache2)?

**URL:** <https://www.ruby-forum.com/t/multiple-apps-one-host-mongrel-apache2/93219>\
**Category:** Rails\
**Created:** [April 29, 2007, 3:02pm UTC](https://www.ruby-forum.com/t/multiple-apps-one-host-mongrel-apache2/93219 "2007-04-29T15:02:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dankitania](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@dankitania](https://www.ruby-forum.com/u/dankitania)\
**Post date:** [April 29, 2007, 3:02pm UTC](https://www.ruby-forum.com/t/multiple-apps-one-host-mongrel-apache2/93219/1 "2007-04-29T15:02:14Z")

</div>

Fame, glory, and a lot of appreciation would shower upon anyone who can  
indicate how to use mongrel with apache2, to get multiple public apps on  
one host, without DNS or IP tweaking, etc.

To be concrete, let’s say we’re trying to expose the following sites

[http://host.com/app\_one](http://host.com/app_one)  
[http://host.com/app\_two](http://host.com/app_two)

using Rails, Mongrel, and Apache2. It should be assumed that the person  
doing the work has root access (is able to edit httpd.conf, to restart  
the web server, etc.), but does _not_ have the ability to alter IP or  
DNS information. For reasons whose details are irrelevant, two other  
requirements are that the site has to be exposed to the outside world  
(127.0.0.1 is not sufficient) and that commercial hosting is not a  
solution.

Apology: I know that I am asking a question that has been asked before.  
However, I’ve been unable to uncover a proposed solution that was  
reported by the questioner to work. For reference, some threads on the  
topic include:

[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/2a596862bc96c6df/c183ce496bc873c9?lnk=gst&q=multiple+application&rnum=4#c183ce496bc873c9](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2a596862bc96c6df/c183ce496bc873c9?lnk=gst&q=multiple+application&rnum=4#c183ce496bc873c9)

[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/c2d1e47e2db4ed8a/4fa4b83aee8f9764#4fa4b83aee8f9764](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/c2d1e47e2db4ed8a/4fa4b83aee8f9764#4fa4b83aee8f9764)

---

<div class="post-metadata">

**Author:** ![dankitania](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@dankitania](https://www.ruby-forum.com/u/dankitania)\
**Post date:** [April 29, 2007, 3:10pm UTC](https://www.ruby-forum.com/t/multiple-apps-one-host-mongrel-apache2/93219/2 "2007-04-29T15:10:56Z")

</div>

Dan K. wrote:

> doing the work has root access (is able to edit httpd.conf, to restart
> 
> [http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/2a596862bc96c6df/c183ce496bc873c9?lnk=gst&q=multiple+application&rnum=4#c183ce496bc873c9](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2a596862bc96c6df/c183ce496bc873c9?lnk=gst&q=multiple+application&rnum=4#c183ce496bc873c9)
> 
> [http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/c2d1e47e2db4ed8a/4fa4b83aee8f9764#4fa4b83aee8f9764](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/c2d1e47e2db4ed8a/4fa4b83aee8f9764#4fa4b83aee8f9764)

Is there a reason why the solution I posted in my message in the second  
thread above does not work for you? If you are having problems with  
images in a CSS stylesheet you’ll need something like this:

[http://www.ruby-forum.com/topic/100239#216715](http://www.ruby-forum.com/topic/100239#216715)

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![dankitania](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@dankitania](https://www.ruby-forum.com/u/dankitania)\
**Post date:** [April 29, 2007, 3:27pm UTC](https://www.ruby-forum.com/t/multiple-apps-one-host-mongrel-apache2/93219/3 "2007-04-29T15:27:22Z")

</div>

Michael W. wrote:  
[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/2a596862bc96c6df/c183ce496bc873c9?lnk=gst&q=multiple+application&rnum=4#c183ce496bc873c9](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/2a596862bc96c6df/c183ce496bc873c9?lnk=gst&q=multiple+application&rnum=4#c183ce496bc873c9)

> > [http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/c2d1e47e2db4ed8a/4fa4b83aee8f9764#4fa4b83aee8f9764](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/c2d1e47e2db4ed8a/4fa4b83aee8f9764#4fa4b83aee8f9764)
> 
> Is there a reason why the solution I posted in my message in the second  
> thread above does not work for you? If you are having problems with  
> images in a CSS stylesheet you’ll need something like this:
> 
> [OSX apache2 final-stage setup hints? - Rails - Ruby-Forum](http://www.ruby-forum.com/topic/100239#216715)

The problem is that I don’t get images. (Actually, at the moment, I  
don’t even get a site, unless I use 127.0.0.1, but I’ve taken several  
steps backward lately, so if I can just get images I’ll be happier!)

I start mongrel with the command

```
mongrel_rails start -d -p 8010 -a 127.0.0.1 -e development --prefix 
/LSCbc
```

and my http.conf contains as below.

```
# DEK 20070429 start
Alias /LSCbc "/Users/kelley/Sites/LSCbc/public"

  Options Indexes FollowSymLinks
  AllowOverride none
  Order allow,deny
  Allow from all

ProxyPass /LSCbc/images !
ProxyPass /LSCbc/stylesheets !
ProxyPass /LSCbc/javascripts !
ProxyPass /LSCbc/ http://127.0.0.1:8010/LSCbc
#ProxyPass /LSCbc/images http://127.0.0.1:8010/LSCbc/images
ProxyPass /LSCbc http://127.0.0.1:8010/LSCbc
ProxyPassReverse /LSCbc/ http://127.0.0.1:8010/LSCbc
# DEK 20070429 end
```

and the result is that images (used by my stylesheet) do not show up.  
They are called as follows, in my public/stylesheets/style.css file:

```
background: url('/images/headerlogo.png') bottom left no-repeat 
transparent;
```

---

<div class="post-metadata">

**Author:** ![dankitania](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@dankitania](https://www.ruby-forum.com/u/dankitania)\
**Post date:** [April 29, 2007, 4:20pm UTC](https://www.ruby-forum.com/t/multiple-apps-one-host-mongrel-apache2/93219/4 "2007-04-29T16:20:05Z")

</div>

Dan K. wrote:

> don’t even get a site, unless I use 127.0.0.1, but I’ve taken several
> 
> ProxyPass /LSCbc/stylesheets !
> 
> ```
> background: url('/images/headerlogo.png') bottom left no-repeat 
> transparent;
> ```

Well you have a problem cause you have a generic “/images” directory  
reference and multiple apps that can point to it. You have to resolve  
the ambiguity somehow.

One way is as described in my link above which you almost have correct  
but not quite:

ProxyPass /images [http://127.0.0.1:8010/LSCbc/images](http://127.0.0.1:8010/LSCbc/images)

but then you would have to stick all your stylesheet images from all  
your apps into the LSCbc images directory.

Another way is to put the app in the images path in the stylesheets and  
setup ProxyPass that way (like the way you have commented out), i.e.:

background: url(‘/LSCbc/images/headerlogo.png’) bottom left no-repeat

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![dankitania](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@dankitania](https://www.ruby-forum.com/u/dankitania)\
**Post date:** [April 29, 2007, 5:01pm UTC](https://www.ruby-forum.com/t/multiple-apps-one-host-mongrel-apache2/93219/5 "2007-04-29T17:01:54Z")

</div>

Michael W. wrote:

> Another way is to put the app in the images path in the stylesheets and  
> setup ProxyPass that way (like the way you have commented out), i.e.:
> 
> background: url(‘/LSCbc/images/headerlogo.png’) bottom left no-repeat

Michael, this is an excellent solution for me, since I’m hoping to have  
each app provide its own images.

I’m not clear on the ProxyPass, though. I find that the site works for  
me, whether I use

ProxyPass /LSCbc/images !

or

ProxyPass /LSCbc/images [http://127.0.0.1:8010/LSCbc/images](http://127.0.0.1:8010/LSCbc/images)

and so I’m wondering whether I should use the former or the latter. (My  
impression was that the former is better for speed.)

---

<div class="post-metadata">

**Author:** ![dankitania](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@dankitania](https://www.ruby-forum.com/u/dankitania)\
**Post date:** [April 30, 2007, 3:10pm UTC](https://www.ruby-forum.com/t/multiple-apps-one-host-mongrel-apache2/93219/6 "2007-04-30T15:10:56Z")

</div>

I’m transferring now from my laptop to another machine that’s turned on  
all the time, but now I have a new difficulty: I can access all the  
pages through 127.0.0.1, but not through the proxy. Through the proxy,  
I can access only the page pointed at in my config/routes.rb file.  
Other pages give an error

```
no route found to match "books/list" with {:method=>:get}
```

(FYI, this is a site for a book club, hence the name.)

My httpd.conf lines are:

```
# DEK 20070430 start
Alias /LSCbc "/Users/kelley/Sites/LSCbc/public"

  Options Indexes FollowSymLinks
  AllowOverride none
  Order allow,deny
  Allow from all

ProxyPass /LSCbc/public/images !
ProxyPass /LSCbc/public/stylesheets !
ProxyPass /LSCbc/public/javascripts !
ProxyPass /LSCbc/ http://127.0.0.1:8010/LSCbc
ProxyPass /LSCbc http://127.0.0.1:8010/LSCbc
ProxyPassReverse /LSCbc/ http://127.0.0.1:8010/LSCbc
# DEK 20070430 end
```

PS. I realize this is a bit of a different issue, but it’s connected by  
the use of ProxyPass, I guess, so that’s my excuse 🙂

---

<div class="post-metadata">

**Author:** ![dankitania](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@dankitania](https://www.ruby-forum.com/u/dankitania)\
**Post date:** [May 1, 2007, 5:01am UTC](https://www.ruby-forum.com/t/multiple-apps-one-host-mongrel-apache2/93219/7 "2007-05-01T05:01:19Z")

</div>

Dan K. wrote:

> PS. I realize this is a bit of a different issue, but it's connected by the use of ProxyPass, I guess, so that's my excuse :-)

How are you launching Mongrel and what does the “books/list” URL look  
like in the source HTML?

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![dankitania](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@dankitania](https://www.ruby-forum.com/u/dankitania)\
**Post date:** [April 30, 2007, 2:53am UTC](https://www.ruby-forum.com/t/multiple-apps-one-host-mongrel-apache2/93219/8 "2007-04-30T02:53:53Z")

</div>

Dan K. wrote:

> me, whether I use
> 
> ProxyPass /LSCbc/images !
> 
> or
> 
> ProxyPass /LSCbc/images [http://127.0.0.1:8010/LSCbc/images](http://127.0.0.1:8010/LSCbc/images)
> 
> and so I’m wondering whether I should use the former or the latter. (My  
> impression was that the former is better for speed.)

Yes the former is better for speed since you are having Apache serve  
those static files instead of Mongrel but that only works if you have an  
Alias or other path mapping setup to that directory (which you do). I.e.  
the “!” means to not proxy URLs that match the specified path.

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![dankitania](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e9a140/32.png) [@dankitania](https://www.ruby-forum.com/u/dankitania)\
**Post date:** [May 1, 2007, 12:28pm UTC](https://www.ruby-forum.com/t/multiple-apps-one-host-mongrel-apache2/93219/9 "2007-05-01T12:28:48Z")

</div>

Michael W. wrote:

> How are you launching Mongrel

I start Mongrel as:

```
mongrel_rails start -d -p 8010 -a 127.0.0.1 -e development --prefix
/LSCbc
```

> and what does the “books/list” URL look  
> like in the source HTML?

The RoR code is as follows, from my app/views/shared:

```
<%
l = ['welcome','books'] # tab title
c = ['welcome','books'] # controller
a = ['index','list'] # method
n = 2
%>
<% n.times do |i| %>
```
- \<%= link\_to l[i], :controller =\> c[i], :action =\> a[i]%\> 
\<% end %\>

and the resultant HTML is e.g.

```

```
- [welcome](https://www.ruby-forum.com/LSCbc/)
- [books](https://www.ruby-forum.com/LSCbc/books/list)
For context: the scheme works when I'm pointing at 127.0.0.1/LSCbc but not if the browser is pointed at http://localhost/LSCbc/ ... as a reminder, I have apache2 and my httpd.conf contains the following. (
```
# DEK 20070429 start
Alias /LSCbc "/Users/kelley/Sites/LSCbc/public"

  Options Indexes FollowSymLinks
  AllowOverride none
  Order allow,deny
  Allow from all

ProxyPass /LSCbc/images !
#ProxyPass /LSCbc/images http://127.0.0.1:8010/LSCbc/images
ProxyPass /LSCbc/stylesheets !
ProxyPass /LSCbc/javascripts !
ProxyPass /LSCbc/ http://127.0.0.1:8010/LSCbc
ProxyPass /LSCbc http://127.0.0.1:8010/LSCbc
ProxyPassReverse /LSCbc/ http://127.0.0.1:8010/LSCbc
# DEK 20070429 end
```

And, a final symptom the stylesheet/images do not work with the  
httpd.conf as below, when I point at localhost, but they do when I point  
at 127.etc. To get the stylesheet/images, I have to say e.g.

```
ProxyPass /LSC/public/images
```

PS. I’ve stated more than requested here, based on the assumption that  
it’s easier to spot problems in a self-contained entry than in a long  
thread.

Thanks. Dan.
