Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FBI23/52a3440f7de22c8a0f7a61eed38a54fc to your computer and use it in GitHub Desktop.
Save FBI23/52a3440f7de22c8a0f7a61eed38a54fc to your computer and use it in GitHub Desktop.
Using Vagrant share with multiple sites

Using Vagrant share with multiple sites

Vagrant share is a great feature that's quite handy to demo your application to clients. It basically allows you to share whatever you run locally on your VM, accessible by anybody who is connected to the internet. However, Vagrant share doesn't support multiple domains pointing to different applications on your virtual machine. Unless you use different ports. This document will teach you how to set your virtual machine up to allow sharing multiple projects with Vagrant share.

Note: This document is primary based on a virtual machine running Apache.

The setup

  1. Create a free account at HashiCorp's Atlas.
  2. Login using vagrant login.
  3. SSH into the virtual machine using vagrant ssh.
  4. Inside /etc/apache2/sites-available/ edit your virtual hosts by changing the port to something else (say :81). Unfortunately Vagrant Share doesn't allow you to use HTTPS, so changing the 443 port is practically useless.
  5. Inside /etc/apache2/ports.conf add Listen 81 right under Listen 80.
  6. Restart the server: sudo service apache2 restart

Sharing

In the terminal on your host machine enter the following:

  1. vagrant share --http 80
  2. vagrant share --http 81

This will create two links for you looking like http://something-random-1234.vagrantshare.com/.

That's it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment