Configuring Tomcat to use a Proxy server

  • 3725347
  • 06-Nov-2007
  • 26-Apr-2012

Environment

Novell NetWare 6.0
Novell NetWare 6.5
Novell Open Enterprise Server (OES)
Novell Portal Services 1.5
Novell exteNd Director 4.1 Standard Edition
Tomcat 3.3
Tomcat 4.1.18
Tomcat 5.0
Novell iManager

Situation

This document describes how to configure Tomcat to use a proxy server

Resolution

Please see additional notes for other options, such as setting proxy usernames.

** For TOMCAT 3.3 **

To enable TOMCAT 3.3 on a NetWare server to use proxy, you must first modify the sys:\tomcat\33\bin\TOMCAT33.NCF file with the necessary parameters. The definitions should be added to the end of the NCF file that starts TOMCAT, not on the LOAD JAVA line. Add them to the last line in the file that actually starts up Tomcat.
Example:

java -envCWD=$TOMCAT_HOME -classpath $TOMCAT_CLASSPATH -Dhttp.proxyHost=192.168.1.1 -Dhttp.proxyPort=8080 -Dhttp.nonProxyHosts=-Xms256m -Xmx300m -dtomcat.home=SYS:\tomcat\33 org.apache.tomcat.startup.Main -f sys:/tomcat/33/conf/nwserver.xml %1

If you want to use a TOMCAT_OPTS environment variable, you can also add $TOMCAT_OPTS in the above line anywhere before the org.apache.tomcat.startup.Main. A memory flag can also be used within this CONF file. In the above example -XMS254M -XMX300M is an example of a memory flag

** For TOMCAT 4.1 **

To enable TOMCAT 4.1 on a NetWare server to use proxy, you must first modify the edit sys:\tomcat\4\bin\TOMCAT4.ncf file with the necessary parameters. The definitions should be added to the CATALINA_OPTS variable, not on the LOAD JAVA line. The line setting the CATALINA_OPTS variable should become something like this:

setenv CATALINA_OPTS = -Dhttp.proxyHost=proxy.mydomain.com -Dhttp.proxyPort=8080 -Dhttp.nonProxyHosts=192.168*|10.1.*

Where:
-Dhttp.proxyHost is the dns name or ip of proxy server
-Dhttp.proxyPort is the proxy port number
-Dhttp.nonProxyHosts are the local addresses not to be routed to proxy

UPDATE for OES Linux servers:

For Linux OES, the following changes must be made:

1. In the file /opt/novell/tomcat4/bin/dtomcat4 find the line that sets the environmental variable CATALINA_OPTS.

2. Add the following three lines:
CATALINA_OPTS="$CATALINA_OPTS -Dhttp.proxyHost=proxyhost"
CATALINA_OPTS="$CATALINA_OPTS -Dhttp.proxyPort=proxyport"
CATALINA_OPTS="$CATALINA_OPTS -Dhttp.nonProxyHosts=ip subnet"

3. Restart TOMCAT4 - /etc/init.d/novell-tomcat4 restart - after making the edits.

For Linux OES2, the following changes must be made:

1. In the file /etc/sysconfig/j2ee find the line that sets the environmental variable CATALINA_OPTS.

2. Add the following three lines:
CATALINA_OPTS="$CATALINA_OPTS -Dhttp.proxyHost=proxyhost"
CATALINA_OPTS="$CATALINA_OPTS -Dhttp.proxyPort=proxyport"
CATALINA_OPTS="$CATALINA_OPTS -Dhttp.nonProxyHosts=ip subnet"

3. Restart TOMCAT5 - /etc/init.d/novell-tomcat5 restart - after making the edits.

Additional Information

For additional information on setting the java properties: http.proxyHost and http.proxyPort refer to http://java.sun.com/docs/books/tutorial/networking/urls/_setProxy.html

Formerly known as TID# 10067182

To set a proxy username and a proxy password, similar to adding the -Dhttp.proxyHost=hostname parameter, two other parameters can be added. -Dhttp.proxyUser=username and -Dhttp.proxyPassword=supersecret can be added in a similar fashion to enable authentication for the proxy requests.