Re: Third level domain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



André Warnier ha scritto:

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 ?
Correct

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 ?

Correct

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

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.
I need Apache in front of Tomcat

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 ?
mod_jk
Do you have a preference ?
I was thinking about mod_jk

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 ?
Correct

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.
It is 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 ?
As you can see from the configuration I posted I am using mod_jk

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 ?
The apps are installed and working in Tomcat. I have no problem when I call them direcly on Tomcat port like this
http://www.mycompany.com:8080/site_prod
and
http://www.mycompany.com:8080/site_admin

As you said what I want to achieve is calling one this way
http://www.mycompany.com
and the other that way
http://admin.mycompany.com
 


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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




--

Alessandro Fantuzzi - O-one s.r.l.
Software developer


-------------------------------------------------------------------
Via Dante Zanichelli, 61 - 42100 Reggio Emilia
Tel. 0522 930078 - Fax. 0522 387947
-------------------------------------------------------------------
Via Stendhal, 36 - 20144 Milano
Tel 02.42292057 - Fax 02.47770936
-------------------------------------------------------------------

STRICTLY PERSONAL AND CONFIDENTIAL This message may contain confidential and proprietary material for the sole use of the intended recipient. Any review or distribution by others is strictly prohibited. If you are not the intended recipient please contact the sender and delete all copies. The contents of this message that do not relate to the official business of our company shall be understood as neither given nor endorsed by it.
-------------------------------------------------------------------

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux