Working with Proxy Servers
When using WSO2 ESB, there can be scenarios where you need to configure WSO2 ESB to route messages through a proxy server. For example, if WSO2 ESB is behind a firewall, your proxy service might need to talk to a server through a proxy server as illustrated in the following diagram:
For such scenarios, you need to configure the ESB transport sender to forward messages through a proxy server.
Configuring WSO2 ESB to route messages through a proxy server
To configure WSO2 ESB to route messages through a proxy server:
- Edit the
<ESB_HOME>/repository/conf/axis2/axis2.xml
file, and add the following parameters in the<transportSender>
configuration of the http transport:http.proxyHost
- The host name of the proxy server.http.proxyPort
- The port number of the proxy server.
Following is a sample <transportSender>
configuration where the parameters mentioned above are set:
<transportSender name="http" class="org.apache.synapse.transport.passthru.PassThroughHttpSender"> <parameter name="non-blocking" locked="false">true</parameter> <parameter name="http.proxyHost" locked="false">localhost</parameter> <parameter name="http.proxyPort" locked="false">8080</parameter> </transportSender>
When you configure the <transportSender>
with the http.proxyHost
and http.proxyPort
parameters , all HTTP requests pass through the configured proxy server.
A proxy server might require HTTP basic authentication before it handles communication from the ESB.
Configuring proxy profiles in WSO2 ESB
When using WSO2 ESB, there can be scenarios where you need to configure multiple proxy servers to route messages to different endpoints as illustrated in the following diagram.
When you need to route messages to different endpoints through multiple proxy servers, you can configure proxy profiles.
To configure proxy profiles in WSO2 ESB:
Edit the
<ESB_HOME>/repository/conf/axis2/axis2.xml
file, add theproxyProfiles
parameter in the<transportSender>
configuration of the http transport, and then define multiple profiles based on the number of proxy servers you need to have.When you define a profile, it is mandatory to specify the
targetHosts
,proxyHost
andproxyPort
parameters for each profile.
Following is a sample proxy profile configuration that you can have in the <transportSender>
configuration of the http transport:
<parameter name="proxyProfiles"> <profile> <targetHosts>example.com, .*.sample.com</targetHosts> <proxyHost>localhost</proxyHost> <proxyPort>3128</proxyPort> <proxyUserName>squidUser</proxyUserName> <proxyPassword>password</proxyPassword> <bypass>xxx.sample.com</bypass> </profile> <profile> <targetHosts>localhost</targetHosts> <proxyHost>localhost</proxyHost> <proxyPort>7443</proxyPort> </profile> <profile> <targetHosts>*</targetHosts> <proxyHost>localhost</proxyHost> <proxyPort>7443</proxyPort> <bypass>test.com, direct.com</bypass> </profile> </parameter>
When you configure a proxy profile, following are details of the parameters that you need to define in a <profile>
:
Parameter | Description | Required |
---|---|---|
targetHosts | A host name or a comma separated list of host names for a target endpoint. | Yes |
proxyHost | The host name of the proxy server. | Yes |
proxyPort | The port number of the proxy server. | Yes |
proxyUserName | The user name for the proxy server authentication. | No |
proxyPassword | The password for the p roxy server authentication. | No |
bypass | A host name or a comma separated list of host names that should not be sent via the proxy server. For example, if you want all requests to You can specify host names as regular expressions that match a pattern. | No |