when implementing a rewrite rule for a subrequest which is the proper
way to tackle the issue
- write the rewrite rule in the main location (location /), the
location where the subrequests are generated - write the rewrite rule in the subrequest location
i am using two subrequests to concatenate the document’s contents
residing at the requested URL
example
main request
GET /path/to/files/document_1.html
i generate two subrequests allowing me to chunk the response to the
client as the document’s contents are large
subrequest1
echo_subrequest_async GET /sub1 -q $request_filename;
- where request_filename = /path/to/files/document_1.html
subrequest2
echo_subrequest_async GET /sub2 -q $request_filename;
- where
request_filename = /path/to/files/document_1.html before rewrite
rule
and
request_filename = /path/to/files/document_2.html after rewrite
rule
here is the rewrite rule i’m using
rewrite ^(_.*)$ $1_2.html break;
- so subrequest1 would go to /path/to/files/document_1/html and
subrequest2 would go to /path/to/files/document_2.html
i’ve attempted putting the rewrite rule in the default location and also
the subrequest2 location. on my backend i am able to trace the request
is coming from the subrequest2 location but the URL passed through is
the original URL and not my modified URL.
i know i must be missing something in the documentation, but i’m not
sure what it may be. how do you use a modified version of the URL from
subrequest1?
peter
Posted at Nginx Forum: