Quote:
Originally Posted by acid_kewpie
no, it shouldn't. if you are defining a virtualhost on :80 and :443 then as they are on different ports they don't conflict. The port number is not passed as part of the hostname, just look at the headers you're sending, and there should be no port number in the Host header
|
It depends on the browser, and even version numbers in the case of Apache:
Code:
GET / HTTP/1.1
Host: faraday.ipal.net:80
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Code:
GET / HTTP/1.1
Host: faraday.ipal.net
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110422 Ubuntu/10.10 (maverick) Firefox/3.6.17
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
In cases where it is NOT port 80, but a port specified in the URL, then the port number is included in the Host: header in cases where it does not for 80, unless it was specified as 80. When explicitly specified as 80, it seems to be acted on the same way as not specified. But over the limited browser tests I have done (firefox and lynx) I cannot be sure that this doesn't vary for others. Nevertheless, for some other port number, like 88 or 8080 or whatever, it does supply the port number in Host: more often (though in theory it doesn't need to, since it made a connection to the proper port at the TCP layer which can still be used to distinguish the accesses).
It seems as though Apache is parsing the host name and port number apart, and doing EITHER:
1. Comparing only the host name part to select the VirtualHost section.
2. Substituting the connected port number where missing from Host: and the Listen port number where missing from ServerName/ServerAlias, and comparing both host name and port number to select the VirtualHost section.
Perhaps both choices will always end up being the same where there is no specific conflict like (this example of a conflict):
Code:
<VirtualHost example.com:80>
ServerName example.com:96
...
Then I have a case where I code the IP address (IPv6) in the URL:
Code:
GET /used/IP/address/instead/of/host/name HTTP/1.1
Host: [fcca::1a]
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110422 Ubuntu/10.10 (maverick) Firefox/3.6.17
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
How do I match that? Since a port number can be used there, I assume I need the [] to separate the optional port number from the IPv6 address. But, Apache2 doesn't like the [] syntax. Apache1 didn't do IPv6 that I'm aware of (I didn't have IPv6 when I did have Apache1) but it did do IPv4 addresses and I was able to make separate web sites for the three cases:
1. No Host: header provided at all
2. Used the standard dotted-decimal IP address form as host
3. Used the decimal 32-bit number form as host
Perhaps Apache2 has deprecated one or both "address as host" forms. I just haven't found any documentation on the httpd.apache.org site that says that, so I cannot be sure. Nevertheless, sites with IP addresses as host names do exist on the internet.
FYI, I'm writing code to generate Apache configurations from a database of what sites are supposed to be present.