[En-Nut-Discussion] How to connecto to a virtual host

Vesa Jääskeläinen chaac at nic.fi
Sun Dec 25 12:55:05 CET 2005


Pavel Chromy wrote:
> Jesper Hansen napsal(a):
> 
>> I was trying to download a file using HTTP from my Linux machine,
>> which has a number of domains on it.
>>
>> I used NutDnsGetHostByName to pick up the IP which worked fine, then
>> used a "GET /myfile.ext HTTP/1.0" e.t.c. to get the file.
>>
>> It obviously didn't work, because the IP returned by
>> NutDnsGetHostByName  will just point to the default Apache page on the
>> Linux machine and not to the one at my virtual domain on that machine,
>> which I would normally reach with "www.domain.com" in a browser.
> 
> Hi, Jesper!
> 
> Sure, it cannot work this way as all virtual hosts resolve to the same
> IP address. You have to use HTTP 1.1 and a Host header. Try sending
> Host: wanted.virtualhost.net\n" first and then "GET /myfile.ext
> HTTP/1.1\n".
> 
> Hope this helps

Except that it is not allowed in that order!

You must first tell what is the action, eg GET.

--
GET /myfile.ext HTTP/1.0\r\n
Host: www.myhost.com\r\n
\r\n
--

Every line must be terminated by ASCII values 13 (\r) and 10 (\n) and
empty line must be after last entry in request.

Good way to test how pages should be retrieved is to use telnet to test
it out before trying it on embedded environment (saves lot's time :))



More information about the En-Nut-Discussion mailing list