httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: [users@httpd] Third level domain
Date Sat, 11 Apr 2009 13:18:59 GMT
Alessandro Fantuzzi wrote:
[...]

> 
> If I don' t go wrong the domain admin.site.com  is considered to be a 
> "third level domain" related to www.site.com
> 
I believe the following :
.com, .biz, etc.. are called "top level domains" or TLD (for obvious 
reasons).
mycompany.com, yourcompany.biz etc.. may be called "second-level 
domains", which in this case would make "www.yourcompany.biz" AND 
"admin.yourcompany.biz" be third-level domains.

The fact that "www" is traditionally chosen for website servers, and 
often for convenience made to resolve to the same IP as 
"yourcompany.biz", is just a choice.  Other than that, the name "www" 
for a host has no special DNS meaning as compared to "admin".

But that's not the main issue here.

To summarise : you have one Tomcat, one Apache httpd, and you want :
- that the requests to "http://www.yourcompany.com/" would go to the 
Tomcat application deployed under the /site_prod context
- that the requests to "http://admin.yourcompany.com/" would go to the 
Tomcat application deployed under the /site_admin context
both in the same Tomcat.

Check #1:
Presumably, you have Tomcat right now configured so that if you request 
"http://www.company.com:8080/site_prod" or 
"http://www.company.com:8080/site_admin", it calls the corresponding 
application, right ?

Check #2:
I will also suppose that the DNS hostnames "www.company.com" and 
"admin.company.com" resolve to the same IP address, this being the IP 
address of the host where Apache and Tomcat are running, right ?
(If not, then that is the first thing that you should organise, 
otherwise the rest will not work).

There are different ways in which you can achieve what you want.

The first thing you should now, is that strictly-speaking, to do just 
the above, you do not need an Apache httpd in front of Tomcat.  You 
could do this with Tomcat alone, and it may simplify your configuration 
and make your life easier, if you don't need Apache for anything else.
Let us know if you would prefer a Tomcat-only solution.

In the meantime, considering that you are naming Apache httpd in your 
configuration, let's suppose for now that you also need the Apache httpd 
for some other reason, and let's thus do it with a front-end Apache.

Even there, there are several possibilities.

You would want Apache (httpd) to act as a front-end for the Tomcat 
server, and to "distribute" the calls to the /site_prod and /site_admin 
applications under Tomcat.
Apache can do that, using either one of the following "proxy modules" :
- mod_proxy via HTTP
- mod_proxy via AJP
- mod_jk via AJP
Are you familiar with any of those ?
Is one of them already set up on your system ?
Do you have a preference ?

Next, presumably, you also want that in the process Apache makes the 
calls appear like you are calling the top-level (or default) application 
of two different sites, right ?
I mean, you want your clients to call
http://www.company.com  and not http://www.company.com/site_prod
Yes ?

So basically, what we want to achieve is :

browser :     http://www.mycompany.com      http://admin.mycompany.com
1) goes to :         apache httpd host         same apache httpd host
2) changed to:  localhost:xxxx/site_prod      localhost:xxxx/site_admin
   (where xxxx is the listening port of Tomcat on the same host)
3) sent to Tomcat (using mod_proxy_http, mod_proxy_ajp, or mod_jk)
4) calls Tomcat app     /site_prod                   /site_admin
and back

For (1), the DNS part must be working.
You will probably also need to understand Virtual Hosts, so you might as 
well read this too :
http://httpd.apache.org/docs/2.2/vhosts/
(read the section about Name-based Virtual Hosts)
For (2), you will need some rewriting of the URL.
Read this :
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
For (3), we will need an Apache/Tomcat Connector.
If one is already installed and working, it will be a lot easier.
Is there ?
Otherwise, I suggest mod_jk, but that is only a personal preference, 
because I know it better than the others.
For (4), these apps need to be installed and working in Tomcat.
Are they ? How do you call them, right now ?












> Here are the info about production environment.
> 
> LINUX   APACHE     2.0.59
> TOMCAT     5.5.20
> JVM    1.5
> 
> I read the documentation for both Apache httpd and Tomcat, and I also 
> had some testing on my testing environment, which is somewhat different.
> 
> Windows XP Professional
> APACHE     2.0.63
> Tomcat         6.0.14
> JVM    1.5
> 
> This is what we want to obtain:
> when the user calls http://www.site.com the contents must be served by 
> the application intalled in /site_prod under Tomcat.
> When the user calls a particular third level domain, say 
> http://admin.site.com the contents must be served by the application 
> installed in /site_admin
> 
> This is how I configured Apache httpd and Tomcat
> 
> :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

> 
> 
> httpd.conf:
> 
> here I created two VirtualHosts
> 
> <VirtualHost *:80>
> ServerName    admin.site.com
> 
> DocumentRoot    "webapps/site_admin"
> 
> JkMount     /site_admin/*.jsp worker1
> JkMount     /* worker1
> 
> RewriteEngine on
> 
> [...](Some rewrite rules)
> 
> [...](Log files)
> 
> </VirtualHost>
> 
> 
> <VirtualHost *:80>
> ServerName    site.com
> 
> DocumentRoot    "webapps/site_prod"
> 
> JkMount     /site_prod/*.jsp worker1
> JkMount     /* worker1
> 
> [...](Some rewrite rules)
> 
> [...](Log files)
> 
> </VirtualHost>
> 
> :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

> 
> 
> In server.xml I created two Hosts
> 
> <Host appBase="webapps\" autoDeploy="true" debug="0" 
> name="admin.site.com" unpackWARs="true">
>    <Context debug="1" docBase="web\" path=""/>
>    <Valve className="org.apache.catalina.valves.AccessLogValve" 
> directory="logs" pattern="common" prrefix="home_access_log."
>        resolveHosts="false" suffix=".txt"/>
> </Host>
>       <Host appBase="webapps\" autoDeploy="true" debug="0" 
> name="www.site.com" unpackWARs="true">
>    <Context debug="1" docBase="web\" path=""/>
>    <Valve className="org.apache.catalina.valves.AccessLogValve" 
> directory="logs" pattern="common" prrefix="home_access_log."
>        resolveHosts="false" suffix=".txt"/>
> </Host>
> 
> :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

> 
> 
> What is strange is that when both applications are up and running 
> everithing seem to go the right way.
> I mean, when I call www.site.com I get a response from the application 
> sitting on /site_prod
> And when I call admin.site.com I get a response from the application 
> sitting on /site_admin
> But if I turn off the application installed in /site_admin , instead of 
> receving an error message, I get a page from the application in /site_prod
> 
> I don' t know if this is a correct behaviour or if my configuration is 
> messed up.
> 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message