3

I just set up our first machine with Ubuntu 16 LTS and Tomcat 8.5.11 + Apache/2.4.18, mod_jk/1.2.41. I was quiet familiar with Ubuntu 14 LTS, Tomcat 7.0.70 and Apache/2.4.7 mod_jk/1.2.37.

Deploying my servlet seemed fine, no errors in tomcat or app log, but still not avail. Using fqdn/app showed an error 503. Using ip:port/app worked fine..

I saw these entries in mod_jk.log:

[Fri Feb 24 11:17:49.149 2017] [9219:139689407260416] [info] ajp_connect_to_endpoint::jk_ajp_common.c (1068): (worker1) Failed opening socket to (::1:8009) (errno=111)
[Fri Feb 24 11:17:49.149 2017] [9219:139689407260416] [error] ajp_send_request::jk_ajp_common.c (1728): (worker1) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111)

-> ::1:8009 Why is my worker.host=localhost resolved to ::1 (IPv6) instead of 127.0.0.1 (IPv4)?

I also saw the "newer" parameter "prefer_ipv6" and set it to "worker.prefer_ipv6=0" but without luck..

Workaround: When I set the worker.host=127.0.0.1 everything works fine/as I am used to. Downside: I know some collegue of mine has changed the 127.0.0.1 entry to "localhost" in the past for some reason (different ip stack in processing?), so I am not 100% confident leaving it with IPv4-IP.

Some advices on how I could fix that?

insideAC
  • 41
  • 3

1 Answers1

5

It's a bug in the JK connector, where it always prefers IPv6 when resolving the hostname in the "worker.*.host=" setting. The only way to force the latest JK connector to connect via IPv4 is to use an IPv4 address (rather than a DNS name).

The other alternative is to configure tomcat AJP/1.3 listener to listen on IPv6.

Until the folks at Apache fix the bug in the JK connector, these are the only options right now.

deltamind106
  • 638
  • 7
  • 19