How to configure virtual hosts in WebSphere

Home > Search > How-to
  by

Before application servers had virtual hosts, you would have had to had a physical server for each app that you wanted to produce.

 

Virtual hosts allow you to run multiple apps from a single physical server.

 

A WebSphere application server contains 3 default virtual hosts.

  • admin_host
  • default_host
  • proxy_host

 

When deploying an app to WebSphere, there will be a prompt to select the virtual host. Typically, default_host is selected. You can also verify the virtual host being used by an application by navigating to Applications > All applications > select your app > Virtual hosts, and the virtual host being used by the app will be displayed.

 

To view and change the configuration of a virtual host:

  1. In the left panel of the WebSphere admin console, expand Enviroment.
  2. Select Virtual hosts.
  3. Select a virtual host. Applications typically use default_host.

 

At this page, the name of the virtual host can be changed.

 

Selecting Host Aliases will list the hostname and ports that are listening. In the example below, we can see some of the ports that default_host is listening on.

Notice in this example that ports 9080 and 9081 are listed. Typically, this suggests that 9080 is being used by one JVM, and port 9081 is being used by another JVM. The JVMs can be running on the same machine (vertical cluster) or on different machines (horizontal cluster).

 

The ports can then be correlated to a certain type of listener.

  1. In the left panel of the WebSphere web console, expand Servers > Server Types.
  2. Select WebSphere application servers.
  3. Select the application server.
  4. Expand Ports.

 

In this example, WC_defaulthost of JVM "a" has port 9080. The WC_defaulthost of JVM "b" would have port 9081.

 

Applications running on the JVM using default_host will be able to be called using the WC_defaulthost port, which is 9080 or 9081 in this example. In a horizontal cluster, the JVMs will likely have different hostnames, so you would pull up the app with something like www.hostname1:9080/context/root and www.hostname2:9081/context/root.

 


Change the port

Changing the virtual host to listen on a different port would allow you to produce the application on a different port.

  1. In the left panel of the WebSphere web console, expand Servers > Server Types.
  2. Select WebSphere application servers.
  3. Select the application server.
  4. Select Ports.
  5. Select WC_defaulthost.
  6. Enter the new port value and select OK.
  7. Select Save.

 

In this example, the WC_defaulthost value is updated to be 12345.

 

You would be able to produce the app on port 12345 after the JVM is restarted.

 

This type of change is not limited to just the WC_defaulthost. This change can be done on other ports being used for other listeners.



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments