tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: How to map username.domain.com to www.domain.com/username
Date Mon, 25 Jan 2010 22:16:22 GMT
Bytecode wrote:
> Hi,
>  
>> Assuming you have DNS set up properly, use this:
> 
> I have not done DNS tweaking before. How should I setup the DNS? Do I have to set the
value of host name for the A record to "*"?
> 
>> http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html
> 
> Looks like this is not a dynamic approach. I have to specify each subdomain in the server.xml
but in my app
> I need a way to automatically map www.domain.com/newusername to newusername.domain.com.
Or have I missed something?
> 
Yes.  Basically, the whole point of DNS.

That part is really out of the scope of this forum, which is dedicated 
to Tomcat itself.
But here is a short rundown :


You have to look at it from the client point of view (the browser).

Suppose one of your users sits in Timbuctu, along with his workstation, 
on which runs an OS, on which runs a browser.
And supposes your Tomcat host has the public IP address 10.20.30.40.

In the browser URL bar, the user types :
http://hisname.bytecode-domain.com

B (for browser)) What his browser does :

B1) ask the local OS for the IP address of "hisname.bytecode-domain.com"
If he gets it (from the OS), then goto B3

B2) If he does not, then print : that host does not exist ! and stop.

B3) open a TCP connection with this IP address and port 80
B4) over that TCP connection, send a request that looks like this :

GET / HTTP/1.1
Host: hisname.bytecode-domain.com

and wait for a server answer on the same connection

O (for OS)) What the OS of his workstation does :
O1) it gets a request from the browser to translate the name 
"hisname.bytecode-domain.com" into an IP address.
O2) it looks in the local "hosts" file to see if that name is mentioned 
there (under Windows, this would be \windows\system32\drivers\etc\hosts)
O3) if yes, it returns the corresponding IP address and is done
O4) if not, then it will look for the IP address of a DNS server
(on a Windows workstation, type "ipconfig /all" in a command window to 
see this)
O5) it connects to, and sends a request to this DNS server, to translate 
the name "hisname.bytecode-domain.com" into an IP address
O6a) possibly, the DNS server returns : I don't know.
    Then the OS returns "I don't know" to the browser, and see B2 above
O6b) the DNS server returns an IP address (preferably the IP address of 
your Tomcat host). The OS then returns this IP address to the browser, 
and the browser can proceed to B3 above


In other words, if you want your user in Timbuctu to be able even to 
connect to your server, the information
"hisname.bytecode-domain.com" = IP address 10.20.30.40
has to be present in either one of two places :
- in the local "hosts" file on the workstation of your user
OR
- on the DNS servers out on the internet (**)

THEN, when that is solved, you can start figuring out how your Tomcat 
should proceed, when it receives a request for 
"http://hisname.bytecode-domain.com"
But you have to solve the above DNS issue first.
The Tomcat configuration itself is irrelevant until then.


(**) that sounds complicated at first sight, but if you control the main 
DNS server for your domain "bytecode-domain.com", then it is possible.
But it is anyway a bit out of the scope of Tomcat.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message