You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@knox.apache.org by David Morin <mo...@gmail.com> on 2018/07/28 13:34:54 UTC

logsearch with knox 0.12.0: errors without the trailing /

Hello,

I'm quite near to resolve my problem with the double urlencoding with
logsearch but I still face to an issue that happens when users try the url
without a trailing /
https://XXXX/gateway/default/logsearch instead of
https://XXXX/gateway/default/logsearch/

I've found that the Init Js file of Logsearch contains this:

require.config({baseUrl: location.href.substring(0,
location.href.lastIndexOf("/")+1)+"scripts",

Thus, without the trailing / in the request url the logsearch context
disappears.

How can I handle this issue ?
For example, how can I replace the String above ?
Or how to force a redirect that adds the trailing / ?
https://XXXX/gateway/default/*logsearch* => https://XXXX/gateway/default/
*logsearch/*

Thanks in advance

David

Re: logsearch with knox 0.12.0: errors without the trailing /

Posted by David Morin <mo...@gmail.com>.
It seems there is no Location header at this step (because no 302 HTTP
redirect)
Is there a way to force a redirect to XXX/gateway/default/l*ogsearch/ when
we've entered XXX/gateway/default/logsearch ?*


Le sam. 28 juil. 2018 à 22:24, David Morin <mo...@gmail.com> a
écrit :

> Ho yes !! I'm currently defining a Dispatch class for that.
> It's much simpler with the use of rewrite.xml.
> Thanks a lot Sandeep
>
> David
>
> Le sam. 28 juil. 2018 à 19:55, Sandeep Moré <mo...@gmail.com> a
> écrit :
>
>> David,
>>
>> You can rewrite the location header, there are a bunch of services that
>> rewrite the location header.
>>
>> e.g.
>>
>> <filter name="SPARKHISTORYUI/sparkhistory/outbound/headers/jobs">
>>   <content type="application/x-http-headers">
>>     <apply path="Location" rule="SPARKHISTORYUI/sparkhistory/outbound/headers/jobs/location"/>
>>   </content>
>> </filter>
>>
>> <rule dir="OUT" name="SPARKHISTORYUI/sparkhistory/outbound/headers/jobs/location">
>>   <match pattern="*://*:*/history/{**}/jobs">
>>     <rewrite template="{$frontend[url]}/sparkhistory/history/{**}/jobs"/>
>>   </match>
>> </rule>
>>
>>
>>
>> On Sat, Jul 28, 2018 at 10:55 AM David Morin <mo...@gmail.com>
>> wrote:
>>
>>> yes, this is a request going in.
>>> How can I make I rewrite rule that is equivalent to a redirect HTTP
>>> (302) ?
>>> Because the script uses location.href.lastIndexOf("/") so this is the
>>> url of the browser.
>>>
>>>
>>> Le sam. 28 juil. 2018 à 16:06, Sandeep Moré <mo...@gmail.com> a
>>> écrit :
>>>
>>>> If this is for a request going in then you can create a rewrite rule
>>>> that
>>>> matches *logsearch and rewrite it to logsearch/.
>>>> If this does not work, you can try modifying the request in a custom
>>>> dispatch, NiFi dispatch
>>>> <
>>>> https://github.com/apache/knox/blob/92e2ec59a5940a9e7c67ec5cd29044f811dee40a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiResponseUtil.java#L62
>>>> >
>>>> does this.
>>>>
>>>> Best,
>>>> Sandeep
>>>>
>>>> On Sat, Jul 28, 2018 at 9:43 AM David Morin <mo...@gmail.com>
>>>> wrote:
>>>>
>>>> > ---------- Forwarded message ---------
>>>> > From: David Morin <mo...@gmail.com>
>>>> > Date: sam. 28 juil. 2018 à 15:34
>>>> > Subject: logsearch with knox 0.12.0: errors without the trailing /
>>>> > To: <us...@knox.apache.org>
>>>> >
>>>> >
>>>> > Hello,
>>>> >
>>>> > I'm quite near to resolve my problem with the double urlencoding with
>>>> > logsearch but I still face to an issue that happens when users try
>>>> the url
>>>> > without a trailing /
>>>> > https://XXXX/gateway/default/logsearch instead of
>>>> > https://XXXX/gateway/default/logsearch/
>>>> >
>>>> > I've found that the Init Js file of Logsearch contains this:
>>>> >
>>>> > require.config({baseUrl: location.href.substring(0,
>>>> > location.href.lastIndexOf("/")+1)+"scripts",
>>>> >
>>>> > Thus, without the trailing / in the request url the logsearch context
>>>> > disappears.
>>>> >
>>>> > How can I handle this issue ?
>>>> > For example, how can I replace the String above ?
>>>> > Or how to force a redirect that adds the trailing / ?
>>>> > https://XXXX/gateway/default/*logsearch* =>
>>>> https://XXXX/gateway/default/
>>>> > *logsearch/* <https://XXXX/gateway/default/*logsearch/*>
>>>> >
>>>> > Thanks in advance
>>>> >
>>>> > David
>>>> >
>>>>
>>>

Re: logsearch with knox 0.12.0: errors without the trailing /

Posted by David Morin <mo...@gmail.com>.
Ho yes !! I'm currently defining a Dispatch class for that.
It's much simpler with the use of rewrite.xml.
Thanks a lot Sandeep

David

Le sam. 28 juil. 2018 à 19:55, Sandeep Moré <mo...@gmail.com> a
écrit :

> David,
>
> You can rewrite the location header, there are a bunch of services that
> rewrite the location header.
>
> e.g.
>
> <filter name="SPARKHISTORYUI/sparkhistory/outbound/headers/jobs">
>   <content type="application/x-http-headers">
>     <apply path="Location" rule="SPARKHISTORYUI/sparkhistory/outbound/headers/jobs/location"/>
>   </content>
> </filter>
>
> <rule dir="OUT" name="SPARKHISTORYUI/sparkhistory/outbound/headers/jobs/location">
>   <match pattern="*://*:*/history/{**}/jobs">
>     <rewrite template="{$frontend[url]}/sparkhistory/history/{**}/jobs"/>
>   </match>
> </rule>
>
>
>
> On Sat, Jul 28, 2018 at 10:55 AM David Morin <mo...@gmail.com>
> wrote:
>
>> yes, this is a request going in.
>> How can I make I rewrite rule that is equivalent to a redirect HTTP (302)
>> ?
>> Because the script uses location.href.lastIndexOf("/") so this is the
>> url of the browser.
>>
>>
>> Le sam. 28 juil. 2018 à 16:06, Sandeep Moré <mo...@gmail.com> a
>> écrit :
>>
>>> If this is for a request going in then you can create a rewrite rule that
>>> matches *logsearch and rewrite it to logsearch/.
>>> If this does not work, you can try modifying the request in a custom
>>> dispatch, NiFi dispatch
>>> <
>>> https://github.com/apache/knox/blob/92e2ec59a5940a9e7c67ec5cd29044f811dee40a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiResponseUtil.java#L62
>>> >
>>> does this.
>>>
>>> Best,
>>> Sandeep
>>>
>>> On Sat, Jul 28, 2018 at 9:43 AM David Morin <mo...@gmail.com>
>>> wrote:
>>>
>>> > ---------- Forwarded message ---------
>>> > From: David Morin <mo...@gmail.com>
>>> > Date: sam. 28 juil. 2018 à 15:34
>>> > Subject: logsearch with knox 0.12.0: errors without the trailing /
>>> > To: <us...@knox.apache.org>
>>> >
>>> >
>>> > Hello,
>>> >
>>> > I'm quite near to resolve my problem with the double urlencoding with
>>> > logsearch but I still face to an issue that happens when users try the
>>> url
>>> > without a trailing /
>>> > https://XXXX/gateway/default/logsearch instead of
>>> > https://XXXX/gateway/default/logsearch/
>>> >
>>> > I've found that the Init Js file of Logsearch contains this:
>>> >
>>> > require.config({baseUrl: location.href.substring(0,
>>> > location.href.lastIndexOf("/")+1)+"scripts",
>>> >
>>> > Thus, without the trailing / in the request url the logsearch context
>>> > disappears.
>>> >
>>> > How can I handle this issue ?
>>> > For example, how can I replace the String above ?
>>> > Or how to force a redirect that adds the trailing / ?
>>> > https://XXXX/gateway/default/*logsearch* =>
>>> https://XXXX/gateway/default/
>>> > *logsearch/* <https://XXXX/gateway/default/*logsearch/*>
>>> >
>>> > Thanks in advance
>>> >
>>> > David
>>> >
>>>
>>

Re: logsearch with knox 0.12.0: errors without the trailing /

Posted by Sandeep Moré <mo...@gmail.com>.
David,

You can rewrite the location header, there are a bunch of services that
rewrite the location header.

e.g.

<filter name="SPARKHISTORYUI/sparkhistory/outbound/headers/jobs">
  <content type="application/x-http-headers">
    <apply path="Location"
rule="SPARKHISTORYUI/sparkhistory/outbound/headers/jobs/location"/>
  </content>
</filter>

<rule dir="OUT"
name="SPARKHISTORYUI/sparkhistory/outbound/headers/jobs/location">
  <match pattern="*://*:*/history/{**}/jobs">
    <rewrite template="{$frontend[url]}/sparkhistory/history/{**}/jobs"/>
  </match>
</rule>



On Sat, Jul 28, 2018 at 10:55 AM David Morin <mo...@gmail.com>
wrote:

> yes, this is a request going in.
> How can I make I rewrite rule that is equivalent to a redirect HTTP (302) ?
> Because the script uses location.href.lastIndexOf("/") so this is the url
> of the browser.
>
>
> Le sam. 28 juil. 2018 à 16:06, Sandeep Moré <mo...@gmail.com> a
> écrit :
>
>> If this is for a request going in then you can create a rewrite rule that
>> matches *logsearch and rewrite it to logsearch/.
>> If this does not work, you can try modifying the request in a custom
>> dispatch, NiFi dispatch
>> <
>> https://github.com/apache/knox/blob/92e2ec59a5940a9e7c67ec5cd29044f811dee40a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiResponseUtil.java#L62
>> >
>> does this.
>>
>> Best,
>> Sandeep
>>
>> On Sat, Jul 28, 2018 at 9:43 AM David Morin <mo...@gmail.com>
>> wrote:
>>
>> > ---------- Forwarded message ---------
>> > From: David Morin <mo...@gmail.com>
>> > Date: sam. 28 juil. 2018 à 15:34
>> > Subject: logsearch with knox 0.12.0: errors without the trailing /
>> > To: <us...@knox.apache.org>
>> >
>> >
>> > Hello,
>> >
>> > I'm quite near to resolve my problem with the double urlencoding with
>> > logsearch but I still face to an issue that happens when users try the
>> url
>> > without a trailing /
>> > https://XXXX/gateway/default/logsearch instead of
>> > https://XXXX/gateway/default/logsearch/
>> >
>> > I've found that the Init Js file of Logsearch contains this:
>> >
>> > require.config({baseUrl: location.href.substring(0,
>> > location.href.lastIndexOf("/")+1)+"scripts",
>> >
>> > Thus, without the trailing / in the request url the logsearch context
>> > disappears.
>> >
>> > How can I handle this issue ?
>> > For example, how can I replace the String above ?
>> > Or how to force a redirect that adds the trailing / ?
>> > https://XXXX/gateway/default/*logsearch* =>
>> https://XXXX/gateway/default/
>> > *logsearch/* <https://XXXX/gateway/default/*logsearch/*>
>> >
>> > Thanks in advance
>> >
>> > David
>> >
>>
>

Re: logsearch with knox 0.12.0: errors without the trailing /

Posted by David Morin <mo...@gmail.com>.
yes, this is a request going in.
How can I make I rewrite rule that is equivalent to a redirect HTTP (302) ?
Because the script uses location.href.lastIndexOf("/") so this is the url
of the browser.


Le sam. 28 juil. 2018 à 16:06, Sandeep Moré <mo...@gmail.com> a
écrit :

> If this is for a request going in then you can create a rewrite rule that
> matches *logsearch and rewrite it to logsearch/.
> If this does not work, you can try modifying the request in a custom
> dispatch, NiFi dispatch
> <
> https://github.com/apache/knox/blob/92e2ec59a5940a9e7c67ec5cd29044f811dee40a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiResponseUtil.java#L62
> >
> does this.
>
> Best,
> Sandeep
>
> On Sat, Jul 28, 2018 at 9:43 AM David Morin <mo...@gmail.com>
> wrote:
>
> > ---------- Forwarded message ---------
> > From: David Morin <mo...@gmail.com>
> > Date: sam. 28 juil. 2018 à 15:34
> > Subject: logsearch with knox 0.12.0: errors without the trailing /
> > To: <us...@knox.apache.org>
> >
> >
> > Hello,
> >
> > I'm quite near to resolve my problem with the double urlencoding with
> > logsearch but I still face to an issue that happens when users try the
> url
> > without a trailing /
> > https://XXXX/gateway/default/logsearch instead of
> > https://XXXX/gateway/default/logsearch/
> >
> > I've found that the Init Js file of Logsearch contains this:
> >
> > require.config({baseUrl: location.href.substring(0,
> > location.href.lastIndexOf("/")+1)+"scripts",
> >
> > Thus, without the trailing / in the request url the logsearch context
> > disappears.
> >
> > How can I handle this issue ?
> > For example, how can I replace the String above ?
> > Or how to force a redirect that adds the trailing / ?
> > https://XXXX/gateway/default/*logsearch* =>
> https://XXXX/gateway/default/
> > *logsearch/* <https://XXXX/gateway/default/*logsearch/*>
> >
> > Thanks in advance
> >
> > David
> >
>

Re: logsearch with knox 0.12.0: errors without the trailing /

Posted by David Morin <mo...@gmail.com>.
yes, this is a request going in.
How can I make I rewrite rule that is equivalent to a redirect HTTP (302) ?
Because the script uses location.href.lastIndexOf("/") so this is the url
of the browser.


Le sam. 28 juil. 2018 à 16:06, Sandeep Moré <mo...@gmail.com> a
écrit :

> If this is for a request going in then you can create a rewrite rule that
> matches *logsearch and rewrite it to logsearch/.
> If this does not work, you can try modifying the request in a custom
> dispatch, NiFi dispatch
> <
> https://github.com/apache/knox/blob/92e2ec59a5940a9e7c67ec5cd29044f811dee40a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiResponseUtil.java#L62
> >
> does this.
>
> Best,
> Sandeep
>
> On Sat, Jul 28, 2018 at 9:43 AM David Morin <mo...@gmail.com>
> wrote:
>
> > ---------- Forwarded message ---------
> > From: David Morin <mo...@gmail.com>
> > Date: sam. 28 juil. 2018 à 15:34
> > Subject: logsearch with knox 0.12.0: errors without the trailing /
> > To: <us...@knox.apache.org>
> >
> >
> > Hello,
> >
> > I'm quite near to resolve my problem with the double urlencoding with
> > logsearch but I still face to an issue that happens when users try the
> url
> > without a trailing /
> > https://XXXX/gateway/default/logsearch instead of
> > https://XXXX/gateway/default/logsearch/
> >
> > I've found that the Init Js file of Logsearch contains this:
> >
> > require.config({baseUrl: location.href.substring(0,
> > location.href.lastIndexOf("/")+1)+"scripts",
> >
> > Thus, without the trailing / in the request url the logsearch context
> > disappears.
> >
> > How can I handle this issue ?
> > For example, how can I replace the String above ?
> > Or how to force a redirect that adds the trailing / ?
> > https://XXXX/gateway/default/*logsearch* =>
> https://XXXX/gateway/default/
> > *logsearch/* <https://XXXX/gateway/default/*logsearch/*>
> >
> > Thanks in advance
> >
> > David
> >
>

Re: logsearch with knox 0.12.0: errors without the trailing /

Posted by Sandeep Moré <mo...@gmail.com>.
If this is for a request going in then you can create a rewrite rule that
matches *logsearch and rewrite it to logsearch/.
If this does not work, you can try modifying the request in a custom
dispatch, NiFi dispatch
<https://github.com/apache/knox/blob/92e2ec59a5940a9e7c67ec5cd29044f811dee40a/gateway-service-nifi/src/main/java/org/apache/knox/gateway/dispatch/NiFiResponseUtil.java#L62>
does this.

Best,
Sandeep

On Sat, Jul 28, 2018 at 9:43 AM David Morin <mo...@gmail.com>
wrote:

> ---------- Forwarded message ---------
> From: David Morin <mo...@gmail.com>
> Date: sam. 28 juil. 2018 à 15:34
> Subject: logsearch with knox 0.12.0: errors without the trailing /
> To: <us...@knox.apache.org>
>
>
> Hello,
>
> I'm quite near to resolve my problem with the double urlencoding with
> logsearch but I still face to an issue that happens when users try the url
> without a trailing /
> https://XXXX/gateway/default/logsearch instead of
> https://XXXX/gateway/default/logsearch/
>
> I've found that the Init Js file of Logsearch contains this:
>
> require.config({baseUrl: location.href.substring(0,
> location.href.lastIndexOf("/")+1)+"scripts",
>
> Thus, without the trailing / in the request url the logsearch context
> disappears.
>
> How can I handle this issue ?
> For example, how can I replace the String above ?
> Or how to force a redirect that adds the trailing / ?
> https://XXXX/gateway/default/*logsearch* => https://XXXX/gateway/default/
> *logsearch/* <https://XXXX/gateway/default/*logsearch/*>
>
> Thanks in advance
>
> David
>

Fwd: logsearch with knox 0.12.0: errors without the trailing /

Posted by David Morin <mo...@gmail.com>.
---------- Forwarded message ---------
From: David Morin <mo...@gmail.com>
Date: sam. 28 juil. 2018 à 15:34
Subject: logsearch with knox 0.12.0: errors without the trailing /
To: <us...@knox.apache.org>


Hello,

I'm quite near to resolve my problem with the double urlencoding with
logsearch but I still face to an issue that happens when users try the url
without a trailing /
https://XXXX/gateway/default/logsearch instead of
https://XXXX/gateway/default/logsearch/

I've found that the Init Js file of Logsearch contains this:

require.config({baseUrl: location.href.substring(0,
location.href.lastIndexOf("/")+1)+"scripts",

Thus, without the trailing / in the request url the logsearch context
disappears.

How can I handle this issue ?
For example, how can I replace the String above ?
Or how to force a redirect that adds the trailing / ?
https://XXXX/gateway/default/*logsearch* => https://XXXX/gateway/default/
*logsearch/*

Thanks in advance

David