All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Testing virtual hosts on VirtualBox how?
I'm just learning configuring Debian/Nginx and I'd like to use a local Virtualbox machine with snapshots for the draft work. My problem is that I don't know how would it be possible to test the virtual host config, since all I have is an IP address.
Actually even an IP address + NAT is not easy, the only solution I came up with is to make 2 network interfaces in VBox:
1. for NAT
2. for host-only with fixed IP
Do you know any alternative? Afaik this is the easiest setup with VBox, what doesn't need port forwarding.
And for the real question, how do you make the virtual host forwarding work? The only idea I have is from this question, meaning directly editing the "hosts" file on the host. Is this a viable solution? Do you do this normally? Can I just enter any fake names and it will work?
Comments
If I am understanding correctly, you've setup nginx in one of the virtual machines, then you want to know how to access via the IP address of the real machine?
Iptables stuff
http://www.hackorama.com/network/portfwd.shtml
Oh, also, "virtual hosts" is about web hosting, and doesn't have to do with "virtual machines"
No I want to test "virtual host" configuration by running a Debian/Nginx server not in real world, but in virtualbox. I'd like to enter: http://vhost1 to on the vbox host to test the vhost1 website of my virtualbox guest.
then add vhos1 to your hosts file??
OK that's what I thought too. I just wanted to ask if there is someone who regularly uses VBox for testing scripts or images and knows how to work with virtual hosts. I'm trying to see if it works!
You could also setup a local dns server there and query that for your host if you want to make it even more like the real world, you will also learn to setup dns, simulate a big network, zones with your own TLDs, hosting with offloaded mysql on another machine, replication, make 10 VMs and let the fun begin :P
M
This might help you out, at least it does for me.
It's a chrome extension that lets you switch between IPs for live/development environments.
I presume you could just make some up hostnames and it should work - Not tried it out though.
Clicky click
Thanks for all the tips, the hosts file seems to work, but is a bit "slow":
1. After every modification, I have to "ipconfig /flushdns"
2. I need to quit chrome and start it again, as it caches DNS (even with reload).
Other than these, it works perfectly. VBox guest needs 2 network cards, one with NAT and an other with host-only, using static IP.
You don't need 2 network cards.
I use following method:
ipconfig /flushdns
required), add fake virtual domains / hosts, for example:192.168.1.20 vhost1 vpsclone.local mydomain.local www.mydomain.local sub.mydomain.local
Each of the fake aliases may be recognized as a separate vhost in Apache/nginx/lighttpd...
".local" is just a suggestion, you may also temporarily redirect your own domain for testing, like www.mydomain.com
A friend of mine also use that tool for Windows to edit hosts file: http://www.abelhadigital.com/hostsman/
On a Linux host, did not notice anything being slow with the hosts file.
The 2 network card is not related to this vhost issue. It's simply required to
1. Make the Vbox have a static IP address all the time
2. Make internet connection to the Vbox.
With bridged mode, I'm depending on the outside network, a no go. With NAT, I cannot reach the host, except with port forwarding. The only way to get a true connection is by host only card. The NAT is required to supply internet to the vbox.
The only "slow" thing in the hosts editing is the fact that I have to manually save, run flushdns and quit and restart Chrome.
ElliotJ I had a look at that extension and it cannot do that. It's for changing between valid addresses with a single click, not about hacking the DNS system of Chrome. In theory it could be possible, but I haven't found a single extension what could do it.
you need to press F5 or ctrl+F5..
ctrl + f5 is a force refresh, should remove cache from chrome's little self-cache thingy.