BEA Logo BEA WebLogic Server Release 6.1

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

  |  

  WebLogic Server Doc Home   |     Administration Guide   |   Previous Topic   |   Next Topic   |   Contents   |   Index   |   View as PDF

Proxying Requests to Another HTTP Server

 

The following sections discuss how to proxy HTTP requests to another HTTP server:

 


Overview

When you use WebLogic Server as your primary Web server, you may also want to configure WebLogic Server to pass on, or proxy, certain requests to a secondary HTTP server, such as Netscape Enterprise Server, Apache, Microsoft Internet Information Server, or another instance of WebLogic Server. Any request that gets proxied is redirected to a specific URL.You can even proxy to another Web server on a different machine.You proxy requests based on the URL of the incoming request.

The HttpProxyServlet (provided as part of the distribution) takes an HTTP request, redirects it to the proxy URL, and sends the response to the client's browser back through the WebLogic Server instance that is redirecting requests. To use the proxy, you must configure it in a Web Application and deploy that Web Application on the WebLogic Server that is redirecting requests.

If you want to proxy requests to a cluster of WebLogic Servers, you can use the HttpClusterServlet. For more information, see Proxying Requests to a WebLogic Cluster.

 


New Version of the HttpProxyServlet

Service Pack 2 for WebLogic Server 6.1, contains a new version of the HttpProxyServlet. The older version of HttpProxyServlet is still available and functions as described in this document. Differences between the older version and the new version are noted where appropriate in this document. The older version is deprecated and will be removed from a future release.

The new version has the following features:

 


Setting Up a Proxy to a Secondary HTTP Server

To set up a proxy to a secondary HTTP server:

  1. Register the proxy servlet in your Web Application deployment descriptor. The Web Application must be the default Web Application of the Server that is responding to requests.

    If you are using the new version of HttpProxyServlet, see Sample web.xml for use with NEW version of HttpProxyServlet).

    If you are using the older, deprecated version of HttpProxyServlet, see Sample web.xml for use with DEPRECATED version of HttpProxyServlet).

    The class name for the new version of HttpProxyServlet is weblogic.servlet.proxy.HttpProxyServlet.

    The class name for the older, deprecated version of HttpProxyServlet is weblogic.t3.srvr.HttpProxyServlet.)

    For more information on deployment descriptors and Web Applications, see Assembling and Configuring Web Applications.

  2. Define the appropriate initialization parameters for the HttpProxyServlet. You define initialization parameters with the <init-param> element in the web.xml Web Application deployment descriptor.

    If you are using the new version of HttpProxyServlet, define the WebLogicHost and WebLogicPort parameters (these two parameters are required) using <init-param> elements in the web.xml Web Application deployment descriptor. Set WebLogicHost to the host name of the secondary HTTP server and set WebLogicPort to the port number on the secondary HTTP server that is listening for HTTP requests. You can also, where appropriate, define additional parameters as described in Parameters for Web Server Plug-ins. For a sample deployment descriptor, see Sample web.xml for use with NEW version of HttpProxyServlet.

    If you are using the older, deprecated version of HttpProxyServlet, define the redirectURL parameter using the <init-param> element in the web.xml Web Application deployment descriptor. Set the value of this parameter to the URL of the secondary HTTP, including the port number. For example, http://myHttpServer:7001. For a sample deployment descriptor, see Sample web.xml for use with DEPRECATED version of HttpProxyServlet.

  3. Map the ProxyServlet to a <url-pattern>. Specifically, map the file extensions you wish to proxy, for example *.jsp, or *.html. Use the <servlet-mapping> element in the web.xml Web Application deployment descriptor.

    If you set the <url-pattern> to "/", then any request that cannot be resolved by WebLogic Server is proxied to the remote server. However, you must also specifically map the following extensions: *.jsp, *.html, and *.html if you want to proxy files ending with those extensions.

  4. Deploy the Web Application on the WebLogic Server that redirects incoming requests.

 


Sample Deployment Descriptor for the Proxy Servlet

The following are samples of Web Application deployment descriptors for use with the HttpProxyServlet.

Listing 9-1 Sample web.xml for use with NEW version of HttpProxyServlet

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.
 //DTD Web Application 2.2//EN"
 "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> 

<web-app>
<servlet>
    <servlet-name>ProxyServlet</servlet-name> 
    <servlet-class>weblogic.servlet.proxy.HttpProxyServlet</servlet
-class> 
<init-param> 
    <param-name>WebLogicHost</param-name> 
    <param-value>serverName</param-value> 
</init-param> 
<init-param> 
    <param-name>WebLogicPort</param-name> 
    <param-value>serverPort</param-value> 
</init-param> </servlet>
<servlet-mapping>
    <servlet-name>ProxyServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>ProxyServlet</servlet-name> 
    <url-pattern>*.jsp</url-pattern> 
</servlet-mapping>
<servlet-mapping>
    <servlet-name>ProxyServlet</servlet-name> 
    <url-pattern>*.htm</url-pattern> 
</servlet-mapping>
<servlet-mapping>
    <servlet-name>ProxyServlet</servlet-name> 
    <url-pattern>*.html</url-pattern> 
</servlet-mapping>
</web-app>

Note: You can define additional parameters by creating additional <init-param> blocks within the <servlet> block. For example,

<init-param>
<param-name>
ParameterName</param-name>
<param-value>
ParameterValue</param-value>
</init-param>

Where ParameterName is a parameter described in Parameters for Web Server Plug-ins and ParameterValue is the value you set for the parameter

Listing 9-2 Sample web.xml for use with DEPRECATED version of HttpProxyServlet

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.
 //DTD Web Application 2.2//EN"
 "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> 

<web-app>
<servlet>
  <servlet-name>ProxyServlet</servlet-name> 
  <servlet-class>weblogic.t3.srvr.HttpProxyServlet</servlet-class>
  <init-param>
        <param-name>redirectURL</param-name>
        <param-value>http://myServer:7001</param-value> 
  </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>ProxyServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>ProxyServlet</servlet-name> 
    <url-pattern>*.jsp</url-pattern> 
</servlet-mapping>
<servlet-mapping>
    <servlet-name>ProxyServlet</servlet-name> 
    <url-pattern>*.htm</url-pattern> 
</servlet-mapping>
<servlet-mapping>
    <servlet-name>ProxyServlet</servlet-name> 
    <url-pattern>*.html</url-pattern> 
</servlet-mapping>
</web-app>

 

back to top previous page next page