cURL / Mailing Lists / curl-users / Single Mail

curl-users

Requesting an Apache virtual host with CURL

From: John Sherling <sf.techguy_at_gmail.com>
Date: Wed, 13 Dec 2006 20:35:15 -0800

I need to move a website from webserver 1 to webserver 2, and I'm
trying to use CURL to help me test the new server before I switch the
DNS. A little tricky to explain, so I'll give an example:

Let's say I've got an old Apache webserver running on IP 12.34.56.78 -
this runs my live website for 'www.domain.com' (which is a virtual
host, among many, on this server).

Additionally, I've got a second, new Apache webserver running on IP
98.76.54.32. I've got the same virtual host name ('www.mydomain.com')
set up on that machine. Of course, if I do a DNS lookup for
'www.mydomain.com,' it will return 12.34.56.78, the address of my old
live sever.

My problem: I want to test the new server, using the proper hostname
(www.mydomain.com), WITHOUT resorting to DNS trickery to acheive it
(reasons are complicated, but valid).

So my question is: can I to tell CURL to request the site
'www.mydomain.com' from the server 12.34.56.78, but WITHOUT trying to
resolve 'www.mydomain.com' to an IP first (since it will resolve to
12.34.56.78 and show me the old live site)?

Again, for various reaasons, I DONT want to use any kind of DNS tricks
to solve the problem. I want to know if CURL can make a request for
the 'www.mydomain.com' domain name to the 98.76.54.32 server, but
WITHOUT trying to resolve the 'www.mydomain.com' hostname first.

I thought there may be a way to use headers to do it (since that's how
browsers handle virtual hosts on webservers), so I tried:

curl -H "http://www.domain.com" 98.76.54.32
curl -H www.domain.com 98.76.54.32

but when I try this, curl always does a lookup on the hostname, and
sends me to the old server.

Again, to summarize: I want CURL to request the site
'www.mydomain.com' from the webserver IP 98.76.54.32, but WITHOUT
trying to do a hostname lookup on 'www.mydomain.com' first.

Can anyone help me here?

Many thanks!!
Received on 2006-12-14