What about configuring the proxy-rewrite plugin in the consumer? Like this: ``` $ curl http://127.0.0.1:9080/apisix/admin/consumers -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "username": "jack", "plugins": { "key-auth": { "key": "auth-one" }, "proxy-rewrite": { "headers": { "X-CONSUMER-ID": "$consumer_name" }, ... } } }'
``` Alexandre SOLOVIEFF <alexandre.solovi...@4sh.fr> 于2022年2月14日周一 07:10写道: > > Hi, > > My case scenario : > I want to add a custom header (ex: X-CONSUMER-ID) which value depends of > the consumer identified by its api key. And so for two consumer consumer-01 > and consumer-02 I want to proxy the request to which I added the header > X-CONSUMER-ID=consumer-01-id or X-CONSUMER-02-id depending of who've done > the call. > > So to summarize, I want to add a header in all cases but the value shall > depend on the target consumer. > > Best regards, > > Le sam. 12 févr. 2022 à 11:16, Zhiyuan Ju <juzhiy...@apache.org> a écrit : > > > Hi, > > > > > want to do is configure it on the consumer. > > > > Just to make sure, do you want to only execute this plugin on a target > > consumer? If yes, you could use the consumer-restriction plugin[1], but it > > still needs to work with Route: Route + Consumer + Plugin. > > > > More detailed scenarios could be helpful to all of us, and let's wait for > > other members' thoughts. > > > > [1] https://apisix.apache.org/docs/apisix/plugins/consumer-restriction/ > > > > Best Regards! > > @ Zhiyuan Ju <https://github.com/juzhiyuan> > > > > > > Ming Wen <wenm...@apache.org> 于2022年2月11日周五 10:10写道: > > > >> I cc this email to dev@apisix.a.o > >> > >> Thanks, > >> Ming Wen, Apache APISIX PMC Chair > >> Twitter: _WenMing > >> > >> > >> Alexandre SOLOVIEFF <alexandre.solovi...@4sh.fr> 于2022年2月10日周四 23:49写道: > >> > >> > Hello, > >> > I am currently trying to add a new header and I can do it with the > >> plugin > >> > proxy-rewrite. But this plugin can only be configured on routes and > >> what I > >> > want to do is configure it on the consumer. Is there a way to do it ? > >> > > >> > Best regards > >> > > >> > -- > >> > [image: Profile] > >> > *Alexandre* Solovieff [image: 4SH]Développeur > >> > > >> > > >> > +33 (0)9 63 28 62 73 <+33+(0)9+63+28+62+73> ◆ +33 (0)9 63 28 62 73 > >> > <+33+(0)9+63+28+62+73> > >> > > >> > > > > -- > [image: Profile] > *Alexandre* Solovieff [image: 4SH]Développeur > > > +33 (0)9 63 28 62 73 <+33+(0)9+63+28+62+73> ◆ +33 (0)9 63 28 62 73 > <+33+(0)9+63+28+62+73>