wood burning stoves 2.0*
The moose likes Tomcat and the fly likes DNS forwarding with multiple applications Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "DNS forwarding with multiple applications" Watch "DNS forwarding with multiple applications" New topic
Author

DNS forwarding with multiple applications

john varren
Greenhorn

Joined: Jun 28, 2012
Posts: 2
I recently installed business objects software on tomcat 6. I have 2 domains - domain1 and domain2. This software allows access to two of its applications via these URLS:

http://myservername.domain1:8080/BO/APP1 and http://myservername.domain1:8080/BO/APP2.

Instead of these urls, I would like the end users to access these apps via something like http://bobj.domain2.com:8080/BO/APP1 and http://bobj.domain2.com:8080/BO/APP2.

I cannot figure out how to accomplish that. I have looked into the option of http redirect (not good because the destination address shows up in the address bar), domain forwarding (not sure if it would work with multiple applications and forwarding from one domain to another) and also using apache tomcat with mod_jk by using virtual hosts (not sure if it is possible when forwarding from one domain to a sub domain in another domain) ??

Experts, please advise as to what would be my best option and how to accomplish.

thanks a bunch
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15947
    
  19

Welcome to the JavaRanch, John!

The first part of a URL (after the protocol declaration) is the server domain name or IP address. This part cannot be arbitrarily set because it is what the client uses to select which server to send the request to. In the case of an IP address ("http://10.0.0.1:8080"), the client targets that IP directly. In the case of a symbolic name ("http://www.javaranch.com"), the client uses its address name resolution services to determine the appropriate IP address.

The most common way that a client resolves a domain name is via Domain Name Services (DNS). DNS is a protocol whereby a client submits a domain name to a DNS server (usually via UDP port 53) and is returned the corresponding IP address. Of the several alternatives, a popular one is a "hosts" file, which is typically a simple text file with a list of domain names and their corresponding IP addresses. Since there are at least 5 different ways of doing a hostname lookup, most OS's allow customizing this process, including setting the order in which resolvers are searched.

So to use a hostname like "bob.domain1.com", you need a resolver that maps "bob.domain1.com" to the IP address of that machine - even if it's the same machine that the request comes from (usually you'd map to 127.0.0.1 in that case).


Customer surveys are for companies who didn't pay proper attention to begin with.
john varren
Greenhorn

Joined: Jun 28, 2012
Posts: 2
Tim,

Thank you for your insight. But i am not sure how your solution would work because please note that my end user url would be in domain1 and my server is in internal domain2 ?? Also, on which machine would I modify the hosts file ??? I cannot modify the hosts file of 1000s of end users !! Additionaly, if i modify the hosts file, the destination address (server address in domain 2) would show up in the address bar for the users, wouldnt it ?

Thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15947
    
  19

Definitely you don't want to have to modify thousands of host files on thousands of computers. We can rule that one out.

On the other hand, there is absolutely no law that says a server has to belong to only one Internet domain (which is not the same thing as a Windows domain, BTW).

At one time I had a server whose primary domain name was www3.mousetech.com. but also hosted mail.mousetech.com, ftp.mousetech.com, www.chucktfrog.com and www.servicingauction.com.

Normally, when a URL comes back in a link, the hostname that comes back will be the same as the hostname that requested whatever page the link was in. It's ultimately in how things are programmed, but that's the usual way of it.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12753
    
    5
I have my Tomcat configured to serve 6 different host addresses using <Host entries in server.xml - naturally all 6 have been registered with DNS entries pointing to the same IP - Tomcat looks at the URL and decides which set of webapp files to use from the appBase attribute in the Host entry.

Bill
>
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15947
    
  19

William Brogden wrote:I have my Tomcat configured to serve 6 different host addresses using <Host entries in server.xml - naturally all 6 have been registered with DNS entries pointing to the same IP - Tomcat looks at the URL and decides which set of webapp files to use from the appBase attribute in the Host entry.

Bill
>


Well..... Actually not quite like that, I think.

Each Host entry specifies a Host Name - or more precisely, Domain Name. When a TCP IP request comes into port 8080, Tomcat looks at the URL and pattern-matches it against the list of Hosts. There's a default host if it doesn't match. Once the Host has been determined, then the Contexts defined for that host are pattern-matched against the URL to determine the webapp context. That determines which of the deployed webapps receives the request. The further routing of the incoming URL request is then determined by rummaging around in the webapp's web.xml.

And, of course, the app-local part of the classpath and the other resource paths for that Context are defined relative to the appBase in the Context.

In the case of the server box I mentioned earlier, some of the hosts I named had individual IP addresses of their own various reasons, so the IP address isn't "naturally" always the same. But placing a network interface card into promiscuous mode so that it may answer to multiple IP addresses does carry a performance penalty, so natural or not, it's generally better.

Incidentally, one of the reasons for the multiple IP addresses is that back when I set all this up, there was still some HTTP 1.0 traffic kicking around, and Virtual Hosts don't like sharing the same IP address in HTTP 1.0. You need at least HTTP 1.1 for that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DNS forwarding with multiple applications
 
Similar Threads
Problem with referencing session information from 2 contexts, one a subfolder of another
Session Variable
DNS related problem and Tomcat
Ajax doubt - url in open method
jboss web application (WAR) deployment