tags:

views:

72

answers:

3

Hi there, I have a Tomcat app that is acting as a web server/gateway to Sun Systems Connect (which is itself the gateway to Systems Union Accounts that I suspect is the gateway to happiness).

Anyway.

I can access the app's login page via a browser as long as I use the machine name (or localhost when local). But neither the machines IP nor Localhost allows me to see the login page.

SUN tell me this is a 'feature' of Tomcat. Unfortunatly the account smachines in development and in production have th esame name ( different domains) so I can't tell if I am running tests on the dev or Live box. Short of changing the box names can I force Tomcat to accept IPs?

Thanks for any help Richard

A: 

It's been a while since I used Tomcat, but I thought by default you could call the web service via either name or IP address. I don't know if this will help, but you could try setting a virtual host for the IP address in server.xml, e.g. add a stanza something like

<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true">

but replacing "localhost" with your machine's IP address.

ire_and_curses
A: 

http://tomcat.apache.org/tomcat-4.1-doc/config/valve.html talks about a resolveHosts flag that forces a DNS lookup, also maybe with adjusting the pattern shown to one of the %A parameters you could list the IP address in the log.

+1  A: 

Tomcat doesn't know anything about IPs. IP is just treated as hostname. You need to make sure the configuration allows the IP. You have a few options to achieve this.

If you add a defaultHost for the engine, any non-matching hostname or IP will use this virtual host. For example,

<Engine name="Standalone" defaultHost="example.com">

If you want more control, you can also add the IP as an alias, like

<Host appBase="webapps" name="example.com">
   <Alias>192.168.1.2</Alias>
</Host>

There are many other reasons that an IP may be rejected,

  1. SSL doesn't allow IP because certificate doesn't know anything about IP address.
  2. If you use virtual host on Apache or a front-end switch, it normally based on the decision on the hostname you use and it doesn't know how to route IP.
  3. You may have some security filter or rule to check Host headers in HTTP and specifically drops requests from unknown hosts.

Looking at logs may show you the exact cause.

ZZ Coder