# Nginx: Multiple apps, one domain

**URL:** <https://www.ruby-forum.com/t/nginx-multiple-apps-one-domain/110276>\
**Category:** Deployment\
**Created:** [July 24, 2007, 9:22pm UTC](https://www.ruby-forum.com/t/nginx-multiple-apps-one-domain/110276 "2007-07-24T21:22:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nadav](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nadav](https://www.ruby-forum.com/u/nadav)\
**Post date:** [July 24, 2007, 9:22pm UTC](https://www.ruby-forum.com/t/nginx-multiple-apps-one-domain/110276/1 "2007-07-24T21:22:02Z")

</div>

Hi all.  
I guess I am not the first to encounter this…  
I want to deploy some rails apps, using only one domain  
([www.mydomain.com](http://www.mydomain.com)), so that [www.mydomain.com/app1/](http://www.mydomain.com/app1/)… will be mapped to  
the app1 directory,  
[www.mydomain.com/app2/](http://www.mydomain.com/app2/)… will be mapped to the app2 directory.

I would like to use nginx + mongrels  
I couldn’t figure out how to express this in the nginx config file.  
I did something like :

http {  
.  
.  
.

# cluster serving app1

upstream mongrel1 {  
server 127.0.0.1:7000;  
server 127.0.0.1:7001;  
}

# cluster serving app2

upstream mongrel2 {  
server 127.0.0.1:8000;  
server 127.0.0.1:8001;  
}

server {  
.  
.  
.  
location /app1 {  
.  
.  
.  
proxy\_pass http://mongrel\_app1;  
}

location /app2 {  
.  
.  
.  
proxy\_pass http://mongrel\_app2;  
}  
}

}

But this doesn’t work, I get error messages in the production.log files  
because the app1 / app2 prefixes are stll there for rails to figure out.

Thanks for your help

Nadav

---

<div class="post-metadata">

**Author:** ![nadav](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nadav](https://www.ruby-forum.com/u/nadav)\
**Post date:** [July 26, 2007, 6:30am UTC](https://www.ruby-forum.com/t/nginx-multiple-apps-one-domain/110276/2 "2007-07-26T06:30:51Z")

</div>

On Jul 24, 2:22 pm, Nadav B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> http {  
> upstream mongrel2 {  
> .  
> }  
> Posted viahttp://www.ruby-forum.com/.  
> take a look at the prefix option with mongrel:

[http://mongrel.rubyforge.org/docs/howto.html](http://mongrel.rubyforge.org/docs/howto.html)

---

<div class="post-metadata">

**Author:** ![nadav](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8e7dd6/32.png) [@nadav](https://www.ruby-forum.com/u/nadav)\
**Post date:** [July 26, 2007, 3:31pm UTC](https://www.ruby-forum.com/t/nginx-multiple-apps-one-domain/110276/3 "2007-07-26T15:31:36Z")

</div>

alex durgin wrote:

> take a look at the prefix option with mongrel:
> 
> [http://mongrel.rubyforge.org/docs/howto.html](http://mongrel.rubyforge.org/docs/howto.html)

Thanks man, this was the problem. I added the prefix option to  
config/mongrel\_cluster.yml in each of the applications directories and  
now it works fine.

Cheers

Nadav
