When using the proxyHost
, proxyPort
and nonProxyHosts
properties in Java to modify a URL
connection, what are the valid uses of wildcards in the nonProxyHosts
property? Could I do any or all of the following?
nonProxyHosts=server.company.com
nonProxyHosts=*.local.company.com
nonProxyHosts=192.168.101.110
nonProxyHosts=192.168.101.*
nonProxyHosts=192.168.101/23
Are there other types of patterns?
Thanks!
Check out the OpenJDK source for sun.net.spi.DefaultProxySelector
and sun.misc.Regexp
classes. The nonProxyHosts
System property gets processed there for the Sun JVM. The Regexp class was written by the Java man himself, James Gosling, according to the @author
javadoc comment. All it does is match *
regular expressions, anywhere in a string (start, middle and end). So, you can do partial hostnames as well as partial IP addresses, such as host12*
or 10.*
to match all hostnames starting with host12
or all IPs starting with 10.
. Also, DefaultProxySelector
detects localhost
and 127.0.0.1
in proxied URLs and automatically excludes them. So you don't need to add those to your nonProxyHosts
as far as the Sun JVM is concerned.
Now, in Weblogic it seems they have their own weblogic.net
classes that operate with the same Sun System net properties, but not always the same way. I don't have the Weblogic source handy, but my point is, it's not only the Sun JDK that uses these properties. YMMV with different proxy implementations out there due to bugs or different semantics or interpretations of the Sun behavior and docs.
The OpenJDK source version I referenced was from openjdk-6 at http://download.java.net/openjdk/jdk6/.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With