Ngrok not passing my post request on to localhost

人走茶凉 提交于 2019-12-07 06:47:37

问题


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

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.

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?


回答1:


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



回答2:


Bit late to the party :) I could get http working by un-checking Enable SSL flag in Properties.

Step 1: Right click Web Api project, select Properties

Step 2: Download and install extension

https://marketplace.visualstudio.com/items?itemName=DavidProthero.NgrokExtensions

Step 3: Start ngrok Tunnel from Visual Studio

(image from https://raw.githubusercontent.com/dprothero/NgrokExtensions/master/docs/img/menu-item.png)

Step 4: Copy Forwarding http url

Step 5: Paste in Postman, and append the controller/action

you get 200! (upvotes? :))



来源:https://stackoverflow.com/questions/46947548/ngrok-not-passing-my-post-request-on-to-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!