Handy dandy tool for sharing Sitecore instances

Often while working on projects, a team member may ask you to share your local Sitecore instance with them. Or you might even want to expose your local site to an external service for performance testing/analysis. There is a handy dandy tool that makes this really easy, ngrok. Using secure tunnels ngrok exposes local sites behind NATs and firewalls to the public internet. By connecting to the ngrok cloud service which accepts traffic on a public address and relays that traffic through to the ngrok process running on your machine and then on to the local address you specify.

There are various plans available including a free plan which supports:

  • HTTP/TCP tunnels on random URLs/ports
  • 1 online ngrok process
  • 4 tunnels/ngrok process
  • 40 connections / minute

localsitecore

Getting started

  1. Sign up for a free account.
  2. Download and run ngrok.exe.
  3. You must specify your authtoken to ngrok so that your client is tied to this account. Login to your account and grab your authtoken from the dashboard then run the following command: ngrok authtoken [your authtoken] This is saved in ~/.ngrok2/ngrok.yml so that you don’t need to repeat this step.
  4. When forwarding to a local port, ngrok does not modify the tunneled HTTP requests at all, they are copied to your server byte-for-byte as they are received. However, ngrok can rewrite your requests with a modified Host header. Use the -host-header switch to rewrite incoming HTTP requests, for example the following command will tunnel to my local Sitecore sandbox instance: ngrok http -host-header=rewrite http://sandbox.sitecore.local:80
  5. ngrok will assign you a unique public address while it is running:

ngrok

Some Cool Features

  • Inspect Traffic – ngrok provides a real-time web UI where you can introspect all of the HTTP traffic running over your tunnels. After you’ve started ngrok, just open http://localhost:4040 in a web browser to inspect request details.ngrok_inspect
  • Replay Requests – ngrok allows you to replay any request with a single click dramatically speeding up your iteration cycle. Click the Replay button at the top-right corner of any request on the web inspection UI to replay it.
  • Status Page – ngrok’s local web interface has a dedicated status page that shows configuration and metrics information about the running ngrok process. You can access it at http://localhost:4040/status.ngrok_status
  • Password protect tunnel – You can make your tunnels secure with the -auth switch. This enforces HTTP Basic Auth on all requests with the username and password you specify as an argument.
  • Serve local directories – Often our front end developers will work on static HTML templates on their file system. Well, ngrok has a built-in file server so you can serve local file system directories. So they could easily share these if they had a need to.

Additional Info

 

Happy sharing!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s