Ngrok not passing my post request on to localhost

user1186050 picture user1186050 · Oct 26, 2017 · Viewed 12.3k times · Source

I'm trying to set up a webhook for Stripe and I've created a controller, according to the Stripe doc , to do it in ASP.Net MVC running in a virtual machine (maybe that changes things?). I've been testing the action in the controller to see if I can receive posts, so I'm using Postman to send my localhost posts requests which are working. But now I need to use Ngrok to give my localhost a url so that Stripe can use it. I'm running ngrok and passing in these parameters to run

ngrok http -host-header="localhost:44368" 44368

and here is what I see, everything looks ok

enter image description here

But now when I try and use it in Postaman

ex https://11d1ba97.ngrok.io/StripeWebHook/Index

I get a 502 Bad Gateway message and the action method never gets hit.

I get the same problem when I try and send a test webhook from Stripe. FYI - The request times from Ngrok using 'localhost:4040' show all my response times as 0ms.

enter image description here

Update - I was emailed by ngrok "The trouble is the HTTPS. ngrok terminates HTTPS traffic and then forwards the unencrypted http traffic through to your local application. You want to do one of two things:

1) make your application expose an HTTP port as well and forward traffic to that 2) use ngrok's TLS tunnels (which hand of TLS traffic to you for termination). with this option you have all the complexities of doing cert management, cert mismatches, etc, just fyi. i'd recommend #1 if possible"

Question - anyone know how to open up a http port in a ASP.Net MVC app using Https?

Answer

Joshua Duxbury picture Joshua Duxbury · Apr 25, 2018

My problem was that the breakpoint in my application wasn't getting hit.

I was using

ngrok http 58533

but changing it to the following allowed my breakpoint to get hit.

ngrok http -host-header=rewrite localhost:58533