> But here is also a disadvantages that this plugin must work at > rewrite_phase and be a global rule, because mapping action must execute > before route matching We can use two methods to solve this issue: plugin orchestration and dynamic modification upstreams in plugin. Both of features are on the way.
Thanks, Ming Wen, Apache APISIX & Apache SkyWalking Twitter: _WenMing vincixu <[email protected]> 于2020年8月7日周五 上午11:05写道: > +1 for plugin way. > The feature is simple mapping action, "geo_ip -> geo_city or geo_country". > It likes request-rewrite plugin, but have more logic.We can implement it as > a plugin and have advantage as below: > 1. the parameter's option could easy changed by user, such should read geo > ip from what source (header or query or cookie), what name it could be > etc. > 2. make APISIX route logic clean > > But here is also a disadvantages that this plugin must work at > rewrite_phase and be a global rule, because mapping action must execute > before route matching > > YuanSheng Wang <[email protected]> 于2020年8月7日周五 上午9:53写道: > > > > > only get geo_city info when the geoip condition is set, we don't > need > > > > calculate ip geo information for every request. > > > agreed, geo_ip should not calculated ervery request. > > > > please take a look at the `cookie` of `vars` [1]. we should use the same > > way. > > > > If we refer to geoip variables, the GeoIP library will be called to get > the > > value. > > If we do not refer to these variables, the GeoIP library will never be > > called. > > > > > The request condition can not only be placed on the `route`, but the > > plugin > > > also has this capability. > > > > `vars` is the easiest way to support both `route` and `plugin`. > > > > [1] https://github.com/apache/apisix/blob/master/apisix/core/ctx.lua#L76 > > > > > > > > > > integrate maxmind code into lua-resty-radixtree, only when the route > > with > > > > geo condition is matched , then we calculate the geo ip info. > > > so why not take geo_ip as a plugin? > > > Plugin orchestration is particularly well suited for this. > > > The request condition can not only be placed on the route, but the > plugin > > > also has this capability. > > > > > > Thanks, > > > Ming Wen, Apache APISIX & Apache SkyWalking > > > Twitter: _WenMing > > > > > > > > > Li Ling(Lien) <[email protected]> 于2020年8月6日周四 下午7:29写道: > > > > > > > IMO,the the geoip-route is a feature of *route* module,it shouldn't > > > > involved with vars module, > > > > and only get geo_city info when the geoip condition is set, we don't > > > need > > > > calculate ip geo information for every request. > > > > > > > > here is my solution: > > > > integrate maxmind code into lua-resty-radixtree, only when the > route > > > with > > > > geo condition is matched , then we calculate the geo ip info. > > > > > > > > YuanSheng Wang <[email protected]> 于2020年8月6日周四 下午6:00写道: > > > > > > > > > > 1、I want route user‘s request from country request into > different > > > > > upstream > > > > > host. > > > > > > > > > > I think AIPSIX needs to support this feature. it is a useful > feature > > > for > > > > > the user. > > > > > We do not need to update `resty-radixtree`, only update `ctx.vars` > is > > > > > enough. > > > > > > > > > > for example, a way to get the city: `ctx.vars.geo_city` . > > > > > > > > > > Then the users can use it in `route` or `plugin`, both of the way > are > > > > fine. > > > > > > > > > > On Thu, Aug 6, 2020 at 8:55 AM Ming Wen <[email protected]> > wrote: > > > > > > > > > > > Optional features should be implemented by plugins, > > > > > > and the core should be keep simple. > > > > > > > > > > > > Thanks, > > > > > > Ming Wen, Apache APISIX & Apache SkyWalking > > > > > > Twitter: _WenMing > > > > > > > > > > > > > > > > > > YuanSheng Wang <[email protected]> 于2020年8月6日周四 上午8:28写道: > > > > > > > > > > > > > On Thu, Aug 6, 2020 at 7:39 AM Ming Wen <[email protected]> > > > wrote: > > > > > > > > > > > > > > > IMO, implement geo_ip as plugin is better, not in the route. > > > > > > > > > > > > > > > > > > > > > > I would like to implement it in `route`. > > > > > > > > > > > > > > It may be a condition, we can support it in `vars'. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > And https://luarocks.org/modules/agladysh/lua-geoip is not a > > > good > > > > > > > > approach, > > > > > > > > lua-resty-maxminddb[1] is good for APISIX. > > > > > > > > > > > > > > > > > > > > > > this library is better. agree +1 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > [1] https://github.com/anjia0532/lua-resty-maxminddb > > > > > > > > > > > > > > > > Thanks, > > > > > > > > Ming Wen, Apache APISIX & Apache SkyWalking > > > > > > > > Twitter: _WenMing > > > > > > > > > > > > > > > > > > > > > > > > JinChao Shuai <[email protected]> 于2020年8月6日周四 > 上午1:47写道: > > > > > > > > > > > > > > > > > I also agree with the second approach and to `Yansheng > Wang` > > > that > > > > > > users > > > > > > > > can > > > > > > > > > use their own GeoIP database. > > > > > > > > > > > > > > > > > > YuanSheng Wang <[email protected]> 于2020年8月5日周三 > 下午11:40写道: > > > > > > > > > > > > > > > > > > > Of course, the second way is better for APISIX. > > > > > > > > > > > > > > > > > > > > The `lua-geoip` is under Dual license, we need to confirm > > if > > > we > > > > > can > > > > > > > use > > > > > > > > > > this library. > > > > > > > > > > > > > > > > > > > > The users needs to download the GeoIP database by > himself, > > > > Apache > > > > > > > > APISIX > > > > > > > > > > can > > > > > > > > > > not ship with the GeoIP data(under LGPL 2.1). > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Wed, Aug 5, 2020 at 9:16 PM Li Ling(Lien) < > > > > [email protected]> > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > rencently I am thinking about have Geo routing in > APISIX, > > > > > > > > > > > scenario: > > > > > > > > > > > 1、I want route user‘s request from country request > > > intoto > > > > > > > > different > > > > > > > > > > > upstream host. > > > > > > > > > > > 2、When users from outside China redirect to > > > international > > > > > > > > > > homepage(many > > > > > > > > > > > video sites like youku.com they ban users from outside > > > > china). > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > here is two solution I digged into: > > > > > > > > > > > > > > > > > > > > > > 1、intergrate nginx module > > > > > > > > > https://github.com/leev/ngx_http_geoip2_module > > > > > > > > > > > and > > > > > > > > > > > do variable matching. > > > > > > > > > > > disadvantage: we need calculate the geo data from > ip > > > > info > > > > > > for > > > > > > > > > every > > > > > > > > > > > request,which is so inefficient. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 2、https://luarocks.org/modules/agladysh/lua-geoip > > > > > > > > > > > intergrate this lua module into > lua-resty-radixtree, > > > > when > > > > > > > > geo_ip_* > > > > > > > > > > > parameter is set in the routes, we calculate the ip > > country > > > > > info > > > > > > > from > > > > > > > > > > geoip > > > > > > > > > > > library.so that it wont calculate the geo data for > each > > > > > > request. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > > > > > > > > > > > > > *MembPhis* > > > > > > > > > > My GitHub: https://github.com/membphis > > > > > > > > > > Apache APISIX: > https://github.com/apache/incubator-apisix > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > > Thanks, > > > > > > > > > Janko > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > > > > > > > *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 > > > > > > > > > > > > > > > > > > -- > > > > *MembPhis* > > My GitHub: https://github.com/membphis > > Apache APISIX: https://github.com/apache/incubator-apisix > > >
