Repository: knox Updated Branches: refs/heads/master 040e9442c -> da237588d
KNOX-1326 merge DATANODE rewrite rules into HDFSUI Project: http://git-wip-us.apache.org/repos/asf/knox/repo Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/da237588 Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/da237588 Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/da237588 Branch: refs/heads/master Commit: da237588d13ea9bd2d6e5e81f9ec7aa7824f770e Parents: 040e944 Author: Sandeep More <[email protected]> Authored: Fri Jun 1 08:52:00 2018 -0400 Committer: Sandeep More <[email protected]> Committed: Fri Jun 1 08:52:00 2018 -0400 ---------------------------------------------------------------------- .../resources/services/hdfsui/2.7.0/rewrite.xml | 116 +++++++++++++------ .../resources/services/hdfsui/2.7.0/service.xml | 20 +++- 2 files changed, 102 insertions(+), 34 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/knox/blob/da237588/gateway-service-definitions/src/main/resources/services/hdfsui/2.7.0/rewrite.xml ---------------------------------------------------------------------- diff --git a/gateway-service-definitions/src/main/resources/services/hdfsui/2.7.0/rewrite.xml b/gateway-service-definitions/src/main/resources/services/hdfsui/2.7.0/rewrite.xml index 1cd047b..9c58335 100644 --- a/gateway-service-definitions/src/main/resources/services/hdfsui/2.7.0/rewrite.xml +++ b/gateway-service-definitions/src/main/resources/services/hdfsui/2.7.0/rewrite.xml @@ -18,6 +18,62 @@ <rules> <!-- Route in rules --> + + <!-- DATANODE Rules --> + <rule dir="IN" name="DATANODE/datanode/inbound/master/query2" pattern="*://*:*/**/hdfs/datanode/?host={host}?{**}"> + <rewrite template="{host}/?{**}"/> + </rule> + + <rule dir="IN" name="DATANODE/datanode/inbound/master/query" pattern="*://*:*/**/hdfs/datanode/{**}?host={host}?{**}"> + <rewrite template="{host}/{**}?{**}"/> + </rule> + + <rule dir="IN" name="DATANODE/datanode/inbound/static" pattern="*://*:*/**/hdfs/static/{**}?host={host}?{**}"> + <rewrite template="{host}/static/{**}?{**}"/> + </rule> + <rule dir="IN" name="DATANODE/datanode/inbound/logs" pattern="*://*:*/**/hdfs/datanode/logs/?host={host}"> + <rewrite template="{host}/logs/"/> + </rule> + <rule dir="IN" name="DATANODE/datanode/inbound/logs/files" pattern="*://*:*/**/hdfs/datanode/logs/{**}?host={host}"> + <rewrite template="{host}/logs/{**}"/> + </rule> + + <rule dir="OUT" name="DATANODE/inbound/datanode/html" pattern="*0;url=datanode.html"> + <rewrite template="{$prefix[0;url&equals;,url]}/hdfs/datanode/datanode.html?host={$inboundurl[host]}"/> + </rule> + <rule dir="OUT" name="DATANODE/outbound/datanode/dn" pattern="/dn.js"> + <rewrite template="{gateway.url}/hdfs/datanode/dn.js?host={$inboundurl[host]}"/> + </rule> + <rule dir="OUT" name="DATANODE/outbound/datanode/dfs/jmx" pattern="/jmx?{**}"> + <rewrite template="{gateway.url}/hdfs/datanode/jmx?host={$inboundurl[host]}?{**}"/> + </rule> + <rule dir="OUT" name="DATANODE/datanode/html/logs" pattern="/logs"> + <rewrite template="{gateway.url}/hdfs/datanode/logs/?host={$inboundurl[host]}"/> + </rule> + <rule dir="OUT" name="DATANODE/datanode/html/OUT" pattern="/static/{**}"> + <rewrite template="{gateway.url}/hdfs/datanode/static/{**}?host={$inboundurl[host]}"/> + </rule> + <rule dir="OUT" name="DATANODE/datanode/html/jetty-dir-css" pattern="jetty-dir.css"> + <rewrite template="{gateway.url}/hdfs/datanode/static/jetty-dir.css?host={$inboundurl[host]}"/> + </rule> + + <filter name="DATANODE/outbound/datanode/static"> + <content type="*/html"> + <apply path="dn.js" rule="DATANODE/outbound/datanode/dn"/> + <apply path=".*datanode\.html" rule="DATANODE/inbound/datanode/html"/> + <apply path="logs" rule="DATANODE/datanode/html/logs"/> + <apply path="jetty-dir.css" rule="DATANODE/datanode/html/jetty-dir-css"/> + <apply path=".*\.js" rule="DATANODE/datanode/html/OUT"/> + <apply path=".*\.css" rule="DATANODE/datanode/html/OUT"/> + </content> + <content type="application/x-javascript"> + <apply path="/jmx" rule="DATANODE/outbound/datanode/dfs/jmx"/> + </content> + <content type="application/javascript"> + <apply path="/jmx" rule="DATANODE/outbound/datanode/dfs/jmx"/> + </content> + </filter> + <!-- namenode rules --> <rule dir="IN" name="HDFSUI/hdfs/inbound/namenode/root" pattern="*://*:*/**/hdfs/"> <rewrite template="{$serviceUrl[HDFSUI]}/"/> @@ -40,15 +96,10 @@ <rule dir="IN" name="HDFSUI/hdfs/inbound/logs" pattern="*://*:*/**/hdfs/logs"> <rewrite template="{$serviceUrl[HDFSUI]}/logs"/> </rule> - <rule dir="IN" name="HDFSUI/hdfs/inbound/logs/files" pattern="*://*:*/**/hdfs/logs/{**}"> + <rule dir="IN" name="HDFSUI/hdfs/inbound/logs/files" pattern="*://*:*/**/hdfs/logs/{**}"> <rewrite template="{$serviceUrl[HDFSUI]}/logs/{**}"/> </rule> - <!-- datanode rules --> - <rule dir="IN" name="HDFSUI/hdfs/inbound/datanode" pattern="*://*:*/**/hdfs/datanode?{host}"> - <rewrite template="{$serviceScheme[HDFSUI]}:{host}/datanode.html"/> - </rule> - <!-- After the redirection(302) from {gateway.url}/hdfs/logs/?{**}, hdfs returns the datanode host from which we need to access the log as part of the redirection location header. @@ -63,13 +114,12 @@ {**} -> user.name=guest --> <rule dir="IN" name="HDFSUI/hdfs/inbound/logs/redir" pattern="*://*:*/**/hdfs/logs?{scheme}?{host}?{port}?{**}"> - <rewrite template="{scheme}://{host}:{port}/logs/?{**}"/> - </rule> + <rewrite template="{scheme}://{host}:{port}/logs/?{**}"/> + </rule> <!-- Outbound rewrite rule that apply to html body--> <rule dir="OUT" name="HDFSUI/content/static" pattern="/static/{**}"> - <rewrite template="{gateway.url}/hdfs/static/{**}"/> </rule> <rule dir="OUT" name="HDFSUI/content/resource" pattern="dfshealth.js"> @@ -79,8 +129,8 @@ <rewrite template="{gateway.url}/hdfs/logs/{**}"/> </rule> <rule dir="OUT" name="HDFSUI/hdfs/outbound/datanode"> - <match pattern="//{dnWebAddress}"/> - <rewrite template="/gateway/default/datanode/?host=http://{dnWebAddress}"/> + <match pattern="//{dnWebAddress}"/> + <rewrite template="/gateway/default/datanode/?host=http://{dnWebAddress}"/> </rule> <!-- rules for to fix angular infoAddr variable KNOX-1242 --> @@ -94,7 +144,7 @@ </rule> <rule dir="OUT" name="HDFSUI/hdfs/outbound/datanode/address"> <match pattern="{dnWebAddress}"/> - <rewrite template="{$prefix[',url]}/datanode/?host={dnWebAddress}'"/> + <rewrite template="{$prefix[',url]}/hdfs/datanode/?host={dnWebAddress}'"/> </rule> <!-- Redirection rules that rewrite the Location reponse header --> @@ -104,19 +154,19 @@ </content> </filter> - <!-- - The following outbound rule re-writes the response Location header, and it used by the - "HDFSUI/hdfs/outbound/headers/logs" redirection rule. - Any /logs query parameter is matched and then it is rewritten so Location has - {host} -> host=nodehost.com - host can be mapped using the hostmap function(used to map server that may have an outside hostname and inside hostname - see hostmap function in Knox User's guide). - {scheme} -> scheme=http - {port} -> port=50070 - {**} -> user.name=guest - The result of rewriting the Location header is that the browser then will go through Knox, and the next request - will trigger the inbound "HDFSUI/hdfs/inbound/logs/redir" rule. - --> + <!-- + The following outbound rule re-writes the response Location header, and it used by the + "HDFSUI/hdfs/outbound/headers/logs" redirection rule. + Any /logs query parameter is matched and then it is rewritten so Location has + {host} -> host=nodehost.com + host can be mapped using the hostmap function(used to map server that may have an outside hostname and inside hostname + see hostmap function in Knox User's guide). + {scheme} -> scheme=http + {port} -> port=50070 + {**} -> user.name=guest + The result of rewriting the Location header is that the browser then will go through Knox, and the next request + will trigger the inbound "HDFSUI/hdfs/inbound/logs/redir" rule. + --> <rule dir="OUT" name="HDFSUI/hdfs/outbound/headers/logs/location"> <match pattern="{scheme}://{host}:{port}/logs/?{**}"/> <rewrite template="{gateway.url}/hdfs/logs?{scheme}?host={$hostmap(host)}?{port}?{**}"/> @@ -150,14 +200,14 @@ <apply path="/webhdfs" rule="HDFSUI/hdfs/outbound/namenode/relative/webhdfs"/> </content> <content type="*/html"> - <apply path="//\{dnWebAddress\}" rule="HDFSUI/hdfs/outbound/datanode"/> - <!-- rules for to fix angular infoAddr variable KNOX-1242 --> - <apply path="\'//\{infoAddr\}\'" rule="HDFSUI/hdfs/outbound/datanode/infoAddr"/> - <apply path="\'//\{infoSecureAddr\}\'" rule="HDFSUI/hdfs/outbound/datanode/infoSecureAddr"/> - <!-- KNOX-1277 --> - <apply path=".*dfshealth\.html" rule="HDFSUI/hdfs/inbound/namenode/root/filter/refresh-tag"/> - <!-- DN web Address Change --> - <apply path="\'\{dnWebAddress\}\'" rule="HDFSUI/hdfs/outbound/datanode/address"/> + <apply path="//\{dnWebAddress\}" rule="HDFSUI/hdfs/outbound/datanode"/> + <!-- rules for to fix angular infoAddr variable KNOX-1242 --> + <apply path="\'//\{infoAddr\}\'" rule="HDFSUI/hdfs/outbound/datanode/infoAddr"/> + <apply path="\'//\{infoSecureAddr\}\'" rule="HDFSUI/hdfs/outbound/datanode/infoSecureAddr"/> + <!-- KNOX-1277 --> + <apply path=".*dfshealth\.html" rule="HDFSUI/hdfs/inbound/namenode/root/filter/refresh-tag"/> + <!-- DN web Address Change --> + <apply path="\'\{dnWebAddress\}\'" rule="HDFSUI/hdfs/outbound/datanode/address"/> </content> </filter> http://git-wip-us.apache.org/repos/asf/knox/blob/da237588/gateway-service-definitions/src/main/resources/services/hdfsui/2.7.0/service.xml ---------------------------------------------------------------------- diff --git a/gateway-service-definitions/src/main/resources/services/hdfsui/2.7.0/service.xml b/gateway-service-definitions/src/main/resources/services/hdfsui/2.7.0/service.xml index 82c7426..9d209a1 100644 --- a/gateway-service-definitions/src/main/resources/services/hdfsui/2.7.0/service.xml +++ b/gateway-service-definitions/src/main/resources/services/hdfsui/2.7.0/service.xml @@ -32,6 +32,24 @@ <route path="/hdfs/dfshealth.html#tab-datanode"> <rewrite apply="HDFSUI/hdfs/outbound/namenode/relative" to="response.body"/> </route> + + <!-- DATANODE Rules --> + <route path="/hdfs/datanode/"> + <rewrite apply="DATANODE/datanode/inbound/master/query2" to="request.url"/> + <rewrite apply="DATANODE/outbound/datanode/static" to="response.body"/> + </route> + <route path="/hdfs/datanode/**?**"> + <rewrite apply="DATANODE/datanode/inbound/master/query" to="request.url"/> + <rewrite apply="DATANODE/outbound/datanode/static" to="response.body"/> + </route> + <route path="/hdfs/datanode/logs/"> + <rewrite apply="DATANODE/datanode/inbound/logs" to="request.url"/> + <rewrite apply="DATANODE/outbound/datanode/static" to="response.body"/> + </route> + <route path="/hdfs/datanode/logs/**"> + <rewrite apply="DATANODE/datanode/inbound/logs/files" to="request.url"/> + <rewrite apply="DATANODE/outbound/datanode/static" to="response.body"/> + </route> </routes> - <dispatch classname="org.apache.knox.gateway.hdfs.dispatch.HdfsHttpClientDispatch" ha-classname="org.apache.knox.gateway.hdfs.dispatch.HdfsUIHaDispatch"/> + <dispatch classname="org.apache.knox.gateway.dispatch.URLDecodingDispatch"/> </service>
