Centos – Why is apache giving DNS lookup failures

apache-httpdcentostomcat

A CentOS 7 web server has tomcat serving up war files behind an apache httpd reverse proxy. This works perfectly when the WAR files are all server-side code. But when client side code (AngularJS in this case) is included alongside server-side code in the war files, apache httpd 2.4 throws the following proxy error for every dependency of the core html file in the app when domain3.com is typed in a web browser:

[proxy:error] AH00898: DNS lookup failure for: resources returned by /res$

To confirm that this is an apache error and not a tomcat error, I opened up the 8084 port for the app in firewalld and then loaded domain3.com:8084 to find the app running perfectly, including its client side, AngularJS, code.

What config changes are required in order to enable apache httpd 2.4 to serve up the includes for the client side app that is included in the war when requests for domain3.com are typed into web browsers?

The complete httpd logs for one such domain3.com transaction are:

[Tue Nov 03 14:31:57.662516 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013resources returned by /res$
[Tue Nov 03 14:31:57.747345 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013resources returned by /res$
[Tue Nov 03 14:31:57.752815 2015] [proxy:error] [pid 9294] [client client.ip.addr:57370] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:57.757663 2015] [proxy:error] [pid 11936] [client client.ip.addr:57372] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/an$
[Tue Nov 03 14:31:57.758121 2015] [proxy:error] [pid 4325] [client client.ip.addr:57371] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:57.758509 2015] [proxy:error] [pid 23006] [client client.ip.addr:57373] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/an$
[Tue Nov 03 14:31:57.762749 2015] [proxy:error] [pid 9325] [client client.ip.addr:57374] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:57.829953 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:57.846174 2015] [proxy:error] [pid 9294] [client client.ip.addr:57370] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:57.851022 2015] [proxy:error] [pid 4325] [client client.ip.addr:57371] AH00898: DNS lookup failure for: server.ip.addr:8013somecontroller.js returned$
[Tue Nov 03 14:31:58.049885 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:58.207199 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:58.320704 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:58.428737 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:58.523564 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:58.611546 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013js returned by /js/lib/ang$
[Tue Nov 03 14:31:58.708439 2015] [proxy:error] [pid 9332] [client client.ip.addr:57369] AH00898: DNS lookup failure for: server.ip.addr:8013somecontroller.js returned$

The tomcat logs for the same domain3.com transaction simply show one successful GET request:

client.ip.addr - - [03/Nov/2015:14:31:57 -0500] "GET / HTTP/1.1" 200 2944

The client sees these as 502 errors for the dependencies, but not for index.html, which is the only resource that is served correctly.

The relevant section of /etc/httpd/conf.d/virtualhosts.conf is:

<VirtualHost www.domain3.com:80>
    ServerName www.domain3.com
    ServerAlias domain3.com
    ErrorLog /var/log/httpd/domain3_com_error.log
    CustomLog /var/log/httpd/domain3_com_requests.log combined
    ProxyPass / ajp://server.ip.addr:8013
    ProxyPassReverse / ajp://server.ip.addr:8013
</VirtualHost>

So what do I change in order to get httpd to serve up the requests for the include files in the client-side portion of the app at domain3.com?

Best Answer

Add the missing trailing slash to your ProxyPass and ProxyPassReverse directives:

ProxyPass / ajp://server.ip.addr:8013/
ProxyPassReverse / ajp://server.ip.addr:8013/
Related Question