hmthoo commented on issue #8117: URL: https://github.com/apache/apisix/issues/8117#issuecomment-1283556117
> It looks like you want to add an Nginx location configuration, and what you're adding here is a route. APISIX core does not use Nginx location for request matching, please check APISIX's definition of the route here https://github.com/apache/apisix/blob/master/docs/en/latest/admin-api.md# route. If you want to add Nginx configuration, please refer to here: https://github.com/apache/apisix/blob/master/conf/config-default.yaml#L170-L173. I didn't find the answer I was looking for in the documentation. I want to disforward "/saas" to "@apps_stable" via a custom plugin. ## my code Forwarding to the location based on the cid in the cid list ``` local core = require("apisix.core") local plugin_name = "cid-dispatch" local ngx_cache = ngx.shared.cid local schema = { type = "object", properties = {}, additionalProperties = false, } local _M = { version = 1.0, priority = 3002, name = plugin_name, schema = schema, } function get_cookie(cname) local cookie_name = 'cookie_'..cname return ngx.var[cookie_name] end function get_upstream() local proxy = "@apps_stable" local cid_list = ngx_cache:get("cid_list") if cid_cookie == nil then core.log.warn("can't get cid in cookie") return proxy end if cid_cookie then local patter_cid=','..cid_cookie..',' local res = string.find(cid_list,patter_cid) if res == nil then return proxy end proxy = "@apps_canary" return proxy end return proxy end function _M.rewrite(conf, ctx) this_proxy = get_upstream() ngx.exec(this_proxy) end return _M ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
