nginx and rails configuration question

Francisco Valladolid ficovh at gmail.com
Wed Apr 2 20:52:31 MSD 2008


Hi Cathal, ..

You need two mongrel cluster instances, one per each rails app ok!

eg:

upstream mongrel_app_1 {
    server 127.0.0.1:8000;
    server 127.0.0.1:8001;
    server 127.0.0.1:8002;
  }

upstream mongrel_app2_2 {
    server 127.0.0.1:9000;
    server 127.0.0.1:9001;
    server 127.0.0.1:9002;
  }

Currently I'm hosting two rails app in my OpenBSD server.

Regards.

On Wed, Apr 2, 2008 at 5:30 PM, Cathal <coriordan at tssg.org> wrote:

> Hi,
>
> I'm trying to configure nginx to serve multiple rails applications, each
> from
> its own path. app1 is accessible from '/' and app2 is accessible from
> '/app2'.
>
> In my configuration I've defined two location's as follows:
>
> -- begin snip! --
>
> # app1
> location / {
>
>        root /u/apps/app1/current/public;
>
>        proxy_set_header  X-Real-IP  $remote_addr;
>
>        # needed for HTTPS
>    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
>    proxy_set_header Host $http_host;
>    proxy_redirect false;
>    proxy_max_temp_file_size 0;
>
>        if (-f $request_filename) {
>        break;
>      }
>
>      if (-f $request_filename/index.html) {
>        rewrite (.*) $1/index.html break;
>      }
>
>      if (-f $request_filename.html) {
>        rewrite (.*) $1.html break;
>      }
>
>      if (!-f $request_filename) {
>        proxy_pass http://mongrel_app1;
>        break;
>      }
> }
>
> #app2
> location /app2 {
>
>        root /u/apps/app2/current/public;
>        proxy_set_header  X-Real-IP  $remote_addr;
>
>        # needed for HTTPS
>        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
>        proxy_set_header Host $http_host;
>        proxy_redirect false;
>        proxy_max_temp_file_size 0;
>
>
>        if (-f $request_filename) {
>          break;
>        }
>
>        if (-f $request_filename/index.html) {
>          rewrite (.*) $1/index.html break;
>        }
>
>        if (-f $request_filename.html) {
>          rewrite (.*) $1.html break;
>        }
>
>        if (!-f $request_filename) {
>          proxy_pass http://mongrel_app2;
>          break;
>        }
> }
>
> -- end snip! --
>
> The problem is that nginx is trying to resolve static files for /app2
> along the
> /app2 path inside my rails application's public directory, which doesn't
> exist.
>
> The only way I've been able to make the above configuration work is to
> create a
> symbolic from 'app2' to 'public'. Is there some way to tell nginx to
> ignore the
> location part it has already matched when dealing with a request?
>
> regards,
> C.
>
>
>
>


-- 
Francisco Valladolid H.
-- http://bsdguy.net - Jesus Christ follower.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20080402/9603759f/attachment.html>


More information about the nginx mailing list