RousselTMLEARNING

Automation

Sharing a Vagrant environment: ngrok and the vagrant-share plugin

Make an application running in a Vagrant machine accessible to a colleague or a client: port forwarding, ngrok, the vagrant-share plugin, and security precautions.

1. Why share an environment #

Showing without deploying.

Use cases #

  • Have a feature validated by a client or a product manager before deploying it.
  • Debug together on the same environment.
  • Test a webhook (payment, GitHub) that must call a public URL.
Sharing tunnel
The tunnel service receives public requests and relays them through the connection opened from the workstation.

2. With ngrok #

The simplest and best-maintained solution.

Steps #

# Vagrantfile : publier le port 80 de la machine sur le port 8080 de l'hôte
#   config.vm.network "forwarded_port", guest: 80, host: 8080
vagrant up
ngrok config add-authtoken <JETON>           # compte ngrok requis
ngrok http 8080                               # affiche l'URL publique https://…
ngrok http 8080 --basic-auth "demo:MotDePasse-Solide"   # protéger l'accès

Alternatives #

ToolSpecificity
Cloudflare Tunnel (cloudflared)Free, custom domain, access control
Tailscale FunnelExposure from a Tailscale network
Vagrant private network + VPNSharing without public exposure, between team members

3. The vagrant-share plugin #

The historical approach.

Usage #

The vagrant-share plugin adds the vagrant share command that creates the tunnel for you. It relies on ngrok itself.

vagrant plugin install vagrant-share
vagrant share                   # partage HTTP de la machine
vagrant share --ssh             # partage aussi l'accès SSH (à éviter)
vagrant connect --ssh <NOM>     # côté collègue
Common mistake: vagrant-share is no longer actively maintained: prefer running ngrok or cloudflared directly.

Security #

  • Never share SSH publicly, or a machine containing real data.
  • Protect the link (authentication) and close the tunnel as soon as the demo is over.
  • A tunnel URL is public: anyone who knows it can access it.
Good practice: For long-term sharing, deploy a staging environment rather than exposing a development workstation.

Related articles

Vagrant: overview and vocabulary (box, provider, provisioner, Vagrantfile)

The essential notions for following the Vagrant course: what Vagrant is for, the lifecycle of an environment,…

Vagrant multi-machine: deploying a ready-to-use Docker Swarm cluster

Use a single Vagrantfile to build a three-node Docker Swarm cluster (one manager, two workers) with automated…

Vagrant plugins: extending providers, provisioners and commands

Understand Vagrant's plugin system: what a plugin can add (provider, provisioner, command, capability), insta…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!