Tomcat – Correct way to configure Tomcat virtual hosts

tomcatvirtualhost

If I want to access Tomcat directly from a remote host, i.e. not through Apache, should I configure the connector to use localhost or the external IP/hostname? What if it's on a Windows server and I want to access it both remotely and from the desktop or from two different external IPs – do I need multiple connectors and multiple directories under conf/Catalina/ or can I somehow connect two hosts to the same directory?

Best Answer

You should use the external host name for the connector.

As long as the server is accessible from the all networks you're using with the external IP, you're good to go - no extra configuration.

If you do need multiple host names/IPs, you can do what the tomcat documentation suggests:

<Host name="www.mycompany.com" ...>
    <Alias>mycompany.com</Alias>
     ...
</Host>