/
Enabling HTTP Basic Authentication through a Proxy Server

This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Enabling HTTP Basic Authentication through a Proxy Server

If WSO2 ESB is behind a firewall, your proxy service might need to talk to a server through a proxy server, which might require HTTP basic authentication.

To configure the ESB to communicate with the proxy server:

  1. In <PRODUCT_HOME>/repository/conf/axis2/axis2.xml, edit the transportSender configuration of the http transport to specify the proxy server as follows:

    <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>
  2. In the Synapse configuration of the proxy service that sends messages to this proxy server, set the following two properties before the send mediator:

    <syn:property name="Proxy-Authorization" expression="fn:concat('Basic ', base64Encode('userName:password'))" scope="transport"/>
    <syn:property name="POST_TO_URI" value="true" scope="axis2"/>

    The first property sets the Proxy-Authorization HTTP transport header with the base64 encoded user name and password as expected by the HTTP basic authentication. The second property makes the outgoing URL a complete URL understandable by the proxy server.

For example, in normal scenarios the outgoing request is sent as following:

POST /services/SimpleStockQuoteService HTTP/1.1

But the proxy server requires sending the actual URL:

POST [http://localhost:9000/services/SimpleStockQuoteService] HTTP/1.1

Following is a sample proxy service configuration that sets these two properties:

<proxy name="StockQuoteProxy" startOnLoad="true" xmlns="http://ws.apache.org/ns/synapse">
	<target>
		<inSequence>
			<property name="Proxy-Authorization" expression="fn:concat('Basic ', base64Encode('supun:test123'))" scope="transport"/>
			<property name="POST_TO_URI" value="true" scope="axis2"/>
			<send>
				<endpoint name="endpoint_urn_uuid_379C485AD3CB65037F10216600509076498395882">
					<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
				</endpoint>
			</send>
		</inSequence>
		<outSequence>
			<send/>
		</outSequence>
	</target>
	<publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
</proxy>

Related content

Enabling HTTP Basic Authentication through a Proxy Server
Enabling HTTP Basic Authentication through a Proxy Server
More like this
Enabling HTTP Basic Authentication through a Proxy Server
Enabling HTTP Basic Authentication through a Proxy Server
More like this
Enabling HTTP Basic Authentication through a Proxy Server
Enabling HTTP Basic Authentication through a Proxy Server
More like this
Working with Proxy Servers
Working with Proxy Servers
More like this
Working with Security
Working with Security
More like this
Working with Proxy Servers
Working with Proxy Servers
More like this