hashbangcode / vlad

Vlad - Vagrant LAMP Ansible Drupal
173 stars 53 forks source link

Accessing Vlad VM from another VM on same host system #287

Closed dixhuit closed 8 years ago

dixhuit commented 9 years ago

IE testing using VMs is probably the nicest way to go about it today (it's still horrid, this is all relative). Microsoft make this easier these days thanks to the VMs available at Modern IE. VirtualBox also seems to come with its own "smart" networking out of the box in that you can access a page served from one guest VM via another guest VM if they're both on the same host.

Regarding that last point, the closest I can get with Vlad is to type in the IP address of the Vlad VM (as a browser URL from the Windows VM), doing so will load the Vlad VM's Adminer subdomain by default (not much help). Is there something we can do to improve this?

philipnorton42 commented 8 years ago

So when you access a Vlad box via the IP address you will almost always get the adminer subdomain. Why? Basically because Apache doesn't know what the address is for it will serve the first site it has in it's alphabetically sorted list of virtual hosts. Which happens to be adminer (unless you've called your site aardvark.local or something). For this reason it's best to call Apache with the correct DNS address.

So a couple of solutions come to mind. 1) Alter the hosts file on the other VMs so that you can reference the correct site with the correct name. 2) Use something like Charles Proxy (http://www.charlesproxy.com/) to create a middleman between your test VM and the Vlad VM. This might need some configuration/tweaking, but I think it should work. 3) Vagrant share.

dixhuit commented 8 years ago

I thought it might be to do with alphabetical defaults. Thanks for the info, I will look into this further!

philipnorton42 commented 8 years ago

You could always run sudo a2dissite adminer.local.conf to turn off the adminer sub domain.

dixhuit commented 8 years ago

That's a good idea.

dixhuit commented 8 years ago

If adminer is not installed, the sub domain is not created right?

philipnorton42 commented 8 years ago

True :)

dixhuit commented 8 years ago

OK, cool. More options :)

iAugur commented 8 years ago

FWIW - the 'common' approach here is to rename the default vhost conf file to 000-default.conf - that way it is the first in the list and serves up the default site for the ip address with no host header. I also typically create a default holding page (one page) to use in place of the standard - 'It Works' page.

dixhuit commented 8 years ago

That sounds even better :)

philipnorton42 commented 8 years ago

Good point @iAugur. This is also a good way of "catching" traffic that hits the Apache server via the IP address which you can redirect to a domain name of some sort.

thom8 commented 8 years ago

Vagrant share is another option -- https://www.vagrantup.com/docs/share/

Also good for mobile testing.

dixhuit commented 8 years ago

Yeah, I've used Vagrant Share (also suggested by Phil further up) and it's great but I was particularly interested in something local and not having to mess about with unique generated URLs (there's a lot to be said for having a local site bookmarked in a number of different browsers/devices when testing).

Anyways, I recently committed https://github.com/hashbangcode/vlad/commit/0ec9603b77d5457885eb0db7195b02069028ce0f which fixes this particular issue.