Sun Java System Application Server Enterprise Edition 8.1 2005Q2 High Availability Administration Guide

- Previous: Setting Up HTTP Load Balancing
- Next: Configuring the Load Balancer

# Configuring Web Servers for Load Balancing

The load balancer plug-in installation program makes a few modifications to the web server’s configuration files. The changes made depend upon the web server.

Note –

The load balancer plug-in can be installed either along with Sun Java System Application Server Enterprise Edition, or separately, on a machine running the supported web server. For complete details on the installation procedure, see Chapter 1, Installing Application Server Software, in Sun Java System Application Server Enterprise Edition 8.1 2005Q2 Installation Guide (if using the standalone Application Server) or Sun Java Enterprise System 2005Q5 Installation Guide (if using Java Enterprise System).

- Modifications to Sun Java System Web Server

- Using Apache Web Server

- Installation

- Configuring Multiple Web Server Instances

## Modifications to Sun Java System Web Server

The installation program adds the following entries to the Sun Java System Web Server’s configuration files:

To the web server instance’s `magnus.conf` file, it adds:

    ##EE lb-pluginInit
    fn="load-modules"
    shlib="web_server_install_dir/plugins/lbplugin/bin/libpassthrough.so"
    funcs="init-passthrough,service-passthrough,name-trans-passthrough" Thread="no"
    Init fn="init-passthrough"
    ##end addition for EE lb-plugin

To the web server instance’s `obj.conf` file, it adds:

    <Object name=default>
    NameTrans fn="name-trans-passthrough" name="lbplugin"
    config-file="web_server_install_dir/web_server_instance/config/loadbalancer.xml"
    <Object name="lbplugin">
      ObjectType fn="force-type" type="magnus-internal/lbplugin"
      PathCheck fn="deny-existence" path="*/WEB-INF/*"
      Service type="magnus-internal/lbplugin"
      fn="service-passthrough"
      Error reason="Bad Gateway"
      fn="send-error"
      uri="$docroot/badgateway.html"
    </object>

In the above code, `lbplugin` is a name that uniquely identifies the `Object`, and web_server_install_dir`/` web_server_instance`/config/loadbalancer.xml` is the location of the XML configuration file for the virtual server on which the load balancer is configured to run.

After installing, configure the load balancer as described in Setting Up HTTP Load Balancing

## Using Apache Web Server

To use Apache Web Server, you must perform certain configuration steps before installing the load balancer plug-in. The load balancer plug-in installation also makes additional modifications to the Apache Web Server. After the plug-in is installed, you must perform additional configuration steps.

Note –

On Apache 1.3, when more than one Apache child processes runs, each process has its own load balancing round robin sequence. For example, if there are two Apache child processes running, and the load balancer plug-in load balances on to two application server instances, the first request is sent to instance #1 and the second request is also sent to instance #1. The third request is sent to instance #2 and the fourth request is sent to instance #2 again. This pattern is repeated (instance1, instance1, instance2, instance2, etc.)This behavior is different from what you might expect, that is, instance1, instance2, instance1, instance2, etc. In Sun Java System Application Server, the load balancer plug-in for Apache instantiates a load balancer instance for each Apache process, creating an independent load balancing sequence.

Apache 2.0 has multithreaded behavior if compiled with the `--with-mpm=worke`r option.

- Requirements for Using Apache Web Server

- Configuration before Installing the Load Balancer Plug-in

- Modifications Made by the Application Server Installer

- To configure Apache Security Files to work with the Load Balancer

### Requirements for Using Apache Web Server

For the Apache Web Server, your installation must meet the minimum requirements, depending on the version of Apache.

#### Requirements for Apache 1.3

With Apache 1.3, the load balancer plug-in requires:

- `openssl-0.9.7e` (source)

- `mod_ssl-2.8.16-1.3.`x (source), where x represents the version of Apache. The mod_ssl version must match the Apache version.

- `gcc-3.3-sol9-sparc-local` packages (for Solaris SPARC)

- `gcc-3.3-sol9-intel-local` packages (for Solaris x86)

- `flex-2.5.4a-sol9-sparc-local` packages (for Solaris SPARC)

- `flex-2.5.4a-sol9-intel-local` packages (for Solaris x86)

  The software sources are available at `http://www.sunfreeware.com`

  In addition, before compiling Apache:

- On the Linux platform, install Sun Java System Application Server on the same machine.

- On the Solaris operating system, ensure that `gcc` version 3.3 and `make` are in the `PATH`, and `flex` is installed.

- On the Solaris 10 operating system, before running `make` for OpenSSL, run `mkheaders`, located in `/usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3/install-tools` on Solaris SPARC or `/usr/local/lib/gcc-lib/i386-pc-solaris2.9/3.3/install-tools` on Solaris x86.

- If you are using `gcc` on Red Hat Enterprise Linux Advanced Server 2.1, the version must be later than `gcc` 3.0.

Note –

To use C compiler other than `gcc`, set the path of the C compiler and make utility in the PATH environment variable. For example, with the `sh` shell: `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:appserver_installdir/lib`

#### Minimum Requirements for Apache 2

With Apache 2.0, the load balancer plug-in requires:

- `openssl-0.9.7e (source)`

- `httpd-2.0.49 (source)`

- `gcc-3.3-sol9-sparc-local` packages (for Solaris SPARC).

- `gcc-3.3-sol9-intel-local` packages (for Solaris x86)

- `flex-2.5.4a-sol9-sparc-local` packages (for Solaris SPARC)

- `flex-2.5.4a-sol9-intel-local` packages (for Solaris x86)

The software sources are available at `http://www.sunfreeware.com`

In addition, before compiling Apache:

- On the Linux platform, install Sun Java System Application Server on the same machine.

- On the Solaris operating system, ensure that `gcc` version 3.3 and `make` are in the `PATH`, and `flex` is installed.

- On the Solaris 10 operating system, before running `make` for OpenSSL, run `mkheaders`, located in `/usr/local/lib/gcc-lib/sparc-sun-solaris2.9/3.3/install-tools` on Solaris SPARC or `/usr/local/lib/gcc-lib/i386-pc-solaris2.9/3.3/install-tools` on Solaris x86.

- If you are using `gcc` on Red Hat Enterprise Linux Advanced Server 2.1, the version must be later than `gcc` 3.0.

Note –

To use a C compiler other than `gcc`, set the path of the C compiler and make utility in the PATH environment variable. For example, with the `sh` shell:`export LD_LIBRARY_PATH=` app_server_install_dir`/lib:$LD_LIBRARY_PATH`.

### Configuration before Installing the Load Balancer Plug-in

Before installing the load balancer plug-in for Apache, install the Apache Web Server. The Apache source must be compiled and built to run with SSL. This section describes the minimum requirements and high-level steps needed to successfully compile Apache Web Server to run the load balancer plug-in. These requirements and steps only apply to the Solaris and Linux versions of the software. For information on the Windows version of Apache, see the Apache web site.

#### To Install SSL-aware Apache

##### Before You Begin

You must have already downloaded and uncompressed the Apache software.

1. Download and unpack the OpenSSL source.

2. Compile and build OpenSSL.

   This step is not required on the Linux platform if OpenSSL 0.9.7.e is installed.

   Enter these commands:

       cd openssl-0.9.7e
       make
       make install

   For more information about OpenSSL, see the `http://www.openssl.org/`.

3. Follow one of these procedures, depending on the version of Apache:

   - For Apache 1.3, configure Apache with `mod_ssl` with the following steps:

     1. Unpack the `mod_ssl` source.

     2. `cd mod_ssl-2.8.14–1.3.x`

     3. `./configure –with-apache=../apache_1.3.x --with-ssl=../openssl-0.9.7e --prefix=install_path --enable-module=ssl --enable-shared=ssl --enable-rule=SHARED_CORE --enable-module=so`

     In the above commands, x is the Apache version number, and install_path is the directory in which to install Apache.

     For more information on `mod_ssl`, see `http://www.modssl.org`.

   - For Apache 2.0, configure the source tree:

     1. `cd http-2.0_` x.

     2. Run `./configure --with-ssl=` open_ssl_install_path `--prefix=` install_path `--enable-ssl --enable-so`

        In the above commands, x is the Apache version number, open_ssl_install_path is the directory where OpenSSL is installed, and install_path is the directory in which to install Apache.

4. For Apache on Linux 2.1, before compiling:

   1. Open `src/MakeFile` and find the end of the automatically generated section.

   2. Add the following lines after the first four lines after the automatically generated section:

          LIBS+= -licuuc -licui18n -lnspr4 -lpthread -lxerces-c
          -lsupport -lnsprwrap -lns-httpd40
          LDFLAGS+= -L/appserver_installdir/lib -L/opt/sun/private/lib

      Note that `-L/opt/sun/private/lib` is only required if you installed Application Server as part of a Java Enterprise System installation.

      For example:

          ## (End of automatically generated section)
          ##
          CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
          LIBS=$(EXTRA_LIBS) $(LIBS1)
          INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
          LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
          "LIBS+= -licuuc -licui18n -lnspr4 -lpthread
          -lxerces-c -lsupport -lnsprwrap -lns-httpd40
          LDFLAGS+= -L/appserver_installdir /lib -L/opt/sun/private/lib

   3. Set environment variable LD_LIBRARY_PATH.

      With all installations, set it to: `appserver_install_dir/lib`

      With Java Enterprise System Installations, set it to `appserver_install_dir/lib:opt/sun/private/lib` .

5. Compile Apache as described in the installation instructions for the version you are using.

   For more information, see the `http://httpd.apache.org/`

   In general the steps are:

   1. `make`

   2. `make certificate` (Apache 1.3 only)

   3. `make install`

      The command `make certificate` asks for a secure password. Remember this password as it is required for starting secure Apache.

6. Configure Apache for your environment.

### Modifications Made by the Application Server Installer

The load balancer plug-in installation program extracts the necessary files to a directory in the web server’s root directory:

- For Apache 1.3, the directory is `libexec`.

- For Apache 2.0, the directory is `modules` .

It adds the following entries to the web server instance’s `httpd.conf` file:

    <VirtualHost machine_name:443>
    ##Addition for EE lb-plugin
    LoadFile /usr/lib/libCstd.so.1
    LoadModule apachelbplugin_module libexec/mod_loadbalancer.so
    #AddModule mod_apachelbplugin.cpp
    <IfModule mod_apachelbplugin.cpp>
      config-file webserver_instance/conf/loadbalancer.xml
      locale en
    </IfModule>
    <VirtualHost machine_ip_address>
      DocumentRoot "webserver_instance/htdocs"
      ServerName server_name
    </VirtualHost>
    ##END EE LB Plugin ParametersVersion 7

### To configure Apache Security Files to work with the Load Balancer

Apache Web Server must have the correct security files to work well with the load balancer plug-in.

1. Create a directory called `sec_db_files` under apache_install_dir.

2. Copy application_server_domain_dir `/config/`*.db to apache_install_dir `/sec_db_files`.

3. Depending on the platform, perform additional configuration.

   - On the Solaris platform:

     Add the path `/usr/lib/mps/secv1` to LD_LIBRARY_PATH in the apache_install_dir`/bin/apachectl` script. The path must be added before `/usr/lib/mps`.

   - On Linux:

     Add the path `/opt/sun/private/lib` to LD_LIBRARY_PATH in the apache_install_dir`/bin/apachectl` script. The path must be added before `/usr/lib`.

   - On Microsoft Windows:

     1. Add a new path to the Path environment variable.

        Click Start->Settings->Control Panel->System->Advanced->Environment Variables->System Variables.

        Add application_server_install_dir `/bin` to the Path environment variable.

     2. Set the environment variable NSPR_NATIVE_THREADS_ONLY to 1.

        In the Environment Variables window, under System Variables, click New. Enter Variable name of NSPR_NATIVE_THREADS_ONLY and Variable value of 1.

     3. Restart the machine.

## Modifications to Microsoft IIS

To configure Microsoft Internet Information Services (IIS) to use the load balancer plug-in, modify certain properties in Windows Internet Services Manager. The Internet Services Manager is located in the Administrative Tools folder in the Control Panel folder.

Make these modifications after installing the Sun Java System Application Server.

### To Configure Microsoft IIS to use the Load Balancer Plug-in

1. Open the Internet Services Manager.

2. Select the web site for which you want to enable the plug-in.

   This web site is typically named the Default Web Site.

3. Right click on the web site and select Properties to open the Properties notebook.

4. Add a new ISAPI filter, following these steps:

   1. Open the ISAPI Filters tab.

   2. Click Add.

   3. In the Filter Name field, enter `Application Server`

   4. In the Executable field, type `C:\Inetpub\wwwroot\sun-passthrough\sun-passthrough.dll`

   5. Click OK, and close the Properties notebook.

5. Create and configure a new virtual directory:

   1. Right click on the default web site, select New, and then Virtual Directory.

      The Virtual Directory Creation Wizard opens.

   2. In the Alias field, type `sun-passthrough` .

   3. In the Directory field, type `C:\Inetpub\wwwroot\sun-passthrough`.

   4. Check the Execute Permission checkbox.

      Leave all other permission-related check boxes are left unchecked.

   5. Click Finish.

6. Add the path of `sun-passthrough.dll` file and application_server_install_dir `/bin` to the system’s `PATH` environment variable.

7. Restart the machine.

8. Stop and start the web server for the new settings to take effect.

   To stop the web server, right click on the web site and select `Stop` . To start the web server, right click on the web site and select `Start`.

9. Verify that the web server, load balancer plug-in, and Application Server are operating correctly.

   Type the following in a web browser to access the web application context root: `http://webserver_name/web_application`, where webserver_name is the host name or IP address of the web server and web_application is the context root that you listed in the `C:\Inetpub\wwwroot\sun-passthrough\sun-passthrough.properties` file.

### Automatically configured Sun-passthrough properties

The installer automatically configures the following properties in `sun-passthrough.properties`. You can change the default values.

Property | Definition | Default Value
--- | --- | ---
lb-config-file | Path to the load balancer configuration file | `IIS_www_root\sun-passthrough\loadbalancer.xml`
log-file | Path to the load balancer log file | `IIS_www_root\sun-passthrough\lb.log`
log-level | Log level for the web server | INFO

## Configuring Multiple Web Server Instances

The Sun Java System Application Server installer does not allow the installation of multiple load balancer plug-ins on a single machine. To have multiple web servers with the load balancer plug-in on a single machine, in either a single cluster or multiple clusters, a few manual steps are required to configure the load balancer plug-in.

### To Configure Multiple Web Server Instances

1. Configure the new web server instance to use the load balancer plug-in.

   Follow the steps in Modifications to Sun Java System Web Server or Using Apache Web Server , or Installation

2. Copy the DTD file.

   Copy `sun-loadbalancer_1_1.dtd` from the existing web server instance’s `config` directory to the new instance’s `config` directory.

3. Set up the load balancer configuration file. Either:

   - Copy the existing load balancer configuration.

     Use an existing load balancer configuration, copy the `loadbalancer.xml` file from the existing web server instance’s `config` directory to the new instance’s `config` directory.

   - Create a new load balancer configuration:

     1. Use `asadmin create-http-lb-config` to create a new load balancer configuration.

     2. Export the new configuration to a `loadbalancer.xml` file using `asadmin export http-lb-config`.

     3. Copy that `loadbalancer.xml` file to the new web server’s `config` directory.

        For information on creating a load balancer configuration and exporting it to a `loadbalancer.xml` file, see Creating an HTTP Load Balancer Configuration

- Previous: Setting Up HTTP Load Balancing
- Next: Configuring the Load Balancer

- © 2010, Oracle Corporation and/or its affiliates