• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DNS forwarding with multiple applications

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
john varren
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic