1

I have multiple instances of springboot application running in Websphere Libery, with following server.xml:

<?xml version="1.0" encoding="UTF-8"?>
<server description="my_app">

    <!-- Enable features -->
    <featureManager>
        <feature>springBoot-2.0</feature>
        <feature>servlet-4.0</feature>
        <feature>transportSecurity-1.0</feature>
    </featureManager>

    <springBootApplication location="my_app.war">
        <applicationArgument>--spring.config.location=file:../relative/path/to/config/</applicationArgument>
        <applicationArgument>--server.liberty.use-default-host=false</applicationArgument>
    </springBootApplication>
    <httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="-1" httpsPort="-1"/>
</server>

Each instance internally chooses the HTTPS port number (springboot application is configured to only accept SSL connections, but that's not the point). I know WLP creates a virtualHost for the spring boot application, based on the server port. In console log, I can see something like this:

[AUDIT   ] CWWKT0016I: Web application available (springBootVirtualHost-8443): https://wlp-host:8443/spring-app-ctx-root/

If I access directly that HTTPS url, it works as expected.

However, these multiple instances of the application are being accessed via a load-balancer (also via HTTPS), that injects HTTP header "Host: load-balancer-host-name" when redirecting the requests to a chosen instance (on a given port).

Assuming If I add the following to server XML of one of the instances while the application is running...

    <virtualHost id="springBootVirtualHost-8443">
        <hostAlias>load-balancer-host-name:443</hostAlias>
    </virtualHost> 

... WLP is able to recognise this configuration and correctly respond to HTTPS requests that come with HTTP header "Host: load-balancer-host-name"

However, when I reboot the WLP instance already with this "virtualHost" configuration, not only HTTP header "Host: load-balancer-host-name" is not recognised anymore, but also WLP seems to fail to bootstrap springBootVirtualHost-8443, meaning that direct requests to "https://wlp-host:8443/spring-app-ctx-root" also don't work anymore (and corresponding [AUDIT] log for springBootVirtualHost-8443 is not displayed).

It looks like, when WLP reads the virtualHost configuration for springBootVirtualHost-8443, it somehow does it before the springboot app is launched and overtakes its configuration. SpringBoot app then fails to create this "springBootVirtualHost-8443" virtualHost, because it's already taken.

Any ideas?

  • Could you please try setting the httpsPort and also pointing the hostAlias to the full port. Something like below `` ` *:9443 ` – Anjum Fatima Sep 15 '22 at 18:14
  • @Anjum Fatima, thanks for your reply. I tried it out, but the problem is the same: once I have `````` in server.xml, WLP fails to enable the springboot end point on port 8443 when it is rebooted – Tiago Moitinho de Almeida Sep 16 '22 at 09:50
  • It looks like the implementation doesn't factor in your scenario. Depending on the significance, I would recommend opening an issue on [open-liberty](https://github.com/OpenLiberty/open-liberty/issues). – Anjum Fatima Sep 20 '22 at 19:44
  • @Anjum Fatima, sorry for not replying before, as I was busy with other issues. I had another go on this topic, and apparently, your suggestion of configuring was pointing in the right direction, as I got it working. `` So, the key for the solution apparently was configuring `springBootHttpEndpoint-8443` end-point (instead of `defaultHttpEndpoint`). Also, the https port must match the suffix of the endpoint name. – Tiago Moitinho de Almeida Sep 26 '22 at 23:01

0 Answers0