Ngrok: How to actually tunnel to https://localhost?

Created on 21 Mar 2018  Â·  12Comments  Â·  Source: inconshreveable/ngrok

I upgraded my account, attempted tls and tcp tunnels - nothing has worked.

Creating these types of tunnels is billed in other threads as the only way to tunnel to https://localhost (I need testing with the green check for Stripe PaymentRequest setup); but the URLs ngrok gives me when I use these protocols are not usable in a browser (e.g. tls://...)

How can I use a browser to tunnel to https://localhost:xxx domains? It appears this must be possible given these threads:

https://github.com/inconshreveable/ngrok/issues/194 https://github.com/inconshreveable/ngrok/issues/123

Thanks!

Most helpful comment

This would be really nice to have. I'm trying to test the autocert code I've been writing, and it'd be nice if I could use ngrok to tunnel tcp 80 and 443 on the same domain.

All 12 comments

I use ngrok to run a server in local host 3001, using rails servers.
My rails server is running in bash and, in another bash, I run the command "ngrok http 3001"
And it works. Usualy gives me and url like this: https://e83ca07e.ngrok.io
try that, maybe works.
"ngrok http YOURHOSTNUMBER"

@lukewlms did you ever get this figured out? I'm trying to do the same thing.

No :\ got a snarky comment from the dev but not solution.

This would be really nice to have. I'm trying to test the autocert code I've been writing, and it'd be nice if I could use ngrok to tunnel tcp 80 and 443 on the same domain.

This all seems pretty odd. I run Laradock locally and don't even bother setting up nginx to listen on port 80. My sites are not available on anything but https, anywhere, ever. It's 2018 after all. I have no interest in port 80.

Perhaps there's a technical reason why ngrok doesn't appear to support an https localhost? When you access a url such as https://14541v64.ngrok.io, the https cert is supplied by ngrok.io. The traffic is decrypted on their server, and then sent onwards unencrypted to your localhost (albeit encrypted via an SSH tunnel or however they implemented it, I presume).

I wish we could tell ngrok to send our (probably self-signed) certs straight through to the client, and not use their cert at all. Just pass the https-encrypted traffic straight through to our localhost.

@lalo312 — not sure what you're suggesting I should upgrade. I just installed ngrok today, so that would be the latest.

+1, it doesn't seem possible to use a localhost https with ngrok, with the free plan at least 😢

I've gone through other related github issues and tried the suggestions - using IP address, tcp tunnels etc and nothing seems to work. It would be amazing if it did work 😄

Will this opportunity ever work?

This issue can be closed, see this issue

this issue can not be closed. Basically, the problem is ngrok with tls certs can only forward to http, there is no https option when using tls, rather than http. It's bumkis.

the same issue with me, so it solved or not ?

The way to tunnel https on localhost is:

  1. Setup certificates
  2. Make your server include server.crt and server.key in its headers. E.g. using Uvicorn I did
    uvicorn.run("views:app", host="localhost", port=5000, log_level="info", ssl_keyfile='server.key', ssl_certfile='server.crt')
  3. With your server running on e.g. https://localhost:5000 forward your port as described in Local HTTPS Servers:
    ngrok http https://localhost:5000
  4. You should now have an ngrok instance using https all on free plan
Was this page helpful?
0 / 5 - 0 ratings

Related issues

megapctr picture megapctr  Â·  4Comments

wujunze picture wujunze  Â·  9Comments

shubhamk1997 picture shubhamk1997  Â·  5Comments

ricardoasc picture ricardoasc  Â·  5Comments

mindcont picture mindcont  Â·  7Comments