Run a local Sourcegraph instance behind ngrok

Sometimes it's useful to have the Sourcegraph instance you're running on your local machine to be reachable over the internet. If you're testing webhooks, for example, where a code host needs to be able to send requests to your instances.

One way to do that is to use ngrok, a reverse proxy that allows you to expose your instance to the internet.

  1. Install ngrok: brew install ngrok
  2. Authenticate the ngrok if this is your first time running it (the token can be obtained from Ngrok dashboard): ngrok config add-authtoken <Your token>
  3. Start your Sourcegraph instance: sg start
  4. Start ngrok and point it at Sourcegraph: ngrok http --host-header=rewrite 3080
  5. Copy the Forwarding URL ngrok displays. e.g.: https://630b-87-170-68-206.eu.ngrok.io
  6. Edit your site-config (i.e. ../dev-private/enterprise/dev/site-config.json) and update the "externalURL" to point to your ngrok: "externalURL": "https://630b-87-170-68-206.eu.ngrok.io"
  7. Open the ngrok URL in browser to make sure you see your instance
  8. Done