Easy URL Forwarding to Localhost Using Ngrok
URL forwarding to your local dev server be incredibly helpful in several situations:
- Developing a 3rd Party integration that needs to point to your local server and test it prior to a stage deploy
- Quick and dirty demos of WIP features to get user feedback
The best part about URL forwarding its super easy to setup. I use ngrok
to create a tunnel from localhost to a public IP address. More information on getting started with ngrok here. To setup URL forwarding to your local dev server do the following:
Step 1: Download ngrok. For a Rails app, I'll save this file to the local bin
directory for that app.
Step 2: Start an ngrok http server, specifying the port to your local server port. In this case, I'm using a Rails app so it would be:
bin/ngrok http 3000
If successful, you should see an interface that looks like this:
Step 3: Once the Tunnel Status is "online", the public URL http://66272bf3.ngrok.io
will forward to your local server. Test that it works by testing this URL with a mobile browser or another computer.
That's it! Super simple.
Addendum: we are using the free version of ngrok, so the URL generated is a random subdomain and will change each time you run the service.