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. >