# Apache Virtual Hosts

**URL:** <https://www.ruby-forum.com/t/apache-virtual-hosts/113728>\
**Category:** Rails\
**Created:** [September 4, 2007, 11:53am UTC](https://www.ruby-forum.com/t/apache-virtual-hosts/113728 "2007-09-04T11:53:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [September 4, 2007, 11:53am UTC](https://www.ruby-forum.com/t/apache-virtual-hosts/113728/1 "2007-09-04T11:53:34Z")

</div>

I can get Apache to forward requests on the ip address of my computer  
to a rails app on mongrel using:

\<VirtualHost \*:80\>

```
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000

```

ie. [http://nnn.nnn.nnn.nnn/](http://nnn.nnn.nnn.nnn/) fires up my app on mongrel on port 3000  
I want to have several different rails apps on different ports and do  
something like  
[http://nnn.nnn.nnn.nnn/app1](http://nnn.nnn.nnn.nnn/app1) goes to app1 mongrel on 3000  
[http://nnn.nnn.nnn.nnn/app2](http://nnn.nnn.nnn.nnn/app2) goes to app2 mongrel on say 4000

I have played around with server names and server alias but have going  
around in circles.

Note that I have no DNS entry I am just going straight to the ip  
address at the moment.

Any tips would be appreciated.

Thanks  
giorgio

---

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [September 4, 2007, 2:22pm UTC](https://www.ruby-forum.com/t/apache-virtual-hosts/113728/2 "2007-09-04T14:22:59Z")

</div>

giorgio wrote:

> address at the moment.
> 
> Any tips would be appreciated.
> 
> Thanks  
> giorgio

Scroll to the bottom of this thread:

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

and read the second to last reply in there. Read up from there if you  
don’t understand what’s going on.

Basically Mongrel has a --prefix switch that allows it to recognize that  
the Rails app is being called with a path prefix like your above  
example. Then you just have to fiddle with Apache to make sure the paths  
match up/pass through properly.

–  
Michael W.

---

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [September 4, 2007, 3:53pm UTC](https://www.ruby-forum.com/t/apache-virtual-hosts/113728/3 "2007-09-04T15:53:26Z")

</div>

Remove the port from your virtual host statement.  
Under debian / ubuntu server edit or create the following file:  
/etc/apache2/conf.d/virtual.conf  
Add the following line: NameVirtualHost \*

Good luck
