Location / rewrite help needed

Hi,

let’s say I use upstream to push the requests to Rails for example like
this:

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

server {
listen 80;
server_name localhost;
access_log /var/log/nginx/localhost.access.log;
root /var/www/test/public;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
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://thin;
break;
}
}
}

Is it possible to define a second location which not should redirect the
request to the upstream but instead redirect to a folder with static
files in it?

How would you do that?

Regards

Elias

Posted at Nginx Forum:

On Thu, Dec 03, 2009 at 03:10:48AM -0500, saile wrote:

proxy_redirect false;

}
}

Is it possible to define a second location which not should redirect the request to the upstream but instead redirect to a folder with static files in it?

How would you do that?

  location / {
      try_files  $uri/index.html  $uri.html  $uri  @thin;
  }

  location /folder/ {
      root  ...
  }

  location @thin {
      proxy_pass http://thin;
      proxy_set_header  X-Real-IP  $remote_addr;
      proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
  }


Igor S.
http://sysoev.ru/en/