nginx and rails configuration question
Cathal
coriordan at tssg.org
Wed Apr 2 17:00:33 MSD 2008
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.
More information about the nginx
mailing list