This tip is for people that would access a Vagrant dev website from another VM (let's say to test another version of Internet Explorer via e.g. https://github.com/xdissent/ievms) or via another device than the host environment (smartphone, tablet, ...).
Vagrant allows you to quickly deploy dev environments on a Virtualbox VM.
xip.io will let you access your dev website from other devices (already tried to patch /etc/hosts on an iPad?)
Basically, there is no problem to access your dev server from xip.io if your Apache is hosted directly on your Mac / PC.
This is something else if you use a VM for the LAMP stack.
Follow these steps to tackle this
- Fetch your local IP (via ifconfig an *nix or ipconfig on Windows), this is needed for xip.io, you should have something like 192.168.X.X on a class C LAN (https://en.wikipedia.org/wiki/Private_network)
- Add the xip.io domain on your Vagrant vm
vagrant sshon the Vagrant directory of your host
sudo nano /etc/apache2/sites-available/localhost.confand search your vhost to add the server alias
- Add a port forwarding on the Vagrantfile by adding this line on the # Configure forwarded ports. section any free port is valid, let's use 4567.
config.vm.network "forwarded_port", guest: 80, host: 4567, protocol: "tcp", auto_correct: true
- Restart vagrant on your host VM directory
vagrant halt vagrant up
Now you can access your dev site from any device, VM with my.local.site.192.168.X.X.xip.io:4567/optional_path