aspose file tools*
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
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
Author

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 "www.mycoolsite.com") 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 www.mycoolsite.com, 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 "www.mycoolsite.com", and also in Tomcat's Engine defaultHost="www.mycoolsite.com" and a Host with name="www.mycoolsite.com". 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: http://aspose.com/file-tools
 
subject: Tomcat returns 302 back to Apache via AJP13