how to make a named location in subrequest

bigplum nginx-forum at
Thu Jan 19 12:24:29 UTC 2012


Previously, I wrote a module to make a subrequest to backend. nginx.conf
like that:

location /file {
    nphase_uri /dummy;
    nphase_set_uri_var $np_uri http://backend;

location /dummy {
    proxy_pass $np_uri;

The module could send original URI "http://localhost/file/abcd.txt" to
backend to process.
And the module could get response from backend and decide to continue or

But now This fix disabled sending original URI to backend.

    *) Bugfix: a "proxy_pass" directive without URI part might use
       request after redirection with the "try_files" directive.

If we need to send same request to backend, we must use named location.
But it
seems that named location is not support in subrequest. The named
location only
processed in try_files phase.

Following configuration would not work, for the subrequest send a
request "GET /dummy"
rather than original URI.

location /dummy {
    try_files /dummy @named;
location @named {
    proxy_pass $np_uri;

So how do I make it work?

Posted at Nginx Forum:,221447,221447#msg-221447

More information about the nginx mailing list