Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Subdomains?

 
Joseph Swager
Ranch Hand
Posts: 41
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
Joseph Swager
Ranch Hand
Posts: 41
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic