# How to setups two rails 2.1 app in different location with Nginx?

**URL:** <https://www.ruby-forum.com/t/how-to-setups-two-rails-2-1-app-in-different-location-with-nginx/141891>\
**Category:** Deployment\
**Created:** [July 1, 2008, 1:55pm UTC](https://www.ruby-forum.com/t/how-to-setups-two-rails-2-1-app-in-different-location-with-nginx/141891 "2008-07-01T13:55:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![caiwangqin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/4bbf92/32.png) [@caiwangqin](https://www.ruby-forum.com/u/caiwangqin)\
**Post date:** [July 1, 2008, 1:55pm UTC](https://www.ruby-forum.com/t/how-to-setups-two-rails-2-1-app-in-different-location-with-nginx/141891/1 "2008-07-01T13:55:45Z")

</div>

i found config from: [Nginx location+proxy\_pass? - NGINX - Ruby-Forum](http://www.ruby-forum.com/topic/128598#573601)

my nginx version: 0.6.13  
and here is my full working nginx.conf:

user www;  
worker\_processes 1;

events {  
worker\_connections 1024;  
}

http {

include mime.types;

upstream mongrel\_cluster1 {  
server 127.0.0.1:3001;  
server 127.0.0.1:3002;  
}

upstream mongrel\_cluster2 {  
server 127.0.0.1:4001;  
server 127.0.0.1:4002;  
}

server {  
listen 127.0.0.1:80 default deferred;

```
location /app1/ {
    proxy_pass http://mongrel_cluster1/;
}

location /app2/ {
    proxy_pass http://mongrel_cluster2/;
}

```

}

}

his config file works find in Rails 1.2.x, but not work for Rails  
2.1. do you know how to make it works for Rails 2.1?

---

<div class="post-metadata">

**Author:** ![caiwangqin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/4bbf92/32.png) [@caiwangqin](https://www.ruby-forum.com/u/caiwangqin)\
**Post date:** [July 2, 2008, 10:38am UTC](https://www.ruby-forum.com/t/how-to-setups-two-rails-2-1-app-in-different-location-with-nginx/141891/2 "2008-07-02T10:38:43Z")

</div>

Èç¹ûÔÚÄãÓÐapp3ÊÇÓÃRails2.1¿ª·¢µÄ£¬ÄÇÃ´ÓÉÓÚmap.resourceµÄÌØÐÔ£¬ÔÚÒÔÉÏ´úÂëÖÐÔö¼ÓÒ»¸ö/app3/µÃÕâÃ´Ð´ÁË£º  
1.  
Æô¶¯mongrelÊ±Ê¹ÓÃprefix²ÎÊý£º  
mongrel\_rails mongrel::start --prefix /app3 -p 5001  
mongrel\_rails mongrel::start --prefix /app3 -p 5002  
2.ÔÚÒÔÉÏconfÎÄ¼þÖÐÔö¼ÓÁ½¶Î´úÂë£º

upstream mongrel\_cluster3 {  
server 127.0.0.1:5001;  
server 127.0.0.1:5002;  
}

location /app3/ {  
proxy\_pass http://mongrel\_cluster3/app3/;  
}
