So I've got two apps I want to run on a server. One app I would like to be the "default" app--that is, all URLs should be sent this app by default, except for a certain path, lets call it /foo
:
http://mydomain.com/ -> app1
http://mydomain.com/apples -> app1
http://mydomain.com/foo -> app2
My two rack apps are installed like so:
/var
/www
/apps
/app1
app.rb
config.ru
/public
/app2
app.rb
config.ru
/public
app1 -> apps/app1/public
app2 -> apps/app2/public
(app1
and app2
are symlinks to their respective apps' public directories). This is the Passenger setup for sub URIs described here: http://www.modrails.com/documentation/Users%20guide%20Nginx.html#deploying_rack_to_sub_uri
With the following config I've got /foo
going to app2:
server {
listen 80;
server_name mydomain.com;
root /var/www;
passenger_enabled on;
passenger_base_uri /app1;
passenger_base_uri /app2;
location /foo {
rewrite ^.*$ /app2 last;
}
}
Now, how do I get app1 to pick up everything else? I've tried the following (placed after the location /foo
directive), but I get a 500 with an infinite internal redirect:
location / {
rewrite ^(.*)$ /app1$1 last;
}
I hoped that the last
directive would prevent that infinite redirect, but I guess not. My /foo
rewrite still works. And I can still go to http://mydomain.com/app1
.
Any ideas? Thanks!