2014-02-27 23:00:37 +00:00
|
|
|
---
|
2016-01-19 18:08:53 +00:00
|
|
|
layout: "docs"
|
2014-02-27 23:00:37 +00:00
|
|
|
page_title: "HTTP Sharing - Vagrant Share"
|
|
|
|
sidebar_current: "share-http"
|
2016-01-19 18:08:53 +00:00
|
|
|
description: |-
|
|
|
|
Vagrant Share can create a publicly accessible URL endpoint to access an
|
|
|
|
HTTP server running in your Vagrant environment. This is known as "HTTP
|
|
|
|
sharing," and is enabled by default when "vagrant share" is used.
|
2014-02-27 23:00:37 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# HTTP Sharing
|
|
|
|
|
|
|
|
Vagrant Share can create a publicly accessible URL endpoint to access an
|
|
|
|
HTTP server running in your Vagrant environment. This is known as "HTTP
|
|
|
|
sharing," and is enabled by default when `vagrant share` is used.
|
|
|
|
|
|
|
|
Because this mode of sharing creates a publicly accessible URL, the accessing
|
|
|
|
party does not need to have Vagrant installed in order to view your environment.
|
|
|
|
|
2014-10-13 14:03:57 +00:00
|
|
|
This has a number of useful use cases: you can test webhooks by exposing
|
2014-02-27 23:00:37 +00:00
|
|
|
your 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`:
|
|
|
|
|
|
|
|
```
|
2014-03-07 17:54:46 +00:00
|
|
|
$ vagrant share
|
|
|
|
==> default: Detecting network information for machine...
|
2017-05-22 16:42:31 +00:00
|
|
|
default: Local machine address: 192.168.84.130
|
|
|
|
default: Local HTTP port: 9999
|
|
|
|
default: Local HTTPS port: disabled
|
2014-03-07 17:54:46 +00:00
|
|
|
==> default: Creating Vagrant Share session...
|
2017-05-22 16:42:31 +00:00
|
|
|
==> default: HTTP URL: http://b1fb1f3f.ngrok.io
|
2014-02-27 23:00:37 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Vagrant detects where your HTTP server is running in your Vagrant environment
|
|
|
|
and outputs the endpoint that can be used to access this share. Just give
|
2016-01-19 18:08:53 +00:00
|
|
|
this URL to anyone you want to share it with, and they will be able to access
|
2014-02-27 23:00:37 +00:00
|
|
|
your 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.
|
|
|
|
|
2016-01-19 18:08:53 +00:00
|
|
|
<div class="alert alert-warning">
|
|
|
|
<strong>Warning:</strong> This URL is accessible by <em>anyone</em>
|
|
|
|
who knows it, so be careful if you are sharing sensitive information.
|
2014-02-27 23:00:37 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
## Disabling
|
|
|
|
|
|
|
|
If you want to disable the creation of the publicly accessible endpoint,
|
|
|
|
run `vagrant share` with the `--disable-http` flag. This will share your
|
|
|
|
environment using one of the other methods available, and will not create
|
|
|
|
the URL endpoint.
|
2014-03-07 17:54:46 +00:00
|
|
|
|
|
|
|
## Missing Assets
|
|
|
|
|
|
|
|
Shared web applications must use **relative paths** for loading any
|
|
|
|
local assets such as images, stylesheets, javascript.
|
|
|
|
|
|
|
|
The web application under development will be accessed remotely. This means
|
|
|
|
that if you have any hardcoded asset (images, stylesheets, etc.) URLs
|
2016-01-19 18:08:53 +00:00
|
|
|
such as `<img src="http://127.0.0.1/header.png">`, then they will not load
|
2014-03-07 17:54:46 +00:00
|
|
|
for people accessing your share.
|
|
|
|
|
|
|
|
Most web frameworks or toolkits have settings or helpers to generate
|
2016-01-19 18:08:53 +00:00
|
|
|
relative paths. For example, if you are a WordPress developer, the
|
2014-03-07 17:54:46 +00:00
|
|
|
[Root Relative URLs](http://wordpress.org/plugins/root-relative-urls/) plugin
|
|
|
|
will automatically do this for you.
|
|
|
|
|
|
|
|
Relative URLs to assets is generally a best practice in general, so you
|
|
|
|
should do this anyways!
|
2014-05-08 20:25:39 +00:00
|
|
|
|
|
|
|
## HTTPS (SSL)
|
|
|
|
|
|
|
|
Vagrant Share can also expose an SSL port that can be accessed over
|
2017-05-22 16:42:31 +00:00
|
|
|
SSL. Creating an HTTPS share requires a non-free ngrok account.
|
2014-05-08 20:25:39 +00:00
|
|
|
|
|
|
|
`vagrant share` by default looks for any SSL traffic on port 443 in your
|
2016-01-19 18:08:53 +00:00
|
|
|
development environment. If it cannot find any, then SSL is disabled by
|
2014-05-08 20:25:39 +00:00
|
|
|
default.
|
|
|
|
|
2017-05-22 16:42:31 +00:00
|
|
|
The HTTPS share can be explicitly disabled using the `--disable-https` flag.
|