I think there is a worker directive for this to handle and is fail_on_status and you could use this for 404 error and there may be no need of including 503 error code with this directive which probably means tomcat is stopped and it’s the work of mod_jk to failover to other working node.
if fail_on_status is used, mod_jk segfaults when a reply with this status is received. Problem is a wrong order of arguments to the jk_log() function in file native/commons/jk_ajp_common.c on line 1851.
I Also tried fail_ on _status and so it puts the nodes to error stage which ever render 404 http status and redirect to other node BUT on my testing I found that it completely puts those nodes to error state and no request is sent to those nodes until restart though they are back working. Workers.properties on.
fail_on_status value Set this property to the value of an HTTP status code that will cause a worker to fail if returned from a Servlet container. This tells mod_jk to declare a back end dead when a specific HTTP status code is returned.
Since jk 1.2.20 you can set the property fail_ on _status for workers. See http://tomcat.apache.org/connectors-doc/reference/workers.html for details.
17.6.8. Configure fail_ on _status Parameter for mod_cluster 17.7. Apache mod_jk. 17.7.1. About the Apache mod_jk HTTP Connector 17.7.2. Configure JBoss EAP 6 to Communicate with Apache mod_jk 17.7.3. Install the mod_jk Module Into the Apache HTTP Server (ZIP) 17.7.4. Install the mod_jk Module Into the Apache HTTP Server (RPM) 17.7.5.
This uriworkermap entry results in httpd’s 503 ErrorDocument: /appname*=worker1use_server_errors=400fail_ on _status=-404 I had to compile mod_jk from source and so I took a peek at the source and added some debug logging in jk_ajp_common.c/ajp_process_callback() and jk_uri_worker_map.c/uri_worker_map_add() to dig a.
You need to build mod_jk.so with or without EAPI to match your Apache configuration. If you install a mismatched mod_jk.so, $APACHE_HOME/bin/apachectl configtest will warn you. Make sure you have Perl 5 installed. The apxs script used to build the module is written in Perl. Change directory to TOMCAT_HOME/native/mod_jk/apache1.3 (or apache2.0).
[error] service::jk_lb_worker.c (1473): All tomcat instances failed, no more workers left Jkstatus lines are for the particular worker are: Name Type Hostname Address:Port Connection Pool Timeout Connect Timeout Prepost Timeout Reply Timeout Retries Recovery Options Max Packet Size srv2 ajp13 x.x.x.x x.x.x.x:8009 30 30000 20000 20000 2 4 8192 Name Act State D F M V Acc Err CE RE Wr Rd Busy.
In addition, after some hours of running tomcat, many of running application on the server crashes with an error related to fork new processes & leak of system resources (I’m running on a VPS but I’m sure that I have enough resources & even more than I need to run such application & so I’m sure the problem is just because of bad configurations of apache, tomcat & mod_jk).