httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Evans <tevans...@googlemail.com>
Subject Re: [users@httpd] Testing virtual hosts on a virtual machine
Date Tue, 24 Nov 2009 17:53:51 GMT
On Tue, Nov 24, 2009 at 5:39 PM, Florent Georges <darkman_spam@yahoo.fr>wrote:

>  Hi,
>
>  I am using a virtual box (Ubuntu server 9.10 with VMware Fusion)
> to test a web server.  No problem to install Apache on this
> Ubuntu box, of course.  And I can access the default page after
> an install by using http://xxx.xxx.xx.xx/ in my browser (on the
> host machine.)
>
>  But the web server will use named virtual hosts.  I guess that
> won't work as the browser won't send the correct domain name.
>
>  Is there any tool to test an Apache instance with virtual hosts
> on a virtual machine?  Any best practice or advice to follow in
> that configuration?
>
>  Regards,
>
>
I've used a couple of different ways, depending on how magic/special you
like it. I'll outline them in terms of difficulty :)

1) Add your testing hostname to /etc/hosts:

Eg, if you want to test www.foocorp.com, and your vm's IP address is
10.0.1.10, then put this in /etc/hosts

10.0.1.10 www.foocorp.com

In windows, this is <WINDOWS>\system32\drivers\etc\hosts or somewhere along
those lines.

Once you do this, you can't go to the real www.foocorp.com without removing
the /etc/hosts entry

2) Run squid on the VM

Squid can do almost anything with HTTP, and works quite well at this. Once
you have squid configured as a regular cache, you add this kind of
configuration:

acl tested_sites dstdomain www.foocorp.com
cache_peer my-regular-upstream-cache parent 3128 0 proxy-only default
cache_peer the-ip-of-the-vhost-apache parent 80 0
cache_peer_access my-regular-upstream-cache deny tested_sites
cache_peer_access the-ip-of-the-vhost-apache deny !tested_sites
never_direct allow all

Basically, this configuration says to send anything not in the tested_sites
ACL to the regular upstream cache, whilst sending anything in tested_sites
to the apache server. Apache and squid are robust enough to do this without
any other changes. If you don't have an upstream squid, then the
configuration would need to be different - I'm no squid expert, so check the
manuals/squid mailing list if you want to do this.

Once you have squid set up and running, you can configure your browser to
switch between using this proxy, and using your regular upstream proxy/no
proxy. I use the firefox plugin SwitchProxy, two clicks to switch to my
testing infrastructure.

The advantage of the squid approach is that the hacks are all centralized on
one box, with no changes required on client machines, making it easier to
allow access to your test infrastructure.

Cheers

Tom

Mime
View raw message