Quick update

In order to see the 503 Status code specified in the  default-response-code attribute on the host-element
I had to remove the welcome-content filter by omitting the 
   <location name="/" handler="welcome-content"/>
element.

However even with that config I see the following sequence from a repeated curl sequence:
watch -n 2 curl -I http://localhost:8080/auth/

Server not started                                   : Connection Refused...
Server Started...                                     : HTTP/1.1 404 Not Found
Begin Web App Deployment (Keycloak): HTTP/1.1 503 Service Unvailable
Web App Deployed                                : HTTP/1.1 200 OK
 
My example configuration
<subsystem xmlns="urn:jboss:domain:undertow:3.0">
    <buffer-cache name="default"/>
    <server name="default-server">
        <ajp-listener name="ajp" socket-binding="ajp"/>
        <http-listener name="default" socket-binding="http" redirect-socket="https"/>

        <host name="default-host" alias="localhost" default-response-code="503">
        </host>
    </server>
    <servlet-container name="default">
        <jsp-config/>
        <websockets/>
    </servlet-container>
    <handlers>
    </handlers>
    <filters>
    </filters>
</subsystem>

Cheers,
Thomas


2017-01-30 22:44 GMT+01:00 Thomas Darimont <thomas.darimont@googlemail.com>:
Hi Stuart,

thanks for the reply - I got a similar tip on the keycloak-user list however if I configure the default-response-code=503
on the (single) host element of the undertow subsystem in Wildfly (10.1.0) and restart the server then I get a 
404 but never a 503 when I access paths of an web app (keycloak) that is not fully initialized yet.

Seems that I'm seeing the same behaviour as those folks:
https://developer.jboss.org/thread/257526

Is there anything else that one needs to configure to make this work?

In the meantime I played a bit with alternative approaches e.g.: https://github.com/thomasdarimont/undertow-extensions

Cheers,
Thomas

2017-01-30 22:09 GMT+01:00 Stuart Douglas <sdouglas@redhat.com>:
You can add the default-response-code attribute in the host element of
the undertow subsystem to make it return 503 by default.

Stuart

On Mon, Jan 30, 2017 at 9:34 PM, Thomas Darimont
<thomas.darimont@googlemail.com> wrote:
> Hello group,
>
> (coss-post from keycloak-user Mailing List)
>
> the undertow servlet-container is started pretty early during the startup of
> the
> wildfly application server. However the initialization of the keycloak
> server
> application might take a while to complete. Within this period requests that
> are
> sent to the keycloak endpoints result in responses with HTTP Status Code
> 404.
>
> Is it possible to configure undertow to return a HTTP Status Code 503
> (Service Unvailable)
> until the keycloak application startup has completed?
>
> This would ease configuring load-balancers and to avoid showing a file not
> found
> to users during server restarts.
>
> Cheers,
> Thomas
>
> _______________________________________________
> undertow-dev mailing list
> undertow-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev