try_files and redirect loops

Francis Daly francis at
Mon Apr 18 20:30:49 MSD 2011

On Mon, Apr 18, 2011 at 11:37:06AM -0400, inspire22 wrote:

Hi there,

> I need to make sure try_files does not send to a static file if $args
> are included.

So... what do you want to happen if $args are included?

I'll guess "check for /downtime.html, then try the app server". In which
case, the following might be close:

server {
  set $u1 $uri/index.html;
  set $u2 $uri;
  if ($is_args) {
    set $u1 "";
    set $u2 "";

  try_files /downtime.html $u1 $u2 @app;

  location @app {
    proxy_pass  http://app_server;

You'll need some extra bits, for example to define app_server, but it
might give some inspiration.

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list