Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Tomcat 5.0.27-2 server (I know... old) and Apache 2.0.46-77 server running and serving apps up just fine currently. The problem we are experiencing is that if I navigate to http://www.mysite.com/index.jsp, I see the expected JSP. However, if i navigate to (broken up for posting purposes) http:// 1.2.3.4 /index.jsp (the site's external ip address that is NATed to 192.168.0.20), I see the default "Tomcat welcome" jsp. One additional tidbit, if i go to http:// 192.168.0.20 /index.jsp, I see the correct site. It's only when going through NAT that i see the tomcat page. I'm sure it's something in the server.xml or web.xml, but I don't know what.

Before you say "Upgrade your tomcat", I know we need to do that, but this is for an immediate issue and we don't have the time available for migration and thorough testing. Eventually, we will upgrade to Tomcat6, just not today.

We are hosting several sites on the server, but for this site the server.xml has the following:

<Host name="mysite.net" appBase="/mysite_root/ROOT" >
   <Alias>1.2.3.4</Alias>
   <Context path="" docBase="" debug="0" reloadable="true" crossContext="true" />
</Host>

<Host name="www.mysite.net" appBase="/mysite_root/ROOT" >
   <Alias>1.2.3.4</Alias>
   <Context path="" docBase="" debug="0" reloadable="true" crossContext="true" />
</Host>

<Host name="mysite.com" appBase="/mysite_root/ROOT" >
   <Alias>1.2.3.4</Alias>
   <Context path="" docBase="" debug="0" reloadable="true" crossContext="true" />
</Host>

<Host name="www.mysite.com" appBase="/mysite_root/ROOT" >
   <Alias>1.2.3.4</Alias>
   <Context path="" docBase="" debug="0" reloadable="true" crossContext="true" />
</Host>
share|improve this question

3 Answers 3

up vote 0 down vote accepted

This can happen when you have Tomcat answering on the host's IP address itself, rather than on 127.0.0.1.

If what you are aiming to do is have Apache act as your front door and proxy all requests to Tomcat, then you should make Tomcat bind to localhost, not to the host's IP address. Then you can use mod_proxy to forward requests, and not have anybody hitting Tomcat directly. This is well-described in the Apache docs and pretty common, so it shouldn't be too hard to change over.

share|improve this answer
    
I think this has something to do with NAT. Internal IP works ok, NAT ip shows tomcat. –  SpaceCowboy74 Aug 14 '12 at 21:03
    
Those issues will probably go away if you bind Tomcat to localhost and let your RP do its job. –  khoxsey Aug 14 '12 at 21:10

It's probably configured to do name based hosting... is there a Host tag in the server.xml with an appBase attribute? If so, check what it is set to and what the default is.

share|improve this answer
    
I updated my original post with the server.xml for that host. I've probably got something configured wrong. –  SpaceCowboy74 Aug 10 '12 at 20:33

You can set a rewrite rule in apache that redirects all request that don't start with http://www.mysite.com to http://www.mysite.com.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.