» HTTP Sharing

Vagrant Share can create a publicly accessible URL endpoint to access anHTTP server running in your Vagrant environment. This is known as "HTTPsharing," and is enabled by default when vagrant share is used.

Because this mode of sharing creates a publicly accessible URL, the accessingparty does not need to have Vagrant installed in order to view your environment.

This has a number of useful use cases: you can test webhooks by exposingyour Vagrant environment to the internet, you can show your work to clients,teammates, or managers, etc.

» Usage

To use HTTP sharing, simply run vagrant share:

  1. $ vagrant share
  2. ==> default: Detecting network information for machine...
  3. default: Local machine address: 192.168.84.130
  4. default: Local HTTP port: 9999
  5. default: Local HTTPS port: disabled
  6. ==> default: Creating Vagrant Share session...
  7. ==> default: HTTP URL: http://b1fb1f3f.ngrok.io

Vagrant detects where your HTTP server is running in your Vagrant environmentand outputs the endpoint that can be used to access this share. Just givethis URL to anyone you want to share it with, and they will be able to accessyour Vagrant environment!

If Vagrant has trouble detecting the port of your servers in your environment,use the —http and/or —https flags to be more explicit.

The share will be accessible for the duration that vagrant share is running.Press Ctrl-C to quit the sharing session.

Warning: This URL is accessible by _anyone_who knows it, so be careful if you are sharing sensitive information.

» Disabling

If you want to disable the creation of the publicly accessible endpoint,run vagrant share with the —disable-http flag. This will share yourenvironment using one of the other methods available, and will not createthe URL endpoint.

» Missing Assets

Shared web applications must use relative paths for loading anylocal assets such as images, stylesheets, javascript.

The web application under development will be accessed remotely. This meansthat if you have any hardcoded asset (images, stylesheets, etc.) URLssuch as <img src="http://127.0.0.1/header.png"&gt;, then they will not loadfor people accessing your share.

Most web frameworks or toolkits have settings or helpers to generaterelative paths. For example, if you are a WordPress developer, theRoot Relative URLs pluginwill automatically do this for you.

Relative URLs to assets is generally a best practice in general, so youshould do this anyways!

» HTTPS (SSL)

Vagrant Share can also expose an SSL port that can be accessed overSSL. Creating an HTTPS share requires a non-free ngrok account.

vagrant share by default looks for any SSL traffic on port 443 in yourdevelopment environment. If it cannot find any, then SSL is disabled bydefault.

The HTTPS share can be explicitly disabled using the —disable-https flag.