You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by "Attila Csoma (JIRA)" <ji...@apache.org> on 2018/05/07 08:23:00 UTC

[jira] [Commented] (KNOX-1295) X-Forwarded-Context contains not the full base path in SHS request

    [ https://issues.apache.org/jira/browse/KNOX-1295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16465621#comment-16465621 ] 

Attila Csoma commented on KNOX-1295:
------------------------------------

Hi [~mgaido]

You can attach a static string to the end of the {{X-Forwarded-Context}} header by defining a rewrite rule for it.
Uploaded a patch to add {{sparkhistoryui}} to the end of {{X-Forwarded-Cache}} in sparkhistoryui service by default.

If you want to do this on your deployed environment please add the following:
 in {{data/services/sparkhistoryui/1.4.0/service.xml}}
{code:java}
<route path="/sparkhistory">
 <rewrite apply="SPARKHISTORYUI/sparkhistory/outbound/rqheaders" to="request.headers"/>
</route>
<route path="/sparkhistory/**">
 <rewrite apply="SPARKHISTORYUI/sparkhistory/outbound/rqheaders" to="request.headers"/>
</route>
{code}
in {{data/services/sparkhistoryui/1.4.0/rewrite.xml}}
{code:java}
  <rule dir="IN" name="SPARKHISTORYUI/sparkhistory/outbound/rqheaders/xfc">
    <match pattern="{**}"/>
    <rewrite template="{**}/sparkhistoryui" />
  </rule>


  <filter name="SPARKHISTORYUI/sparkhistory/outbound/rqheaders">
    <content type="application/x-http-headers">
      <apply path="X-Forwarded-Context" rule="SPARKHISTORYUI/sparkhistory/outbound/rqheaders/xfc"/>
    </content>
  </filter>
{code}
Clear your {{data/deployments/}} cache and restart your knox.

If you need to change the attached {{sparkhistoryui}} text just change it in {{SPARKHISTORYUI/sparkhistory/outbound/rqheaders/xfc}}

> X-Forwarded-Context contains not the full base path in SHS request
> ------------------------------------------------------------------
>
>                 Key: KNOX-1295
>                 URL: https://issues.apache.org/jira/browse/KNOX-1295
>             Project: Apache Knox
>          Issue Type: Improvement
>    Affects Versions: 0.14.0
>            Reporter: Marco Gaido
>            Assignee: Attila Csoma
>            Priority: Major
>             Fix For: 1.1.0
>
>         Attachments: KNOX-1295.patch
>
>
> Knox can send the base path which may be useful for the proxied application in order to determine the proxy base URL and build the URLs accordingly. This may be useful in Spark History Server which may use this to determine the proxy base URL, instead of relying on an internal config (which prevents SHS to be consumed through direct URL anymore).
> The problem is that Knox currently in the {{X-Forwarded-Context}} doesn't send the full base path, but only the first part of it, eg. it sends {{X-Forwarded-Context: gateway/default}} instead of {{X-Forwarded-Context: gateway/default/sparkhistoryui}}.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)