Question

I implemented a simple pass through proxy i.e. when i call

   "http://wso2esb:9443/services/proxy"  

it should forward the request to

 "http://destinationserver:80/" . 

The question is the url extensions are not carried while forwarding.. i.e.

  when i do a HTTP POST in       

       http://wso2esb:9443/services/proxy/path1/path2 

  the request is forwarded to 

       http://destinationserver:80 

  rather than to  

        http://destinationserver:80/path1/path2. 

  but HTTP GET behaves as expected. Could anyone  help in where i am going wrong?

My Proxy.xml

  <proxy xmlns="http://ws.apache.org/ns/synapse" name="proxy" transports="https,http"
   statistics="disable" trace="disable" startOnLoad="true">
   <target>
     <outSequence>
         <send/>
     </outSequence>
     <endpoint>
         <address uri="http://destinationserver:80/"/>
     </endpoint>
  </target>
  <description/>
</proxy>

Thanks in advance!

P.S: my WSO2ESB version : 4.8.1

Was it helpful?

Solution

If you really need that, one way (not sure this is the best) to achieve your goal would be :

<proxy xmlns="http://ws.apache.org/ns/synapse" name="proxy" transports="https,http"
   statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <header name="To"
                 expression="concat('http://destinationserver:80',substring-after(syn:get-property('To'),'/services/proxy'))"/>
         <send/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>

Send a post request to http://wso2esb:8280/services/proxy/path1/path2 and it should be forwarded to http://destinationserver:80/path1/path2

OTHER TIPS

Things worked as per Jeans answer but Htttp HEAD request is not forwarded except it is returning 400 Bad Request. Testing with direct link on the destination server returns expected response.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top