Welcome! Log In Create A New Profile

Advanced

Re: Try_files and location blocks

Dave Hayes
June 24, 2011 07:04PM
appa@perusio.net writes:
> No. It doesn't. Check the code. It tries a named location otherwise
> invokes ngx_http_split_args(). That's just a concise way of writing a
> debug line in the error log.

Ok, I checked the code. As far as I can tell, it uses the actual
path output in the debug line. The code only calls the split_args()
thing is if tf->lengths == NULL and tf->name.len == 0...and also
if that is true then it appears to redirect:

ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"try to use %s: \"%s\" \"%s\"",
test_dir ? "dir" : "file", name, path.data);

if (tf->lengths == NULL && tf->name.len == 0) {

if (tf->code) {
ngx_http_finalize_request(r, tf->code);
return NGX_OK;
}

path.len -= root;
path.data += root;

if (path.data[0] == '@') {
(void) ngx_http_named_location(r, &path);

} else {
ngx_http_split_args(r, &path, &args);

(void) ngx_http_internal_redirect(r, &path, &args);
}

ngx_http_finalize_request(r, NGX_DONE);
return NGX_OK;
}
...
if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
!= NGX_OK)
{


If I'm correct (and I might not be) if split_args() gets called then
an internal redirect is done to that path.

I checked this two ways.

a) I compared the debug output of

try_files /error.php @some_other_location

2011/06/24 15:40:33 [debug] 66904#0: *1 try files phase: 11
2011/06/24 15:40:33 [debug] 66904#0: *1 try to use file: "/error.php"
"/home/test/error.php"
2011/06/24 15:40:33 [debug] 66904#0: *1 try file uri: "/error.php"

with

try_files /error.php?c=404 @some_other_location

2011/06/24 15:39:05 [debug] 66770#0: *1 try to use file: "/error.php?c=403"
"/home/test/error.php?c=403"
2011/06/24 15:39:05 [debug] 66770#0: *1 try to use file:
"@real_error_403" "/home/test/@real_error_403"

b) I added to the code this:

+ ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "really truly try to use %s: \"%s\" \"%s\"",
+ test_dir ? "dir" : "file", name, path.data);
if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)

So it's right above the open (which ostensibly does the file check).
This gives me:

2011/06/24 16:00:15 [debug] 70121#0: *1 try files phase: 11
2011/06/24 16:00:15 [debug] 70121#0: *1 try to use file: "/error.php?c=403"
"/home/test/error.php?code=403"
2011/06/24 16:00:15 [debug] 70121#0: *1 really truly try to use file:
"/error.php?c=403" "/www/home/test/website/error.php?code=403"
2011/06/24 16:00:15 [debug] 70121#0: *1 try to use file: "@real_error_403"
"//home/test/@real_error_403"

Even with this evidence, I don't know the code all that well so if I'm
missing something please correct me. :) I am using nginx 1.0.3, maybe
that is the issue?
--
Dave Hayes - Consultant - Altadena CA, USA - dave@jetcafe.org
>>> The opinions expressed above are entirely my own <<<

The concept, the label, is perpetually hiding from us all
the nature of the real. --Joyce Cary




_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Try_files and location blocks

Dave Hayes June 23, 2011 05:38PM

Re: Try_files and location blocks

António P. P. Almeida June 23, 2011 06:04PM

Re: Try_files and location blocks

António P. P. Almeida June 23, 2011 06:12PM

Re: Try_files and location blocks

António P. P. Almeida June 23, 2011 06:20PM

Re: Try_files and location blocks

Dave Hayes June 23, 2011 06:30PM

Re: Try_files and location blocks

António P. P. Almeida June 23, 2011 06:48PM

Re: Try_files and location blocks

António P. P. Almeida June 23, 2011 07:02PM

Re: Try_files and location blocks

Dave Hayes June 24, 2011 02:16PM

Re: Try_files and location blocks

António P. P. Almeida June 24, 2011 02:52PM

Re: Try_files and location blocks

Dave Hayes June 24, 2011 07:04PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 156
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready