aspose file tools*
The moose likes Tomcat and the fly likes Subdomains? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Subdomains?" Watch "Subdomains?" New topic
Author

Subdomains?

Joseph Swager
Ranch Hand

Joined: Feb 04, 2010
Posts: 36

Ok here is what I'm wanting to do. I have my production site running on my domain.
I want to have a testing site thats a sub domain for development.


now I have all my DNS records set and everything is resolving.

So in my tomcat directory on top of the webapps dir i created a dev dir at the same level.

both dirs have ROOT directory.

here is an example of how my server.xml file is set up.




My question is why does both www.example and dev.example resolve and load the production page?
How do i get the other subdomain to refer to the /dev and not the /webapp directory ?

I 'm feeling kinda lost here so any point in the right direction would be great.


"Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do." -- Steve Jobs
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16014
    
  20

DNS resolves (sub)domain names to ONLY the IP address. There is no provision whatsoever in DNS to resolve context names or even tcp/ip port numbers (like 8080). So the incoming URL must provide those little niceties the hard way.

What we do in the real world in cases like that is to point the incoming URLs to a proxy that has URL rewriting capabilities so that something like "http://dev.example.com" gets rewritten and routed to Tomcat as "http://dev.example.com:8080/devapp".


Customer surveys are for companies who didn't pay proper attention to begin with.
Joseph Swager
Ranch Hand

Joined: Feb 04, 2010
Posts: 36

I see what you mean now. However I only want to run the tomcat server and not use apache to proxy and remap all the URLS. I already have all port 80 traffic redirected to 8080 by the iptables. So is there a module or something to write in the configuration files allows if dev.example.com to be rewritten in the url dev.example.com/dev

im not worried about the port because all traffic is redirected to port 8080

Thank again for your reply.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16014
    
  20

I think that there's a Tomcat Valve that can do URL rewriting and someone here on the Ranch found it a couple of months ago. I don't recall details, but maybe if you search around a little...
Joseph Swager
Ranch Hand

Joined: Feb 04, 2010
Posts: 36

Hey Tim thank you so much for all your help. I solved it with a virtual server within server.xml file. When I get back into the office I'll show the exact setup i set for <Host> tags. It works like a charm.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16014
    
  20

Good point. I tend to avoid defining apps as root contexts, since you can have only one root app per Host, but after all, that's all you wanted here!
Yair Harel
Greenhorn

Joined: Aug 20, 2011
Posts: 2
Joseph Swager wrote:Hey Tim thank you so much for all your help. I solved it with a virtual server within server.xml file. When I get back into the office I'll show the exact setup i set for <Host> tags. It works like a charm.



Any chance you can collaborate how to solve this ??? I'm stuck on the same problem...

Thanks!!
Yair
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Subdomains?