<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p> </p>
<p>Am 29.04.2015 15:48, schrieb Maxim Dounin:</p>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<pre>Hello!
On Wed, Apr 29, 2015 at 09:18:11AM +0200, Sergey Brester wrote:</pre>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px">Hi, enclosed you will find an attached changeset, that: - allows to fast use of named location in sub requests, such as auth_request, etc. Currently no named location was possible in any sub requests, real (or internal) locations only. # now you can use named location in sub requests: # auth_request /auth_loc/; auth_request @auth_loc; - in addition, a second mini-commit (37d7786e7015) with new directive "use_location" as alias or replacement for "try_files" with no file argument and without checking the existence of file(s): # try_files "" @loc use_location @loc It was allready more times discussed (goto location, etc.). PS. If someone needs a git version of it: <a href="https://github.com/sebres/nginx/commits/hg-sb-mod">https://github.com/sebres/nginx/commits/hg-sb-mod</a> [<a href="https://github.com/sebres/nginx/commits/hg-sb-mod">1</a>] Regards, sebres. Links: ------ [1] <a href="https://github.com/sebres/nginx/commits/hg-sb-mod">https://github.com/sebres/nginx/commits/hg-sb-mod</a></blockquote>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px"># HG changeset patch # User Serg G. Brester (sebres) <<a href="mailto:serg.brester@sebres.de">serg.brester@sebres.de</a>> # Date 1430227790 -7200 # Tue Apr 28 15:29:50 2015 +0200 # Node ID 37d7786e7015f8a784e6a4dc3f88f8a7573a4c08 # Parent 96e22e4f1b03ff15a774c6ed34d74b897af32c55 http-core: new directive "use_location" as replacement or alias for "try_files" with no file argument and without checking the existence of file(s): `use_location @loc` replaces `try_files "" @loc`</blockquote>
<pre>Something like this was previously discussed more than once, and
the short answer is "no".</pre>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px"># HG changeset patch # User Serg G. Brester (sebres) <<a href="mailto:serg.brester@sebres.de">serg.brester@sebres.de</a>> # Date 1430228073 -7200 # Tue Apr 28 15:34:33 2015 +0200 # Node ID 43135346275c76add5bf953024a3d244f04184ba # Parent 37d7786e7015f8a784e6a4dc3f88f8a7573a4c08 http-core: allow to fast use of named location in (internal) sub requests, ex.: auth_request, etc.; diff -r 37d7786e7015 -r 43135346275c src/http/ngx_http_core_module.c --- a/src/http/ngx_http_core_module.c Tue Apr 28 15:29:50 2015 +0200 +++ b/src/http/ngx_http_core_module.c Tue Apr 28 15:34:33 2015 +0200 @@ -22,6 +22,7 @@ typedef struct { static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r); +static ngx_int_t ngx_http_core_find_named_location(ngx_http_request_t *r, ngx_str_t *name); static ngx_int_t ngx_http_core_find_static_location(ngx_http_request_t *r, ngx_http_location_tree_node_t *node); @@ -1542,6 +1543,16 @@ ngx_http_core_find_location(ngx_http_req noregex = 0; #endif + /* already internal - check is resp. can be named location - search it */ + + if (r->internal && r->uri.len >= 1 && r->uri.data[0] == '@') { + + if (ngx_http_core_find_named_location(r, &r->uri) == NGX_OK) { + + return NGX_OK; + } + } +</blockquote>
<pre>And how it's expected to be processed in a named location if
r->uri is "@..."?
</pre>
</blockquote>
<pre>Function "ngx_http_core_find_named_location" if location was found set "<span class="blob-code-inner">r->loc_conf = (*clcfp)->loc_conf"</span> and returns NGX_OK.</pre>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px">Note that named locations are ones where requests are handled with their original URIs unmodified. This, in particular, allows to use the original URI to select a file, or in a request to the upstream server, etc. With what you are trying to do it doesn't look different from a static location</blockquote>
<p><span class="blob-code-inner">As I wrote it <span class="blob-code-inner"><span class="blob-code-inner"><span class="blob-code-inner">already (of course it is not a static location)</span></span></span>:<br /></span></p>
<p><span class="blob-code-inner">Example, instead of :</span></p>
<p><span class="blob-code-inner"># auth_request /auth_loc/; </span></p>
<p><span class="blob-code-inner">You can use named location <span class="blob-code-inner">@auth_loc</span> and write <span class="blob-code-inner"><span class="blob-code-inner">now</span></span>:</span></p>
<p><span class="blob-code-inner">auth_request @auth_loc;</span></p>
<p> </p>
<p><span class="blob-code-inner">Regards,<br />sebres.</span></p>
</body></html>