Hi, While trying to integrate CDAP with knox, we created rewrite and service rules for CDAP and content of those files looks like this:
service.xml: <service role="CDAPUI" name="cdapui" version="4.3.4"> <routes> <route path="/cdapui/"> <rewrite apply="CDAPUI/cdap/inbound/root" to="request.url"/> </route> <route path="/cdapui/**"> <rewrite apply="CDAPUI/cdap/inbound/path" to="request.url"/> </route> <route path="/cdapui/**?**"> <rewrite apply="CDAPUI/cdap/inbound/queryv" to="request.url"/> </route> </routes> <dispatch classname="org.apache.hadoop.gateway.dispatch.PassAllHeadersDispatch"/> </service> Rewrite.xml: <rules> <rule dir="IN" name="CDAPUI/cdap/inbound/root" pattern="*://*:*/**/cdapui/"> <rewrite template="{$serviceUrl[CDAPUI]}/"/> </rule> <rule dir="IN" name="CDAPUI/cdap/inbound/path" pattern="*://*:*/**/cdapui/{**}"> <rewrite template="{$serviceUrl[CDAPUI]}/{**}"/> </rule> <rule dir="IN" name="CDAPUI/cdap/inbound/queryv" pattern="*://*:*/**/cdapui/{**}?{**}"> <rewrite template="{$serviceUrl[CDAPUI]}/{**}?{**}"/> </rule> </rules> Now, the expectation from these rules were that any URL with ? should match queryv rule. But in actual for calls containing ? , knox sometimes matches queryv but some times matches path rule. Whenever it apply queryv, the redirected URL is correct but whenever it matches path rule for URL with ? , the redirected URL trim the query part of the URL (I.e everthing that comes after ? in URL). Here is some calsl from gateway.log where knox is applying different rules for same pattern of URLs: 1- Here for https://192.168.134.119:8443/gateway/default/cdapui/_sock/717/lmweicc4/htmlfile?c=_jp.aok0aa1 URL, knox applies path rule instead of queryv rule, as a result of which redirected URL is wrong 2018-08-30 09:45:34,417 DEBUG hadoop.gateway (UrlRewriteProcessor.java:rewrite(166)) - Rewrote URL: https://192.168.134.119:8443/gateway/default/cdapui/_sock/717/lmweicc4/htmlfile?c=_jp.aok0aa1, direction: IN via explicit rule: CDAPUI/cdap/inbound/path to URL: http://platacc003-mst-01.gvs.ggn:11011/_sock/717/lmweicc4/htmlfile 2- Another example where for URL https://192.168.134.119:8443/gateway/default/cdapui/pipelines/ns/_sock/729/5wugs1dc/htmlfile?c=_jp.abxtrqj, knox applies queryv rule, as a result of which redirected URL is correct 2018-08-30 09:45:34,936 DEBUG hadoop.gateway (UrlRewriteProcessor.java:rewrite(164)) - Rewrote URL: https://192.168.134.119:8443/gateway/default/cdapui/pipelines/ns/_sock/729/5wugs1dc/htmlfile?c=_jp.abxtrqj, direction: IN via implicit rule: CDAPUI/cdap/inbound/queryv to URL: http://platacc003-mst-01.gvs.ggn:11011/pipelines/ns/_sock/729/5wugs1dc/htmlfile?c=_jp.abxtrqj Any idea why knox is applying different rules for URLs with similar pattern?? Thanks Divya