mod_jk unable to connect with tomcat9 - apache2.4

After unzip the tomcat9 package available on tomcat.apache.org, and have the mod_jk configured to this:
workers.tomcat_home=/opt/apache-tomcat-9.0.34
workers.java_home=/opt/jdk-13
ps=/
worker.list=ajp13_worker
worker.ajp13_worker.port=8009
worker.ajp13_worker.host=localhost
worker.ajp13_worker.type=ajp13
When I deploy a WAR to the webapps directory, and try access it, the browser shows this error:
in the mod_jk log, I got this:
[Sat Apr 25 08:45:49.187 2020] [16060:139700132441152] [info] jk_open_socket::jk_connect.c (816): connect to 127.0.0.1:8009 failed (errno=111)
[Sat Apr 25 08:45:49.187 2020] [16060:139700132441152] [info] ajp_connect_to_endpoint::jk_ajp_common.c (1065): (ajp13_worker) Failed opening socket to (127.0.0.1:8009) (errno=111)
[Sat Apr 25 08:45:49.187 2020] [16060:139700132441152] [error] ajp_send_request::jk_ajp_common.c (1725): (ajp13_worker) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111)
[Sat Apr 25 08:45:49.187 2020] [16060:139700132441152] [info] ajp_service::jk_ajp_common.c (2775): (ajp13_worker) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
[Sat Apr 25 08:45:49.187 2020] [16060:139700132441152] [error] ajp_service::jk_ajp_common.c (2796): (ajp13_worker) connecting to tomcat failed (rc=-3, errors=2, client_errors=0).
[Sat Apr 25 08:45:49.187 2020] [16060:139700132441152] [info] jk_handler::mod_jk.c (2991): Service error=-3 for worker=ajp13_worker
my server.xml file has this section uncommented already:
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443" />
if I try access with somethid like http://mydomain:8080/app for a webapp named app, works fine. without the :8080, which should make the access go through the mod_jk, I got the error.
anyone can tell me what is wrong here?

Related

Apache/XAMPP does not give access to subdirectory

I set my document root to a git repository of three.js, and the root directory lists all subfolders, except examples/. It also doesn't list files and folders starting with . (understandable, I guess) and README.md. Trying to access examples directly gives a 503 error.
There are no .htaccess files anywhere. There is no IndexIgnore anywhere. Error.log lists this:
[Sat Jun 02 13:35:08.169886 2018] [proxy:error] [pid 20844:tid 1996] (OS 10061)No connection could be made because the target machine actively refused it. : AH00957: AJP: attempt to connect to 127.0.0.1:8009 (127.0.0.1) failed
[Sat Jun 02 13:35:08.169886 2018] [proxy:error] [pid 20844:tid 1996] AH00959: ap_proxy_connect_backend disabling worker for (127.0.0.1) for 5s
[Sat Jun 02 13:35:08.169886 2018] [proxy_ajp:error] [pid 20844:tid 1996] [client 127.0.0.1:57788] AH00896: failed to make connection to backend: 127.0.0.1
In your apache conf folder, see if you have a file named /extra/httpd-ajp.conf with a line like this:
ProxyPass /examples ajp://127.0.0.1:8009/examples smax=0 ttl=60 retry=5
If so, comment out or delete that line. Fixed the problem for me.

WebServers cannot connect to app server ELB - AWS

I have a simple deployment with some webservers connected to an AWS ELB. This ELB in-turn has some application servers behind it.
The webservers are unable to connect to the application server ELB. The httpd error log is full of:
[Thu Dec 22 15:28:05.897273 2016] [proxy:error] [pid 10188] (70007)The timeout specified has expired: AH00957: HTTP: attempt to connect to 54.254.179.37:80 (elblinkhere) failed
[Thu Dec 22 15:28:05.897348 2016] [proxy:error] [pid 10188] AH00959: ap_proxy_connect_backend disabling worker for (elblinkhere) for 60s
[Thu Dec 22 15:28:05.897361 2016] [proxy_http:error] [pid 10188] [client 10.0.0.54:13789] AH01114: HTTP: failed to make connection to backend: elblinkhere
I have tried to check if this is an SELinux issue but that does not seem so.
I have also read a large number of threads on the internet about this and not come across any solutions.
My question(s):
1. What other methods can I use to resolve this?
2. How do I resolve this?
Did you configure your ELB as external and also enabled necessary port for ELB's security group?

Apache not using desired ports on workers.properties

We've configured Apache to redirect to an instance of tomcat through a diferent port of the AJP default 8009 . It only works for the default port but it's not working with the one we set (8109) on the worker.properties This is our scenario
worker.properties on /etc/apache2
worker.list=sacmimexico
# Set properties for sacmimexico
worker.sacmimexico.type=ajp13
worker.sacmimexico.host=localhost
worker.sacmimexico.port=8109
server.xml on /usr/share/instance-tomcat-7.0.42/sacmimexico/conf/
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8109" protocol="AJP/1.3" redirectPort="8143" />
mod_jk.log on /var/log/apache2
[Wed Oct 14 05:29:18 2015] [17752:140024424515392] [info] init_jk::mod_jk.c (3189): mod_jk/1.2.30 initialized
[Wed Oct 14 05:29:18 2015] [17753:140024424515392] [info] init_jk::mod_jk.c (3189): mod_jk/1.2.30 initialized
[Wed Oct 14 05:29:22 2015] [17757:140024328361728] [info] jk_open_socket::jk_connect.c (622): connect to 127.0.0.1:8009 failed (errno=111)
[Wed Oct 14 05:29:22 2015] [17757:140024328361728] [info] ajp_connect_to_endpoint::jk_ajp_common.c (959): Failed opening socket to (127.0.0.1:8009) (errno=111)
[Wed Oct 14 05:29:22 2015] [17757:140024328361728] [error] ajp_send_request::jk_ajp_common.c (1585): (sacmimexico) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111)
[Wed Oct 14 05:29:22 2015] [17757:140024328361728] [info] ajp_service::jk_ajp_common.c (2540): (sacmimexico) sending request to tomcat failed (recoverable), because of error during request sending (attempt=1)
[Wed Oct 14 05:29:22 2015] [17757:140024328361728] [info] jk_open_socket::jk_connect.c (622): connect to 127.0.0.1:8009 failed (errno=111)
[Wed Oct 14 05:29:22 2015] [17757:140024328361728] [info] ajp_connect_to_endpoint::jk_ajp_common.c (959): Failed opening socket to (127.0.0.1:8009) (errno=111)
[Wed Oct 14 05:29:22 2015] [17757:140024328361728] [error] ajp_send_request::jk_ajp_common.c (1585): (sacmimexico) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111)
[Wed Oct 14 05:29:22 2015] [17757:140024328361728] [info] ajp_service::jk_ajp_common.c (2540): (sacmimexico) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
[Wed Oct 14 05:29:22 2015] [17757:140024328361728] [error] ajp_service::jk_ajp_common.c (2559): (sacmimexico) connecting to tomcat failed.
[Wed Oct 14 05:29:22 2015] sacmimexico 199.187.122.163 0.100588
[Wed Oct 14 05:29:22 2015] [17757:140024328361728] [info] jk_handler::mod_jk.c (2618): Service error=-3 for worker=sacmimexico
jk.conf on /etc/apache2/mods-available
<IfModule mod_jk.c>
JkWorkersFile "/etc/apache2/workers.properties"
JkLogFile "/var/log/apache2/mod_jk.log"
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
</IfModule>
default on /etc/apache2/sites-available
JkMount /sacmimexico/* sacmimexico
Versions:
Apache 2 :Apache/2.2.16 (Debian)
Tomcat 7 : Apache Tomcat/7.0.42
mod-jk : 1.2.30-1squeeze1
We know that Tomcat is working on that port 8109
Anyone knows what's happening?
Thanks
Albert
The problem were wrong carachters on workers.properties due to bad edit.
I check it with cat -A workers.properties and then create a new one from scratch.
I faced the exact same issue. The fix for this issue is to change the AJP port to a different range. The port 8109 was getting blocked by SELinux in my CentOS /Red Hat. So I changed the AJP port to 81 on woker.proberties as well as Tomcat server.xml. Thus the issue got fixed.

apache tomcat redirection error: worker1 connecting to backend failed

Getting the below logs when try to run servlet using apache tomcat integertaion. It says unable to connect to tomcat. Dont know why? Moreover, its trying to connect to 0.0.0.0:0 when I have
<Connector port="8009" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
Tried with
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
But no luch
[Sat May 19 13:29:39 2012] [5260:4324] [info] ajp_service::jk_ajp_common.c (2622): (worker1) sending request to tomcat failed (recoverable), because of error during request sending (attempt=1)
[Sat May 19 13:29:39 2012] [5260:4324] [debug] ajp_service::jk_ajp_common.c (2471): retry 1, sleeping for 100 ms before retrying
[Sat May 19 13:29:39 2012] [5260:4324] [debug] ajp_send_request::jk_ajp_common.c (1623): (worker1) all endpoints are disconnected.
[Sat May 19 13:29:39 2012] [5260:4324] [debug] jk_open_socket::jk_connect.c (485): socket TCP_NODELAY set to On
[Sat May 19 13:29:39 2012] [5260:4324] [debug] jk_open_socket::jk_connect.c (574): timeout 3000 set for socket=1548
[Sat May 19 13:29:39 2012] [5260:4324] [debug] jk_open_socket::jk_connect.c (609): trying to connect socket 1548 to 0.0.0.0:0
[Sat May 19 13:29:39 2012] [5260:4324] [info] jk_open_socket::jk_connect.c (627): connect to 0.0.0.0:0 failed (errno=47)
[Sat May 19 13:29:39 2012] [5260:4324] [info] ajp_connect_to_endpoint::jk_ajp_common.c (995): Failed opening socket to (0.0.0.0:0) (errno=47)
[Sat May 19 13:29:39 2012] [5260:4324] [error] ajp_send_request::jk_ajp_common.c (1629): (worker1) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=47)
[Sat May 19 13:29:39 2012] [5260:4324] [info] ajp_service::jk_ajp_common.c (2622): (worker1) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
[Sat May 19 13:29:39 2012] [5260:4324] [error] ajp_service::jk_ajp_common.c (2642): (worker1) connecting to tomcat failed.
[Sat May 19 13:29:39 2012] [5260:4324] [debug] ajp_reset_endpoint::jk_ajp_common.c (786): (worker1) resetting endpoint with socket -1 (socket shutdown)
[Sat May 19 13:29:39 2012] [5260:4324] [debug] ajp_done::jk_ajp_common.c (3085): recycling connection pool for worker worker1 and socket -1
[Sat May 19 13:29:39 2012] [5260:4324] [info] jk_handler::mod_jk.c (2788): Service error=-3 for worker=worker1
[Sat May 19 13:29:47 2012] [5260:4324] [debug] map_uri_to_worker_ext::jk_uri_worker_map.c (1131): Attempting to map URI '/automationutil/LoginApp' from 3 maps
[Sat May 19 13:29:47 2012] [5260:4324] [debug] find_match::jk_uri_worker_map.c (945): Attempting to map context URI '/automationutil/*=worker1' source 'JkMount'
[Sat May 19 13:29:47 2012] [5260:4324] [debug] find_match::jk_uri_worker_map.c (958): Found a wildchar match '/automationutil/*=worker1'
[Sat May 19 13:29:47 2012] [5260:4324] [debug] jk_handler::mod_jk.c (2621): Into handler jakarta-servlet worker=worker1 r->proxyreq=0
[Sat May 19 13:29:47 2012] [5260:4324] [debug] wc_get_worker_for_name::jk_worker.c (115): found a worker worker1
[Sat May 19 13:29:47 2012] [5260:4324] [debug] wc_get_name_for_type::jk_worker.c (292): Found worker type 'ajp13'
[Sat May 19 13:29:47 2012] [5260:4324] [debug] init_ws_service::mod_jk.c (1097): Service protocol=HTTP/1.1 method=POST ssl=false host=(null) addr=127.0.0.1 name=localhost port=82 auth=(null) user=(null) laddr=127.0.0.1 raddr=127.0.0.1 uri=/automationutil/LoginApp
[Sat May 19 13:29:47 2012] [5260:4324] [debug] ajp_get_endpoint::jk_ajp_common.c (3154): acquired connection pool slot=0 after 0 retries
[Sat May 19 13:29:47 2012] [5260:4324] [debug] ajp_marshal_into_msgb::jk_ajp_common.c (626): ajp marshaling done
[Sat May 19 13:29:47 2012] [5260:4324] [debug] ajp_service::jk_ajp_common.c (2449): processing worker1 with 2 retries
[Sat May 19 13:29:47 2012] [5260:4324] [debug] ajp_send_request::jk_ajp_common.c (1623): (worker1) all endpoints are disconnected.
[Sat May 19 13:29:47 2012] [5260:4324] [debug] jk_open_socket::jk_connect.c (485): socket TCP_NODELAY set to On
[Sat May 19 13:29:47 2012] [5260:4324] [debug] jk_open_socket::jk_connect.c (574): timeout 3000 set for socket=1548
[Sat May 19 13:29:47 2012] [5260:4324] [debug] jk_open_socket::jk_connect.c (609): trying to connect socket 1548 to 0.0.0.0:0
[Sat May 19 13:29:47 2012] [5260:4324] [info] jk_open_socket::jk_connect.c (627): connect to 0.0.0.0:0 failed (errno=47)
[Sat May 19 13:29:47 2012] [5260:4324] [info] ajp_connect_to_endpoint::jk_ajp_common.c (995): Failed opening socket to (0.0.0.0:0) (errno=47)
[Sat May 19 13:29:47 2012] [5260:4324] [error] ajp_send_request::jk_ajp_common.c (1629): (worker1) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=47)
[Sat May 19 13:29:47 2012] [5260:4324] [info] ajp_service::jk_ajp_common.c (2622): (worker1) sending request to tomcat failed (recoverable), because of error during request sending (attempt=1)
[Sat May 19 13:29:47 2012] [5260:4324] [debug] ajp_service::jk_ajp_common.c (2471): retry 1, sleeping for 100 ms before retrying
[Sat May 19 13:29:47 2012] [5260:4324] [debug] ajp_send_request::jk_ajp_common.c (1623): (worker1) all endpoints are disconnected.
[Sat May 19 13:29:47 2012] [5260:4324] [debug] jk_open_socket::jk_connect.c (485): socket TCP_NODELAY set to On
[Sat May 19 13:29:47 2012] [5260:4324] [debug] jk_open_socket::jk_connect.c (574): timeout 3000 set for socket=1548
[Sat May 19 13:29:47 2012] [5260:4324] [debug] jk_open_socket::jk_connect.c (609): trying to connect socket 1548 to 0.0.0.0:0
[Sat May 19 13:29:47 2012] [5260:4324] [info] jk_open_socket::jk_connect.c (627): connect to 0.0.0.0:0 failed (errno=47)
[Sat May 19 13:29:47 2012] [5260:4324] [info] ajp_connect_to_endpoint::jk_ajp_common.c (995): Failed opening socket to (0.0.0.0:0) (errno=47)
[Sat May 19 13:29:47 2012] [5260:4324] [error] ajp_send_request::jk_ajp_common.c (1629): (worker1) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=47)
[Sat May 19 13:29:47 2012] [5260:4324] [info] ajp_service::jk_ajp_common.c (2622): (worker1) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
[Sat May 19 13:29:47 2012] [5260:4324] [error] ajp_service::jk_ajp_common.c (2642): (worker1) connecting to tomcat failed.
[Sat May 19 13:29:47 2012] [5260:4324] [debug] ajp_reset_endpoint::jk_ajp_common.c (786): (worker1) resetting endpoint with socket -1 (socket shutdown)
[Sat May 19 13:29:47 2012] [5260:4324] [debug] ajp_done::jk_ajp_common.c (3085): recycling connection pool for worker worker1 and socket -1
[Sat May 19 13:29:47 2012] [5260:4324] [debug] jk_handler::mod_jk.c (2719): Consumed 22 bytes of remaining request data for worker=worker1
[Sat May 19 13:29:47 2012] [5260:4324] [info] jk_handler::mod_jk.c (2788): Service error=-3 for worker=worker1
Any help is highly appreciated. Banging my head for last 10 days.
mod_jk.conf (C:\Program Files\apache-tomcat-5.5.35\conf\auto)
########## Auto generated on Sat May 19 12:48:58 IST 2012##########
<IfModule !mod_jk.c>
LoadModule jk_module "modules/mod_jk.dll"
</IfModule>
<VirtualHost localhost>
ServerName localhost
JkMount /webdav ajp13
JkMount /webdav/* ajp13
JkMount /tomcat-docs ajp13
JkMount /tomcat-docs/* ajp13
JkMount /balancer ajp13
JkMount /balancer/* ajp13
JkMount /host-manager ajp13
JkMount /host-manager/* ajp13
JkMount /automationutil ajp13
JkMount /automationutil/* ajp13
JkMount /servlets-examples ajp13
JkMount /servlets-examples/* ajp13
JkMount /jsp-examples ajp13
JkMount /jsp-examples/* ajp13
JkMount /manager ajp13
JkMount /manager/* ajp13
</VirtualHost>
workers.properties
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
#worker.worker1.lbfactor=50
#worker.worker1.cachesize=10
#worker.worker1.cache_timeout=600
#worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=3000
uriworkermap.properties
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# uriworkermap.properties - IIS
#
# This file provides sample mappings for example wlb
# worker defined in workermap.properties.minimal
# The general syntax for this file is:
# [URL]=[Worker name]
#/admin/*=lb
#/manager/*=lb
#/jsp-examples/*=lb
/servlets-examples/*=worker1
#/examples/*=lb
/automationutil=worker1
/automationutil/*=worker1
#!/automationutil/*.html=worker1
# Optionally filter out all .jpeg files inside that context
# For no mapping the url has to start with exclamation (!)
#!/servlets-examples/*.jpeg=lb
#
# Mount jkstatus to /jkmanager
# For production servers you will need to
# secure the access to the /jkmanager url
#
#/jk-manager=jk-status
httpd.conf
#Include "C:/Program Files/Apache Software Foundation/Apache2.2/conf/vhosts.conf"
#LoadModule jk_module "C:/Program Files/Apache Software Foundation/Apache2.2/modules/mod_jk.so"
# Load mod_jk module
# Update this path to match your modules location
LoadModule jk_module "C:/Program Files/Apache Software Foundation/Apache2.2/modules/mod_jk.so"
# Declare the module for <IfModule directive> (remove this line on Apache 2.x)
#AddModule mod_jk.c
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile "C:/Program Files/Apache Software Foundation/Apache2.2/conf/workers.properties"
# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile "C:/Program Files/Apache Software Foundation/Apache2.2/logs/mod_jk.shm"
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile "C:/Program Files/Apache Software Foundation/Apache2.2/logs/mod_jk.log"
# Set the jk log level [debug/error/info]
#JkLogLevel info
JkLogLevel debug
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# Send everything for context /examples to worker named worker1 (ajp13)
#<VirtualHost localhost:80>
# Set DocumentRoot equal to Tomcat ROOT context
#DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
#DocumentRoot "C:/Program Files/apache-tomcat-5.5.35/webapps"
# Exclude PHP & CGI (let Apache handle)
SetEnvIf Request_URI \.php no-jk
#SetEnvIf Request_URI \.cgi no-jk
#JkMount /* worker1
JkMount /automationutil worker1
JkMount /automationutil/* worker1
JkUnMount /automationutil/*.html worker1
#JkMount /automationutil/* worker1
#</VirtualHost>
I had a similar problem and I fixed it by using the previous version of mod_jk. I originally downloaded version 1.2.36 but I was able to get it to work using 1.2.35. You can download the previous versions here: http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/windows/

Glassfish 3.1.2 Apache2 loadbalancing with mod_jk

We are using glassfish 3.1.2 which is loadbalanced by Apache with mod_jk however, when I turn on the ping_mode to C or A it does not work, it just says
[Wed May 09 08:17:05 2012] [15033:140400029296384] [info] ajp_handle_cping_cpong::jk_ajp_common.c (889): awaited reply cpong, not received
[Wed May 09 08:17:05 2012] [15033:140400029296384] [error] ajp_connect_to_endpoint::jk_ajp_common.c (992): (worker2) cping/cpong after connecting to the backend server failed (errno=0)
[Wed May 09 08:17:05 2012] [15033:140400029296384] [error] ajp_send_request::jk_ajp_common.c (1585): (worker2) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=0)
[Wed May 09 08:17:05 2012] [15033:140400029296384] [info] ajp_service::jk_ajp_common.c (2540): (worker2) sending request to tomcat failed (recoverable), because of error during request sending (attempt=19)
[Wed May 09 08:17:06 2012] [15033:140400029296384] [info] ajp_connection_tcp_get_message::jk_ajp_common.c (1223): (worker2) can't receive the response header message from tomcat, tomcat (192.168.42.83:8009) has forced a connection close for socket 15
However, if I comment out the following line it works fine, any ideas?
worker.template.ping_mode=A
My entire workers file looks like this.
worker.list=loadbalancer, status
worker.template.type=ajp13
worker.template.port=8009
worker.template.lbfactor=1
worker.template.socket_timeout=10
worker.template.ping_timeout=10000
worker.template.ping_mode=A
worker.template.connection_pool_size=25
worker.template.connection_pool_timeout=300
worker.template.retries=20
worker.worker1.reference=worker.template
worker.worker1.host=node1
worker.worker2.reference=worker.template
worker.worker2.host=node2
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=worker1,worker2
worker.status.type=status