I have Tomcat running on port 8080, and when I send a request directly to Tomcat it works fine:
curl -IL http://localhost:8080/myapp HTTP/1.1 302 Moved Temporarily Server: Apache-Coyote/1.1 Location: http://localhost:8080/myapp/ HTTP/1.1 302 Moved Temporarily Server: Apache-Coyote/1.1 Location: http://localhost:8080/myapp/login.html HTTP/1.1 200 OK Server: Apache-Coyote/1.1
I have the following mod_proxy setup in Apache:
ProxyRequests Off ProxyPreserveHost on ProxyPass /myapp http://localhost:8080/myapp retry=0 ProxyPassReverse /myapp http://localhost:8080/myapp retry=0
When I make a request that goes through the proxy, I get a 404 from Tomcat. The headers say Apache-Coyote, so I know it's going through the proxy and reaching Tomcat.
curl -LI https://myserver.com/myapp HTTP/1.1 404 Not Found Server: Apache-Coyote/1.1
I enabled the access log in Tomcat to see what the problem is, and Tomcat's access log is logging any requests that go directly to port 8080, but it isn't logging any requests that go through Apache.
If Apache is mangling the request or something, I would like to see the evidence of that in Tomcat's log. Can anyone tell me how to get Tomcat to log 404's that go through the proxy the same as it logs 404's that don't go through the proxy?
EDIT I also noticed that the 404 only happens when ProxyPreserveHost on
is part of the config. If I remove it, the proxy works exactly as expected. But I do need the proxy to pass along the hostname to Tomcat.
EDIT I have now set LogLevel Debug, which shows the full proxy connection in the error log. Unfortunately I'm still not seeing where the 404 came from, but here's the connection:
[Thu Jan 30 11:42:40 2014] [debug] proxy_util.c(1506): [client 10.100.10.38] proxy: http: found worker http://localhost:8080/myapp for http://localhost:8080/myapp [Thu Jan 30 11:42:40 2014] [debug] mod_proxy.c(1020): Running scheme http handler (attempt 0) [Thu Jan 30 11:42:40 2014] [debug] mod_proxy_ajp.c(677): proxy: AJP: declining URL http://localhost:8080/myapp [Thu Jan 30 11:42:40 2014] [debug] mod_proxy_http.c(1973): proxy: HTTP: serving URL http://localhost:8080/myapp [Thu Jan 30 11:42:40 2014] [debug] proxy_util.c(2011): proxy: HTTP: has acquired connection for (localhost) [Thu Jan 30 11:42:40 2014] [debug] proxy_util.c(2067): proxy: connecting http://localhost:8080/myapp to localhost:8080 [Thu Jan 30 11:42:40 2014] [debug] proxy_util.c(2193): proxy: connected /myapp to localhost:8080 [Thu Jan 30 11:42:40 2014] [debug] proxy_util.c(2444): proxy: HTTP: fam 2 socket created to connect to localhost [Thu Jan 30 11:42:40 2014] [debug] proxy_util.c(2576): proxy: HTTP: connection complete to 127.0.0.1:8080 (localhost) [Thu Jan 30 11:42:40 2014] [debug] mod_proxy_http.c(1851): proxy: header only [Thu Jan 30 11:42:40 2014] [debug] proxy_util.c(2029): proxy: HTTP: has released connection for (localhost)