Configuring nginx for different rails apps under same domain

i want to know how to configure nginx for different rails app under the
same domain.
for example:
1)Rails application 1 http://mydomain.com/app1
2)Rails application 2 http://mydomain.com/app2

Below is my enginx configuration .i want to know where iam goin wrong
as i’m able to go in my home page but not able to navigate from login
and signup pages.

NGINX.CONF:

#user nobody;
worker_processes 1;

#error_log logs/error.log;
error_log logs/error.log notice;
#error_log logs/error.log info;

pid logs/nginx.pid;

events {
worker_connections 1024;
use epoll;
}

http {
include conf/mime.types;
default_type application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local]

$request ’
'“$status” $body_bytes_sent “$http_referer” ’
‘“$http_user_agent” “$http_x_forwarded_for”’;

access_log  logs/access.log  main;

sendfile        on;
tcp_nopush     on;
tcp_nodelay    on;

#keepalive_timeout  0;
keepalive_timeout  65;

gzip  on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript

text/xml application/xml application/xml+rss text/javascript;

server_names_hash_bucket_size 128; # this seems to be required for

vhosts

    # mongrel cluster for domain.in
 upstream mongrel_cluster{
            server 127.0.0.1:4000 ;
            server 127.0.0.1:4001 ;
            server 127.0.0.1:4002 ;
                             }

#domain.in/app1 server
server {
listen 192.168.0.196:80;
client_max_body_size 50M;
server_name www.domain.in domain.in;
root /var/www/domain.in/app1/public;
#charset koi8-r;

    access_log  logs/access.log  main;
    rewrite_log on;

    location /app1/ {
            proxy_pass http://mongrel_cluster/;
              proxy_redirect     off;
                      }

   location ~

^/(images|javascripts|js|css|stylesheets|tiles|static|demo)/ {
root /var/www/domain.in/app1/public;

        expires 30d;
    }

    location ~*

^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$
{
root /var/www/domain.in/app1/public;
expires 30d;
}

    location / {
        proxy_pass  http://mongrel_cluster;
        proxy_redirect     off;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
    }

    error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html

     #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }



    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }
}

}

On Wed, 2007-11-21 at 08:10 +0100, Archana Balaji wrote:

i want to know how to configure nginx for different rails app under
the same domain.

You seem to have accomplished this.

Below is my enginx configuration .i want to know where iam goin wrong
as i’m able to go in my home page but not able to navigate from login
and signup pages.

    location /app1/ {
            proxy_pass http://mongrel_cluster/;

Try removing the trailing slash on this line.

Cliff

On Wed, Nov 21, 2007 at 08:10:44AM +0100, Archana Balaji wrote:

i want to know how to configure nginx for different rails app under the
same domain.
for example:
1)Rails application 1 http://mydomain.com/app1
2)Rails application 2 http://mydomain.com/app2

Below is my enginx configuration .i want to know where iam goin wrong
as i’m able to go in my home page but not able to navigate from login
and signup pages.

How these pages (home, login, and signup) are looked from rails side ?
What their URLs ?

Igor S. wrote:

On Wed, Nov 21, 2007 at 08:10:44AM +0100, Archana Balaji wrote:

i want to know how to configure nginx for different rails app under the
same domain.
for example:
1)Rails application 1 http://mydomain.com/app1
2)Rails application 2 http://mydomain.com/app2

Below is my enginx configuration .i want to know where iam goin wrong
as i’m able to go in my home page but not able to navigate from login
and signup pages.

How these pages (home, login, and signup) are looked from rails side ?
What their URLs ?

the url’s are redirected to main/home in the rails apps side…

The problem now is that

The things which are redirected to main /home gets directed to

http://domain.com/main/home

I want it to be redirected to

http://domain.com/app1/

how do i redirect it using nginx???

On Sat, Nov 24, 2007 at 09:41:19AM +0100, amith amith wrote:

as i’m able to go in my home page but not able to navigate from login

http://domain.com/main/home

I want it to be redirected to

http://domain.com/app1/

how do i redirect it using nginx???

I do not understand the question.
I do not know typical rails URLs.
Could you write how should the URLs be mapped ?
For example,

   outside world:                  Rails:

 domain.com/app1/       >  www.domain.com/main/home
 domain.com/app1/login  >  www.domain.com/main/login

 domain.com/app2/       >  www.domain.com/main2/home

 domain.com/app3/       >  www.domain.com/main3/home

Igor S. wrote:

On Sat, Nov 24, 2007 at 09:41:19AM +0100, amith amith wrote:

as i’m able to go in my home page but not able to navigate from login

http://domain.com/main/home

I want it to be redirected to

http://domain.com/app1/

how do i redirect it using nginx???

I do not understand the question.
I do not know typical rails URLs.
Could you write how should the URLs be mapped ?
For example,

   outside world:                  Rails:

 domain.com/app1/       >  www.domain.com/main/home
 domain.com/app1/login  >  www.domain.com/main/login

 domain.com/app2/       >  www.domain.com/main2/home

 domain.com/app3/       >  www.domain.com/main3/home

the redirecting should be as follows:

outside world: Rails:

domain.com/app1/ > www.domain.com/app1/main/home
domain.com/app1/account/login >
www.domain.com/app1/account/login
after logging in should be redirected to > www.domain.com/app1/

domain.com/app2 > www.domain.com/app2/main/home

domain.com/app3 > www.domain.com/app3/main/home

i hope u’r able to understand from the above example.

Brandon H. wrote:

I am having the same exact issue that you describe… did you ever
figure out a solution?

Figured this out from another post…
you have to use the prefix option for mongrel which can be called on the
command line of included in the .yaml file in /etc/mongrel (if you have
it configured that way)

See: http://mongrel.rubyforge.org/wiki/FAQ

I am having the same exact issue that you describe… did you ever
figure out a solution?