nginx location+proxy_pass?
David Salgado
david at digitalronin.com
Fri Oct 19 17:20:27 MSD 2007
Hi All
I'm trying to move a bunch of rails apps from an apache/fastcgi
platform to nginx/mongrel_cluster.
What I want is something like this;
http://my.server/app1 --> mongrel_cluster1
http://my.server/app2 --> mongrel_cluster2
I can do this in nginx with something like this;
...
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 {
...
location /app1 {
proxy_pass http://mongrel_cluster1;
break;
}
location /app2 {
proxy_pass http://mongrel_cluster2;
break;
}
...
But, the problem is that I'm now hitting my rails apps with paths like
this;
/app1/controller/method
/app2/controller/method
...when the apps want the paths to be just /controller/method
So, I want to use something like this to remove the 'app1' part;
rewrite ^/app1/(.*)$ /$1 permanent;
But, that seems to override the proxy_pass directive, because if I put
that in my location blocks, I just get 404 errors, and it's not
allowed in my upstream blocks.
I know I could use virtual hosts, with a different subdomain for each
app, but that would be this;
http://app1.my.server --> mongrel_cluster1
http://app2.my.server --> mongrel_cluster2
...which is not what I want.
Is there any way to achieve what I want, using nginx?
Thanks in advance for any help.
David
More information about the nginx
mailing list