2

We're using WildFly 10 as our application server and deploy via Docker (deployment in WF is ordinary hotdeployment). We're not using WildFly's clustering mechanisms but simply have load-balancers (HAProxys) in front.

The problem is that WF opens its HTTP port while the EAR deployment is still in progress. This (of course?) leads to HTTP 404 errors which we don't want to handle specifically in the LBs. This could lead to false negatives...

Is there a way to allow HTTP connections only after the EAR has started successfully?

Alternatively is it possible to replace the "404 because nothing is deployed here"-error with a "503 service unavailable"? This would much better express the problem and would be easy to handle externally...

Martin Rauscher
  • 1,700
  • 1
  • 14
  • 20
  • We have similar setup and also tried to deal with this situation. haproxy is configured to make health checks on our simple service in EAR that returns Http 200 only when deployment is completed (check is done via jmx.. ). I'm looking for simpler solution too. – Piotr Kucia Feb 21 '16 at 19:57
  • Yeah, I didn't want introduce **another** health check. ctomc's solution sounds good. – Martin Rauscher Feb 22 '16 at 20:51

1 Answers1

4

You can set default-response-code for host you are running this on.

something along the lines:

<host name="default-host" alias="localhost" default-response-code="503">

or in cli:

/subsystem=undertow/server=default-server/host=default-host:write-attribute(name=default-response-code, value=503)

and similarly for any other host you might have.

Tomaz Cerar
  • 5,761
  • 25
  • 32
  • Very nice. Do I have to list each host or can I do e.g. "*"? – Martin Rauscher Feb 22 '16 at 20:54
  • Worked very well! I simply left "localhost" and it did work fine. One question though: How did you know about this config? Where is a good place to look? I find the Wildfly docs severely lacking... – Martin Rauscher Feb 24 '16 at 09:41
  • Well, I was involved in adding the feature :) for model docs I would recommend using Wildscribe https://wildscribe.github.io/Wildfly/10.0.0.Final/subsystem/undertow/server/host/index.html which shows all model details/configuration options – Tomaz Cerar Feb 24 '16 at 13:38
  • If you configure it via XML (which I would discourage) you can always look at xsd schema you can find in docs/schema of the distribution. For undertow subsystem itself you can also find them in sources at: https://github.com/wildfly/wildfly/tree/10.0.0.Final/undertow/src/main/resources/schema – Tomaz Cerar Feb 29 '16 at 09:33
  • Does anyone know how to customise the 503 page content for the human user ? HTTP 503 is good for load balancers but **503 - Service Unavailable** is not ideal for human viewers. – Shaun O'Hagan Aug 15 '17 at 13:48
  • EDIT - found a solution. If you follow guidance here [link](https://developer.jboss.org/thread/251980) but substitute 404 for 503 it works. – Shaun O'Hagan Aug 15 '17 at 14:05
  • This Answer alone did not work for me on wildfly 16. I had to remove the enclosed location tag to make it work. https://lists.jboss.org/pipermail/undertow-dev/2017-January/001861.html – mojoo-de Jun 09 '21 at 08:31