How can I diagnose a "502 Bad Gateway" response from an Apache/Tomcat configuration?

18,121

Changed the port from default 8080 to 8009 and also added my jsptest directory to tomcat/webapps/ so that it worked according to the JkMount /jsptest/*.jsp worker directive.

Share:
18,121

Related videos on Youtube

Structure
Author by

Structure

Updated on September 17, 2022

Comments

  • Structure
    Structure over 1 year

    I just finished up configuring a fairly default configuration of Tomcat. My Apache configuration was pre-existing and post-tomcat it still has no issues. I am using mod_jk to (if I am saying this correctly) interface between Apache and Tomcat and have my conf files setup for my workers, etc.

    I put my test file (Simply: http://tomcat.apache.org/tomcat-4.1-doc/appdev/sample/web/hello.jsp) into my tomcat/webapps/ directory and then call it via http://localhost/jsptest/hello.jsp. From here Apache returns a 502 Bad Gateway response.

    I confirmed this via the Apache logs, but beyond that I have no idea how to diagnose the issue. I assume the 502 is because Tomcat did not respond. I'd like to confirm if Tomcat received the request, but cannot locate the log file.

    At this point I had thought my installation was complete, so not sure where to go from here. Any input would be appreciated.

    Edit: catalina.out, manager.log, localhost.log, etc do not have any data logged for the time that I made my requests.

    Edit: Slowly figuring the configuration out. The following three lines appear in mod_jk.log when I make a request:

    [Tue Jun 01 17:34:26 2010] [4207:3086195296] [error] ajp_connection_tcp_get_message::jk_ajp_common.c (1252): wrong message format 0x3c21 from 127.0.0.1:8080
    [Tue Jun 01 17:34:26 2010] [4207:3086195296] [error] ajp_get_reply::jk_ajp_common.c (2055): (worker) Tomcat is down or refused connection. No response has been sent to the client (yet)
    [Tue Jun 01 17:34:26 2010] [4207:3086195296] [error] ajp_service::jk_ajp_common.c (2559): (worker) connecting to tomcat failed.
    

    Edit: Changed the port in workers.properties from 8080 to 8009. Now mod_jk.log shows the following:

    [Tue Jun 01 17:54:55 2010] worker localhost 0.003423
    

    So Tomcat is getting the request, however a 404 (from Tomcat) is returned even though I added hello.jsp to both my tomcat/webapps/ and apache/html/jsptest/ directories in order to cover all bases. Perhaps I am misunderstanding the Aliasing method? Not sure how it cannot find a file that exists in the two most logical places...

    Edit: Well, I just walked myself straight through the problem. My port was wrong in workers.properties. Once I fixed that and saw the 404 from Tomcat I realized the configuration was working and the file couldn't be found. What I didn't realize was that the jsptest directory needed to be in tomcat/webapps/jsptest/. Now everything works... thanks for humoring me. Hopefully this helps someone.