I am having some problem hosting a second website in the same server.

I have 2 1and1 domains now. When i had the first one, i set the DNS setting to point to my server's ip address and i had the port forwarding setup that forwards this request coming from port 80 to the port that tomcat is running in my server.

Now i have to add a new webapp for the new domain that i just purchased and it looks like i cannot specify port in the dns setting in 1and1 console for the IP address.

How can my tomcat instance know that the request is coming for this domain and it needs to hit a different context?

I had my original webapp named at ROOT so the domain directly pointed to the correct app!

Let me know if you have any questions?

Looking forward for your help!


Ok, first of all, you can't specify the port for HTTP in your DNS*

You want two different hostnames to be handled by two different contexts in to tomcat. This is called virtual hosting. Tomcat supports it, no port forwarding fanciness required.

Per Tomcat's documentation, you probably want something like this:

<Engine name="Catalina" defaultHost="ren">
    <Host name="ren"    appBase="renapps"/>
    <Host name="stimpy" appBase="stimpyapps"/>

Replacing "ren" with one fully qualified domain name (eg. "foo.example.com", or "www.example.net"), and "stimpy" with the other.

*Ok, well theoretically you technically can specify the port for HTTP in your DNS using SRV, but AFAIK no major HTTP client/browser will honor it.

  • 1
    wow! it did work, I had to add the full domain name though instead of ren in the Host name, it was www.ren.com. Thanks for the help! – Peshal Aug 11 '14 at 4:28
  • Glad the issue is resolved. I'll edit my answer to clarify about the full domain name. – Joe Sniderman Aug 11 '14 at 4:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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