Rewrite mirrored request
Jurian Broertjes
jurian.broertjes at openindex.io
Wed May 30 07:53:44 UTC 2018
Hi Roman,
That seems to work, thanks!
Best regards,
Jurian
On 29-05-18 14:28, Roman Arutyunyan wrote:
> Hi Jurian,
>
> On Tue, May 29, 2018 at 11:18:26AM +0200, Jurian Broertjes wrote:
>> Hi Roman,
>>
>> Thank you for your answer, but it's not clear to me how to do this.
>>
>> The request I'd like to mirror is something like
>> http://solrproxy.example.org/prd-solr/abc/select?xyz, so I would expect the
>> "prd-solr" part to be rewritten for the mirror requests. The log says:
>>
>> "GET /prd-solr/abc/select?xyz HTTP/1.0
>> Host: cloud
>>
>> Do you have a suggestion on how to get it to "/solr/abc/select?xyz
> If the only reason why you need this rewrite is proxy_pass, then just pass it
> a modified uri.
>
> map $request_uri $new_uri {
> ~^/prd-solr/(.*)$ /solr/$1;
> }
>
> location /mirror {
> internal;
> proxy_pass http://cloud$new_uri;
> }
>
>> Best regards,
>> Jurian
>>
>>
>> On 28-05-18 17:50, Roman Arutyunyan wrote:
>>> Hello Jurian,
>>>
>>> On Mon, May 28, 2018 at 03:38:45PM +0200, Jurian Broertjes wrote:
>>>> Hi All,
>>>>
>>>> I'm trying to do a simple rewrite of a mirrored request, see the snippet
>>>> below. I'm under the impression that mirrored requests somehow cannot be
>>>> rewritten. Is this the case or am I doing something wrong here? Is there
>>>> some other way to get the job done?
>>>>
>>>> location / {
>>>> mirror /mirror;
>>>> ....
>>>> proxy_pass http://slave;
>>>> }
>>>>
>>>> location /mirror {
>>>> internal;
>>>>
>>>> rewrite prd-solr solr;
>>>> proxy_pass http://cloud;
>>>> }
>>> Mirror requests can be rewritten. But keep in mind that a mirror subrequest
>>> has a different URI than the original request. In your case it's /mirror.
>>> So unless 'prd-solr' matches it, rewrite will not happen.
>>>
>>> Normally $request_uri is used to access the original request URI in a mirror
>>> subrequest.
>>>
>> _______________________________________________
>> nginx mailing list
>> nginx at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
More information about the nginx
mailing list