Friday, October 3, 2008

How to run Axis2 behind a proxy and Bypass the Proxy for some Domains

I'm sure some of you might already know how to set proxy details in Axis2. Even nandana had blogged about it some time ago. For those who are not familiar with it here is how you could do it. You need to add the following parameter into your clients axis2.xml,

<parameter name="Proxy">

<Configuration>

<ProxyHost>proxy.wso2.org</ProxyHost>

<ProxyPort>5678</ProxyPort>

<ProxyUser>EXAMPLE\keith</ProxyUser>

<ProxyPassword>keithsPassword</ProxyPassword>

</Configuration>

</parameter>

There may be instances where you do not want some request to go through the proxy. For e.g lets imaging you do not want to go through the proxy on a localhost call or when you are calling foo.com. Is it possible to do this? Of course and you could do it by adding the following system property "http.nonProxyHosts",

-Dhttp.nonProxyHosts=localhost|foo.com

The http.nonProxyHosts can be set to specify the hosts which should be connected to directly (not through the proxy server). The value of the http.nonProxyHosts property can be a list of hosts, each separated by | (the pipe character). It can also take a regular expression for matches for example: *.sfbay.sun.com would match any fully qualified hostname in the sfbay domain.

For more information you could refer http://java.sun.com/features/2002/11/hilevel_network.html.

3 comments:

jcesarperez said...

Very interesting post but how can i use axis2.xml in a client? Have i put it in my classes dir?

Keith Chapman said...

This could be a bit of a long answer hence I'll cover it in a separate post.

Keith Chapman said...

I have made a small correction to the above post. Previously it said that you need to add a parameter into the axis2.xml to bypass the proxy but actually it should be a system property.