File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Tomcat returns 302 back to Apache via AJP13 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat returns 302 back to Apache via AJP13" Watch "Tomcat returns 302 back to Apache via AJP13" New topic

Tomcat returns 302 back to Apache via AJP13

Andre Enimot
Ranch Hand

Joined: Jul 29, 2009
Posts: 31
Hi Guys,

I am trying to setup a home website (say "") with Apache2-->mod_jk/ajp13-->Tomcat6. When I go to the site from outside network by typing my home IP, it works ok. But when I go to, it does not work. I examined a debug-level logging from mod_jk, and see that request comes in, mod_jk finds a wildcard match, connects to Tomcat6 socket, sends request via AJP13, but in response gets 302 "Moved Temporarily", and eventually apache2 returns index.html. In case when I type IP address instead of domain name, everything is the same except response from Tomcat is not 302 but correctly rendered page.

So it looks like Tomcat refuses to serve requests that comes with domain name. I have VirtualHost *:80 in apache2 named "", and also in Tomcat's Engine defaultHost="" and a Host with name="". I am running standalone Tomcat6 from inside Eclipse, but have the above settings in server.xml in Tomcats conf folder and also in Eclipse's Server deployment folder. What I am doing wrong, please help?

Thanks in advance!
K. Gil
Ranch Hand

Joined: Apr 29, 2011
Posts: 75

it doesn't matter what "virtualhost" is called in apache, try to check apache ServerName and ServerAlias for this virtualhost
and remember that ServerName is passed to tomcat through AJP, and tomcat needs revelant entry: hostname = apache servername
Andre Enimot
Ranch Hand

Joined: Jul 29, 2009
Posts: 31
Thank you for the hint, the config parameters were as you described, names were matching. But the culprit turned out to be very simple -- the ServerName I was using was too long (because I mistakenly thought it must be same as domain name) -- 31 chars total. After I shortened the server/host names things work fine.
I agree. Here's the link:
subject: Tomcat returns 302 back to Apache via AJP13
Similar Threads
integrating tomcat 5.5.23 with apache 2.0.59
tomcat6 and apache
Using JForum via mod_jk
Tomcat6 404 on deployed subfolders? (It worked fine two days ago)
getting set up apache/tomcat