Any input on this?
Thanks

On Tue, 30 Apr 2019, 11:39 Odon Copon, <odonco...@gmail.com> wrote:

> Hi Sandeep,
> The response from the UI for everything looks good, except for the
> information rendered from those graphs.
> The requests to generate those graphs, from what I see on the errors, are
> GET petitions to that API I mentioned before that get back a JSON. Those
> petitions have the following information:
>
> GET /production/datapoints HTTP/1.1
> Host: knox:12002
> Connection: keep-alive
> Accept: */*
> X-Requested-With: XMLHttpRequest
> User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0)
> AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
> Referer: http://knox:12002/gateway/test/ferrerorui/site/
> Accept-Encoding: gzip, deflate
> Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
>
> And, obviously, I'm getting a 404 back from Knox, because
> knox:12002/production/datapoints is not there, it should be
> knox:12002/gateway/test/ferrerorapi/production/datapoints.
> But I don't really know how to make that with filters. Would it require
> something like the following?
>
> <filter name="FERRERORUI/ferrerorui/outbound/requests/filter">
>         <content type="application/json">
>             <apply path="???"
> rule="FERRERORUI/ferrerorui/outbound/requests"/>
>         </content>
> </filter>
>
> What does the path mean on a filter? Isn't this "apply" already pointing
> to a rule that contains a "path" and a "rewrite"?
>
> Thanks.
>
> On Tue, 30 Apr 2019 at 03:36, Sandeep Moré <moresand...@gmail.com> wrote:
>
>> Hello Odon,
>>
>> What does the response from the the ferrero UI look like? for the last
>> rewrite rule, looks like you are having issues rewriting outbound requests,
>> what response are you dealing with, JSON, HTML, plain text ? depending on
>> that you probably need to add a filter for that specific content type. I
>> think you are very close !
>>
>> Best,
>> Sandeep
>>
>>
>> On Mon, Apr 29, 2019 at 1:47 PM Odon Copon <odonco...@gmail.com> wrote:
>>
>>> Hi,
>>> I have been following the steps from
>>> https://cwiki.apache.org/confluence/display/KNOX/Proxying+a+UI+using+Knox 
>>> but
>>> I'm having some issue making something work, so would double check with you
>>> to understand if I'm making wrong assumptions.
>>> I have a UI made with React which URL is ferrerorui:8080/site/ that
>>> contains some graphs generated by some requests to
>>> ferrerorapi/production/datapoints. When I put Knox in place, I can access
>>> the UI by accessing knox:12002/gateway/test/ferrerorui/site/ and also I can
>>> send requests to the API by doing
>>> knox:12002/gateway/test/ferrerorapi/production/datapoints.
>>>
>>>
>>> This is the service defined (ferrerorapi, the API the UI consumes):
>>>
>>> service.xml
>>>
>>> <service role="FERRERORAPI" name="ferrerorapi" version="0.0.1">
>>>   <routes>
>>>     <route path="/ferrerorapi/**"/>
>>>   </routes>
>>> </service>
>>>
>>> rewrite.xml
>>>
>>> <rules>
>>>   <rule dir="IN" name="FERREORAPI/ferrerorapi/inbound"
>>> pattern="*://*:*/**/ferrerorapi/{path=**}?{**}">
>>>     <rewrite template="{$serviceUrl[FERRERORAPI]}/{path=**}?{**}"/>
>>>   </rule>
>>> </rules>
>>>
>>>
>>> Obviously, the API requests that generate the graphs are all failing
>>> with 404 when I access the UI, because they are hitting
>>> knox:12002/production/datapoints instead of
>>> knox:12002/gateway/test/ferrerorapi/production/datapoints
>>>
>>>
>>> This is the UI service:
>>>
>>> service.xml
>>>
>>> <service role="FERREORUI" name="ferrerorui" version="0.0.1">
>>>   <routes>
>>>     <route path="/ferrerorui"/>
>>>     <route path="/ferrerorui/**"/>
>>>           <rewrite apply="FERRERORUI/ferrerorui/outbound/requests"
>>> to="response.body"/>
>>>   </routes>
>>> </service>
>>>
>>> rewrite.xml
>>>
>>> <rules>
>>>     <rule dir="IN" name="FERRERORUI/ferrerorui/inbound/root"
>>> pattern="*://*:*/**/ferrerorui/">
>>>     <rewrite template="{$serviceUrl[FERRERORUI]}/"/>
>>>   </rule>
>>>   <rule dir="IN" name="FERRERORUI/ferrerorui/inbound/path"
>>> pattern="*://*:*/**/ferrerorui/{path=**}?{**}">
>>>     <rewrite template="{$serviceUrl[FERRERORUI]}/{path=**}?{**}"/>
>>>   </rule>
>>>   <rule dir="OUT" name="FERRERORUI/ferrerorui/outbound/requests"
>>> pattern="*://*:*/**/production/{path=**}?{**}">
>>>     <rewrite template="{$serviceUrl[FERRERORUI]}/{path=**}?{**}"/>
>>>   </rule>
>>> </rules>
>>>
>>>
>>> Tried with this last rewrite to convert on the UI, everything that had
>>> production as part of the path (api call) to be rewritten, but doesn't seem
>>> to work. The API call from the UI still don't contain the missing
>>> "gateway/test/ferrerorapi/".
>>>
>>> Is there anything that you spot that I'm not doing correctly?
>>> Thanks.
>>>
>>

Reply via email to