0

I have two applications running in two different IBM Liberty Servers. Need to create named based virtual host. How can it be achieved.

one in the following location : /opt/wlp/usr/servers/liberty1/apps/expanded/abc.war

Second in the following location: /opt/wlp/usr/servers/liberty1/apps/expanded/def.war

IN the frontend I am running IBM HTTP server. How can i configure multi site. If the client access www.common.com then request should be processed from liberty1 using application abc.war, and if the client requests www.newcommon.com then request should be processed from liberty2 using application def.war.

IBM Http server is running in 80 port.

P Darius
  • 3
  • 5

1 Answers1

1

Here's an outline of what's needed:

1) Create an explicit virtual host in each liberty server

L1:

<virtualHost id="common">
    <hostAlias>www.common.com:80</hostAlias>
    <hostAlias>www.common.com:443</hostAlias>
</virtualHost>

L2:

<virtualHost id="newcommon">
    <hostAlias>www.newcommon.com:80</hostAlias>
    <hostAlias>www.newcommon.com:443</hostAlias>
</virtualHost>

Details: https://www.ibm.com/support/knowledgecenter/SS7K4U_liberty/com.ibm.websphere.wlp.zseries.doc/ae/cwlp_virtual_hosts_ovr.html

2) In the respective apps, bind the app to the newly defined virtual host

There are two ways to do this, server.xml or ibm-web-bnd.xml

server.xml:

<webApplication contextRoot="/app1" id="app1"
        location="app1.war" name="app1">
        <web-bnd>
            <virtual-host name="common"></virtual-host>
        </web-bnd>
    </webApplication>

ibm-web-bnd.xml:

 <virtual-host name="common"/>

3) Each Liberty server will generate a plugin-cfg.xml in the logs/state/ directory

4) Use the bin/pluginUtility in either Liberty to merge the two XML files together

5) The resulting merged file should list multiple virtual hosts and multiple ServerClusters, with multiple <Route ...> stanzas that map a virtual host and URL context root to a ServerCluster.

covener
  • 17,402
  • 2
  • 31
  • 45
  • Is `NameVirtualHost` in `httpd.conf` not needed here? Or is that only if you want some apache rules based on the host too? – dbreaux Apr 06 '18 at 15:02
  • @covener. Tks. Do we have to configure the IBM HTTP Server Httpd.conf file for virtual host after the server.xml configuration or is that the configuration in server.xml will suffice the routing of the request. I just read this following configuration http://www-01.ibm.com/support/docview.wss?uid=swg21592917 Please clarify. – @ – P Darius Apr 06 '18 at 16:30
  • 1
    You don't really need any config in IHS. The DNS for those hostnames just needs to point to an address that leads to IHS. IHS does not actually discriminate between the two hostnames -- just the WAS Plugin does. ofc if you wanted some IHS bhavior to differ, you'd follow the name-based vhost basics to do that – covener Apr 06 '18 at 18:47
  • @covener Hi the application wouldn't when the config is done but if I remove the same the application starts perfectly. what may be cause. – P Darius Apr 07 '18 at 07:24
  • @covener Moreover the web application is an maven project. – P Darius Apr 07 '18 at 09:27
  • shrug, maybe you've used incorrect values? I don't think the maven part is pertinent. – covener Apr 07 '18 at 11:50
  • @covener. There was some config error in server.xml. Tks for your valuable input. – P Darius Apr 17 '18 at 02:08