Using ngrok to get a public HTTPS address for a local server already serving HTTPS (for free)

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.

ERROR: Tunnel 'command_line' specifies invalid address 'http://localhost:4200' too many colons in address
Advertisement

3 thoughts on “Using ngrok to get a public HTTPS address for a local server already serving HTTPS (for free)

Add yours

  1. this doesn’t work anymore

    ngrok is saying: “ngrok gateway error: The server returned an invalid or incomplete HTTP response.”

    Like

  2. Doesn’t seem to work for microsoft powerpoint add-ins etc – might still list as unsafe site, even with https?

    Like

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 )

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: