You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@knox.apache.org by Jeffrey Rodriguez <je...@gmail.com> on 2015/07/28 02:38:35 UTC

Using outbound rewrite patterns in html meta refrex

Have a question on how to rewrite outbound html meta refresh.
e.g.

Let say I want to change:

<meta http-equiv="refresh" content="0; url=http://service">

into
<meta http-equiv="refresh" content="0;
url=http://knox_host:knox_port/gateway/default/service">

So I can route page through Knox.

I can match the entire "0; url=http://service" with a rule dir="OUT" but I
don't have control on
how to parse the refresh time form the url.


But I would like to figure out a way so I get the refresh time.

Does Knox support regex  rule patterns on rule/rewrite template?

If it does then I could use something like (\d);\s*(.*) to capture the
refresh time in the rule and use
it in the rewrite template.

Thanks,
                     Jeffrey Rodriguez

Re: Using outbound rewrite patterns in html meta refrex

Posted by Kevin Minder <ke...@hortonworks.com>.
Awesome.  I’ll look for the jira and then fill it with as many startup tips as I can manage.

From: Jeffrey Rodriguez
Reply-To: "user@knox.apache.org<ma...@knox.apache.org>"
Date: Tuesday, July 28, 2015 at 2:05 PM
To: "user@knox.apache.org<ma...@knox.apache.org>"
Subject: Re: Using outbound rewrite patterns in html meta refrex

Thanks Kevin. Excellent I will open a Jira. I would like to contribute that feature.

On Tue, Jul 28, 2015 at 8:45 AM, Kevin Minder <ke...@hortonworks.com>> wrote:
I’m hoping that Yu will chime in here given the recent work in this area.  I see the HTML filtering in
gateway-service-definitions/src/main/resources/services/yarnui/2.7.0/rewrite.xml
which I was assuming would facilitate what you want but it looks like it may only apply to embedded JavaScript.

  <filter name="YARNUI/yarn/outbound/apps">
    <content type="*/html">
      <apply path="https?://[^/':,]+:[\d]+/proxy/[^']*" rule="YARNUI/yarn/outbound/apps/history"/>
      <apply path="//[^/':,]+:[\d]+/node/containerlogs/container[^']*" rule="YARNUI/yarn/outbound/node/containerlogs"/>
      <apply path="(https?://[^/':,]+:[\d]+)?/cluster/app" rule="YARNUI/yarn/outbound/apps/app"/>
      <apply path="/cluster/container" rule="YARNUI/yarn/outbound/cluster/container"/>
    </content>
  </filter>

So the bottom line is that I think some additional work might still be required in this area and it should probably follow Yu’s lead.  I do see an opportunity here now for something potentially a bit more generic that might be able to encompass both use cases.  Something like

<apply-regex path=“{xpath}” regex=“{regex}” rule=“{rule}”/>

Where the rule would be applied to say group(1) of the regex.  Might even be able to build that into the normal <apply/> with an implied regex=“.*”.

From: Jeffrey Rodriguez
Reply-To: "user@knox.apache.org<ma...@knox.apache.org>"
Date: Monday, July 27, 2015 at 8:38 PM
To: "user@knox.apache.org<ma...@knox.apache.org>"
Subject: Using outbound rewrite patterns in html meta refrex

Have a question on how to rewrite outbound html meta refresh.
e.g.

Let say I want to change:

<meta http-equiv="refresh" content="0; url=http://service">


into
<meta http-equiv="refresh" content="0; url=http://knox_host:knox_port/gateway/default/service">

So I can route page through Knox.

I can match the entire "0; url=http://service" with a rule dir="OUT" but I don't have control on
how to parse the refresh time form the url.


But I would like to figure out a way so I get the refresh time.

Does Knox support regex  rule patterns on rule/rewrite template?

If it does then I could use something like (\d);\s*(.*) to capture the refresh time in the rule and use
it in the rewrite template.

Thanks,
                     Jeffrey Rodriguez


Re: Using outbound rewrite patterns in html meta refrex

Posted by Jeffrey Rodriguez <je...@gmail.com>.
Thanks Kevin. Excellent I will open a Jira. I would like to contribute that
feature.

On Tue, Jul 28, 2015 at 8:45 AM, Kevin Minder <ke...@hortonworks.com>
wrote:

>  I’m hoping that Yu will chime in here given the recent work in this
> area.  I see the HTML filtering in
>
> gateway-service-definitions/src/main/resources/services/yarnui/2.7.0/rewrite.xml
> which I was assuming would facilitate what you want but it looks like it
> may only apply to embedded JavaScript.
>
>    <filter name="YARNUI/yarn/outbound/apps">
>     <content type="*/html">
>       <apply path="https?://[^/':,]+:[\d]+/proxy/[^']*"
> rule="YARNUI/yarn/outbound/apps/history"/>
>       <apply path="//[^/':,]+:[\d]+/node/containerlogs/container[^']*"
> rule="YARNUI/yarn/outbound/node/containerlogs"/>
>       <apply path="(https?://[^/':,]+:[\d]+)?/cluster/app"
> rule="YARNUI/yarn/outbound/apps/app"/>
>       <apply path="/cluster/container"
> rule="YARNUI/yarn/outbound/cluster/container"/>
>     </content>
>   </filter>
>
>  So the bottom line is that I think some additional work might still be
> required in this area and it should probably follow Yu’s lead.  I do see an
> opportunity here now for something potentially a bit more generic that
> might be able to encompass both use cases.  Something like
>
>  <apply-regex path=“{xpath}” regex=“{regex}” rule=“{rule}”/>
>
>  Where the rule would be applied to say group(1) of the regex.  Might
> even be able to build that into the normal <apply/> with an implied
> regex=“.*”.
>
>   From: Jeffrey Rodriguez
> Reply-To: "user@knox.apache.org"
> Date: Monday, July 27, 2015 at 8:38 PM
> To: "user@knox.apache.org"
> Subject: Using outbound rewrite patterns in html meta refrex
>
>     Have a question on how to rewrite outbound html meta refresh.
>  e.g.
>
>  Let say I want to change:
>
> <meta http-equiv="refresh" content="0; url=http://service">
>
> into
> <meta http-equiv="refresh" content="0; url=http://knox_host:knox_port/gateway/default/service">
>
> So I can route page through Knox.
>
>  I can match the entire "0; url=http://service" with a rule dir="OUT" but
> I don't have control on
>  how to parse the refresh time form the url.
>
>
>  But I would like to figure out a way so I get the refresh time.
>
>  Does Knox support regex  rule patterns on rule/rewrite template?
>
>  If it does then I could use something like (\d);\s*(.*) to capture the
> refresh time in the rule and use
>  it in the rewrite template.
>
>  Thanks,
>                       Jeffrey Rodriguez
>

Re: Using outbound rewrite patterns in html meta refrex

Posted by Kevin Minder <ke...@hortonworks.com>.
I’m hoping that Yu will chime in here given the recent work in this area.  I see the HTML filtering in
gateway-service-definitions/src/main/resources/services/yarnui/2.7.0/rewrite.xml
which I was assuming would facilitate what you want but it looks like it may only apply to embedded JavaScript.

  <filter name="YARNUI/yarn/outbound/apps">
    <content type="*/html">
      <apply path="https?://[^/':,]+:[\d]+/proxy/[^']*" rule="YARNUI/yarn/outbound/apps/history"/>
      <apply path="//[^/':,]+:[\d]+/node/containerlogs/container[^']*" rule="YARNUI/yarn/outbound/node/containerlogs"/>
      <apply path="(https?://[^/':,]+:[\d]+)?/cluster/app" rule="YARNUI/yarn/outbound/apps/app"/>
      <apply path="/cluster/container" rule="YARNUI/yarn/outbound/cluster/container"/>
    </content>
  </filter>

So the bottom line is that I think some additional work might still be required in this area and it should probably follow Yu’s lead.  I do see an opportunity here now for something potentially a bit more generic that might be able to encompass both use cases.  Something like

<apply-regex path=“{xpath}” regex=“{regex}” rule=“{rule}”/>

Where the rule would be applied to say group(1) of the regex.  Might even be able to build that into the normal <apply/> with an implied regex=“.*”.

From: Jeffrey Rodriguez
Reply-To: "user@knox.apache.org<ma...@knox.apache.org>"
Date: Monday, July 27, 2015 at 8:38 PM
To: "user@knox.apache.org<ma...@knox.apache.org>"
Subject: Using outbound rewrite patterns in html meta refrex

Have a question on how to rewrite outbound html meta refresh.
e.g.

Let say I want to change:

<meta http-equiv="refresh" content="0; url=http://service">


into
<meta http-equiv="refresh" content="0; url=http://knox_host:knox_port/gateway/default/service">

So I can route page through Knox.

I can match the entire "0; url=http://service" with a rule dir="OUT" but I don't have control on
how to parse the refresh time form the url.


But I would like to figure out a way so I get the refresh time.

Does Knox support regex  rule patterns on rule/rewrite template?

If it does then I could use something like (\d);\s*(.*) to capture the refresh time in the rule and use
it in the rewrite template.

Thanks,
                     Jeffrey Rodriguez