You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@knox.apache.org by "sk_acura@yahoo.com" <sk...@yahoo.com> on 2019/05/01 12:26:15 UTC

Unable to POST data to a Target Service which is proxied through KNOX

 

    On Tuesday, April 30, 2019, 7:58:03 PM EDT, sk_acura@yahoo.com <sk...@yahoo.com> wrote:  
 
 Hi All,  
   I am using 0.12 version of Knox and configured a service to be proxied through knox as listed below:
   My Topology is :
   <topology>    <gateway>        <provider>            <role>webappsec</role>            <name>WebAppSec</name>            <enabled>true</enabled>            <param>                <name>cors.enabled</name>                <value>true</value>              </param>              <param>                    <name>cors.supportedMethods</name>                    <value>GET,HEAD,POST,OPTIONS,PUT</value>               </param>                <param>                        <name>xframe.options.enabled</name>                        <value>true</value>                </param>                <param>                        <name>xframe.options</name>                        <value>SAMEORIGIN</value>                </param>        </provider>       <provider>            <role>identity-assertion</role>            <name>Default</name>            <enabled>true</enabled>        </provider>
        <service>            <role>MYSERVICE</role>            <url>http://localhost:9090</url>        </service></topology>
and the Service it self is described as
<service role="MYSERVICE" name="myservice" version="0.0.1">
        <policies>            <policy role="webappsec"/>            <policy role="authentication" name="Anonymous"/>            <policy role="rewrite"/>            <policy role="authorization"/>        </policies>
        <routes>            <route path="/myservice"/>            <route path="/myservice/**"/>        </routes>
        <dispatch classname="org.apache.hadoop.gateway.dispatch.PassAllHeadersDispatch"/>
</service>
<rules>        <rule dir="IN" name="MYSERVICE/ myservice/inbound" pattern="*://*:*/**/ myservice/{path=**}?{**}">            <rewrite template="{$serviceUrl[MYSERVICE]}/{path=**}?{**}"/>        </rule>

        <rule dir="IN" name="MYSERVICE/myservice/inbound/root" pattern="*://*:*/**/myservice/">            <rewrite template="{$serviceUrl[MYSERVICE]}/"/>        </rule>                <rule dir="IN" name="MYSERVICE/myservice/inbound/path" pattern="*://*:*/**/myservice/{**}">            <rewrite template="{$serviceUrl[MYSERVICE]}/{**}"/>        </rule>
</rules>

When i tried access the Service GET Requests are working as expected. POST requests are also routed to the service how ever the POST Body is not getting sent to the target service. Not sure what's the issue is.
ThanksSateesh
  

Re: Unable to POST data to a Target Service which is proxied through KNOX

Posted by Kevin Risden <kr...@apache.org>.
You haven't shared the exact error message you are getting including the
HTTP status code or the way that you are connecting to the service.

Here is an example without Knox that will cause POST requests to not work.
POST requests typically will not follow a redirect by default. So if you
are connecting to a load balancer in front of Knox, then POST may not work.

Kevin Risden


On Wed, May 1, 2019 at 8:26 AM sk_acura@yahoo.com <sk...@yahoo.com>
wrote:

>
>
> On Tuesday, April 30, 2019, 7:58:03 PM EDT, sk_acura@yahoo.com <
> sk_acura@yahoo.com> wrote:
>
>
> Hi All,
>
>    I am using 0.12 version of Knox and configured a service to be proxied
> through knox as listed below:
>
>    My Topology is :
>
>
> <topology>
>     <gateway>
>         <provider>
>             <role>webappsec</role>
>             <name>WebAppSec</name>
>             <enabled>true</enabled>
>             <param>
>                 <name>cors.enabled</name>
>                 <value>true</value>
>               </param>
>               <param>
>                     <name>cors.supportedMethods</name>
>                     <value>GET,HEAD,POST,OPTIONS,PUT</value>
>                </param>
>                 <param>
>                         <name>xframe.options.enabled</name>
>                         <value>true</value>
>                 </param>
>                 <param>
>                         <name>xframe.options</name>
>                         <value>SAMEORIGIN</value>
>                 </param>
>         </provider>
>        <provider>
>             <role>identity-assertion</role>
>             <name>Default</name>
>             <enabled>true</enabled>
>         </provider>
>
>         <service>
>             <role>MYSERVICE</role>
>             <url>http://localhost:9090</url>
>         </service>
> </topology>
>
> and the Service it self is described as
>
> <service role="MYSERVICE" name="myservice" version="0.0.1">
>
>         <policies>
>             <policy role="webappsec"/>
>             <policy role="authentication" name="Anonymous"/>
>             <policy role="rewrite"/>
>             <policy role="authorization"/>
>         </policies>
>
>         <routes>
>             <route path="/myservice"/>
>             <route path="/myservice/**"/>
>         </routes>
>
>         <dispatch
> classname="org.apache.hadoop.gateway.dispatch.PassAllHeadersDispatch"/>
>
> </service>
>
> <rules>
>         <rule dir="IN" name="MYSERVICE/ myservice/inbound"
> pattern="*://*:*/**/ myservice/{path=**}?{**}">
>             <rewrite template="{$serviceUrl[MYSERVICE]}/{path=**}?{**}"/>
>         </rule>
>
>
>         <rule dir="IN" name="MYSERVICE/myservice/inbound/root"
> pattern="*://*:*/**/myservice/">
>             <rewrite template="{$serviceUrl[MYSERVICE]}/"/>
>         </rule>
>
>         <rule dir="IN" name="MYSERVICE/myservice/inbound/path"
> pattern="*://*:*/**/myservice/{**}">
>             <rewrite template="{$serviceUrl[MYSERVICE]}/{**}"/>
>         </rule>
>
> </rules>
>
>
> When i tried access the Service GET Requests are working as expected. POST
> requests are also routed to the service how ever the POST Body is not
> getting sent to the target service. Not sure what's the issue is.
>
> Thanks
> Sateesh
>
>