Hi I did a simple test and there is no loss of performance. So it's easy to implement a proxy mirror plugin in this way. I will submit a prototype implementation later.
The configuration of the Nginx looks like the following: location / { root html; mirror /mirror; } location /mirror { return 200; } Thanks, agile6v On 2020/03/14 13:30:47, YuanSheng Wang <membp...@apache.org> wrote: > > In addition, if the mirror directive placed inside the / location, the > performance also needs to be confirmed. In theory, it shouldn't make any > different. > > love this way. good luck > > On Sat, Mar 14, 2020 at 8:34 PM agile6v <agil...@apache.org> wrote: > > > Hi YuanSheng, > > > > If use named location, maybe the contents of the / location need to be > > copied into it, this will cause the configuration to become redundant. > > > > The best way is to support variable in the mirror directive, i have > > submitted the patch to nginx community, hopefully the future version of the > > Nginx will support it. > > > > In addition, if the mirror directive placed inside the / location, the > > performance also needs to be confirmed. In theory, it shouldn't make any > > different. > > > > Thanks, > > agile6v > > > > On 2020/03/14 07:10:30, YuanSheng Wang <membp...@apache.org> wrote: > > > Hi: > > > > > > love this feature too. > > > > > > But I think We can refer to this implementation[1]. > > > > > > [1] > > https://github.com/apache/incubator-apisix/blob/master/bin/apisix#L416 > > > <https://github.com/apache/incubator-apisix/blob/master/bin/apisix#L416> > > > > > > > > > On Sat, Mar 14, 2020 at 10:34 AM Ming Wen <wenm...@apache.org> wrote: > > > > > > > looks good to me > > > > > > > > agile6v <agil...@apache.org>于2020年3月14日 周六上午10:33写道: > > > > > > > > > Hi all, > > > > > > > > > > Is it necessary to provide a request mirror plugin? > > > > > > > > > > The nginx configuration looks like: > > > > > > > > > > set $var_mirror_disable 1; > > > > > > > > > > location / { > > > > > mirror /mirror_location; > > > > > proxy_pass $upstream_scheme://apisix_backend$upstream_uri; > > > > > } > > > > > > > > > > location /mirror_location { > > > > > if ($var_mirror_disable) { > > > > > return 200; > > > > > } > > > > > > > > > > proxy_pass $mirror_address; > > > > > } > > > > > > > > > > The variable `var_mirror_disable` and `mirror_address` can be > > configured > > > > > in the mirror plugin. > > > > > > > > > > The admin api looks like this: > > > > > > > > > > { > > > > > "plugins": { > > > > > "mirror": { > > > > > "address": "127.0.0.1:8090" > > > > > } > > > > > }, > > > > > "upstream": { > > > > > "nodes": { > > > > > "127.0.0.1:1980": 1 > > > > > }, > > > > > "type": "roundrobin" > > > > > }, > > > > > "uri": "/hello" > > > > > } > > > > > > > > > > > > > > > In addition, it would be better if the mirror directive could support > > > > > variable. > > > > > > > > > > Thanks, > > > > > agile6v > > > > > > > > > -- > > > > Thanks, > > > > Ming Wen, Apache APISIX & Apache SkyWalking > > > > Twitter: _WenMing > > > > > > > > > > > > > -- > > > *MembPhis* > > > My github: https://github.com/membphis > > > Apache APISIX: https://github.com/apache/incubator-apisix > > > > > > > > -- > *MembPhis* > My github: https://github.com/membphis > Apache APISIX: https://github.com/apache/incubator-apisix >