Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ngrok not passing my post request on to localhost

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?

like image 730
user1186050 Avatar asked Oct 26 '17 06:10

user1186050


People also ask

Why is Ngrok not working?

When an Ngrok connection reaches this length it stops working, and the only way to restore it is by stopping and restarting the ngrok command, which causes a new randomly generated URL to be used. You can always check the Ngrok output to see when a connection is due to expire.

How do I whitelist Ngrok server?

You can manage the IP whitelist on the auth tab of your ngrok dashboard. Enter a new IP address under the "IP Whitelist" section and then click Add Whitelist Entry. Changes to the IP Whitelist can take up to 30 seconds to take effect. Sometimes, you may wish to whitelist an entire range of IPs.


1 Answers

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
like image 196
Joshua Duxbury Avatar answered Sep 20 '22 15:09

Joshua Duxbury