The scenario here is that you’ve got a local web server already serving up a web application over https. You want to be able to access the web application from another machine/device hence you are using ngrok to provide a public URL. By default ngrok assumes that your local web server is just serving http and goes ahead and provides you with a public URL that supports both http and https tunneling through to your local web server. This is really cool, but what happens when you are already serving up https? The https URL that ngrok provides doesn’t work 🙁.
I’m happy to say that the free offering of ngrok now has this capability and it’s super simple to get working!
Let’s say I have a local web server running on port 4200 and it’s already setup with SSL certificate (and so only works when accessing via a https URL).
Instead of starting ngrok with the default command line of:
ngrok http 4200
Use this command line instead:
ngrok http https://localhost:4200
If your local web server is picky about host headers, then you can also map this through by starting ngrok with this command line:
ngrok http https://localhost:4200 -host-header="localhost:4200"
If you encounter the following error it may be because your version of ngrok is too old and doesn’t support this recent capability. Simply go grab the latest version and try again.