Chapter 2. The site’s design
Multiple addresses:
A single system need not have a single IP address. It can have many and each can
have a different web site attached to it. This leads to two different server names ap-
pearing in standard URLs (i.e. there’s no :port element in the URL) but the two
server names correspond to the two different IP addresses of the system and corre-
spond to different web sites. The receiving web server uses the destination IP address
on the incoming query to distinguish web sites.
Multiple aliases
Also known as name-based virtual hosting, this is the most common form of virtual
hosting. The server only has a single IP address, but two different names in the DNS
correspond to that address. So chalk.dept.cam.ac.uk and cheese.dept.cam.ac.uk both
map on to the same IP address and therefore the same server. This raises the question
of how the web server can distinguish requests to the two different web sites.
Structures of HTTP queries and responses
To answer this question, we need to consider, briefly, the nature of a web request.
Exactly what gets sent to a server when a URL is requested? (And for that matter,
what gets sent back?)
GET /index.html HTTP/1.1
Host: noether.csi.cam.ac.uk
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003
Accept: text/html,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
Accept-Language: en, es;q=0.50
Accept-Encoding: gzip, deflate, compress;q=0.9
Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.33
Connection: keep-alive
Keep-Alive: 300
Figure 2-1. Incoming HTTP query for http://noether.csi.cam.ac.uk/index.html
To understand name-based virtual hosting consider just the first two lines. The GET
request only refers to the local element of the URL. The second line specifies the
hostname that is being asked for it.
HTTP Query Structure
GET
The first line declares that this is a request from a client that wishes to read in-
formation from the server. GET is the most common HTTP method.
/index.html
The second term in the first line is the local element of the URL requested. Note
that the leading part of the URL containing the server name has been stripped
out.
HTTP/1.1
The final element declares that the query is couched in the language of version
1.1 of the HTTP standard.
12
Comentarios a estos manuales