try_files ignored in combination with error_page and named locations

Džen yvldwt at gmail.com
Tue Apr 3 20:30:39 UTC 2012


Hello,

For some reason the following nginx configuration snippet doesn't work
as expected, try_files seems to be ignored. When / is requested (or any
other URI which points to a file which doesn't exist), nginx's default
503 page is returned instead of the existing index.html. Requesting
/index.html works correctly.

	location @maintenance {
		root		/var/nginx/$hostid-maintenance;
		index		index.html;
		try_files	$uri $uri/ / =500;
	}

	error_page 503 @maintenance;

	if ( -d $document_root/$hostid-maintenance ) {
		return 503;
	}

Any thoughts? Running nginx version 1.0.12 here.

Kind regards

-- 
Džen



More information about the nginx mailing list