local app using ngrok having issue with http tunnel but not with tcp tunnel - ngrok

I have an app that runs on my localhost port:3000. I am using ngrok to get a public URL. Now when i am using a tcp tunnel as below:
./ngrok tcp 3000
i get the public url as below:
tcp://0.tcp.ngrok.io:14964 -> localhost:3000
I try sending REST post req to https://0.tcp.ngrok.io:14964/ and it works.
But when i try to use an HTTP channel.
./ngrok http --bind-tls "both" -host-header=localhost 3000
i get public URL:
"https://b9076b83.ngrok.io -> localhost:3000"
Now when i try to send the post request to https://b9076b83.ngrok.io/, it doesn't work, i get a 502 error.
What really could be the issue?

Related

How can I let Ngrok provide both https and https tunnels by default for all endpoints?

By default, ngrok only provides https tunnel.
I can specify which tunnel has https or http or both in the config file, but if so, I will have to start this tunnel every time. What I want to do it when I try to run any http port nubmer like ngrok http 5000, ngrok will automatically offers https and http for it.
I have tried
version: "2"
authtoken: faswETNFAW8DSmVuHrOH18s_6pK7iP5
schemes: [http,https]
but got the error.
How can I config the ngrok config file correctly?

Ngrok tunnel https via config

I am having some issues finding how to properly write my ngrok.yml file such that it will start the tunnel using https. What I have at the moment is the following:
tunnels:
invenutory:
proto: http
addr: 44328
host_header: localhost
The issue here is that if I use the url ngrok gives me it does not connect (i test this by seeing if it hits my healthcheck endpoint, it does not). However, if I start ngrok using the following command:
ngrok http https://localhost:44328 -host-header="localhost:44328" then it will properly hit my endpoint. How can I make my config file act the same way?
Edit:
If I set the addr to be addr: "https://localhost:44328" then it does properly use https, but for some reason this seems to me like an incorrect way of doing it.
To start a https only tunnel with a ngrok http tunnel, use the flag -bind-tls.
This is unrelated to how you use addr, which can be used to let ngrok know if your local server is listening for http or https.
From the docs:
ngrok assumes that the server it is forwarding to is listening for unencrypted HTTP traffic, but what if your server is listening for encrypted HTTPS traffic? You can specify a URL with an https:// scheme to request that ngrok speak HTTPS to your local server.
You can add the bind_tls flag to the config file to create only HTTPS tunnels as per the docs
tunnels:
invenutory:
proto: http
addr: 44328
host_header: localhost
bind_tls: true

IISExpress with tunneling tool: The request hostname is invalid

I started a very simple ASP.net web api app. on port 8080.
I used ngrok as a tunneling tool to get a forwarding ip address:
Using postman I posted to the local server with the following request
http://ccf7e40b.ngrok.io/Bot/messages
and get the error: "HTTP Error 400. The request hostname is invalid.". However replacing the forwarding url with localhost:8080 would work.
I have seen several other posts with the same error messages get resolved by adding a binding line in Documents\IISExpress\config\appilcationHost.config to bind to a specific port. However I'm already running on 8080 port.
I'm using Visual Studio 2017.
You have to use modified hostheaders. So in your case, it should work with:
ngrok.exe http -host-header=rewrite localhost:8080

amazon load balancer returns error code 400

We have a load balancer on amazon which balance 4 servers.
When sending specific HTTP request to the load balancer I get Http error code 400.
But when I sends the same request to each one of the servers directly I get Http 200 OK.
Other requests are working fine when using the balancer.
Any Ideas?
Thanks.
Don't know if this will help you, but I've had a similar problem. I was using jMeter and when accessing my instance over AWS load balancer I would always get: HTTP/1.1 400 BAD_REQUEST.
After lot of debugging I found out that I was sending an empty header (no name and no value) because I had an empty row in HTTP Header Manager in jMeter. So, I persume, AWS ELB does some headers checking, and returns HTTP 400, even tough I wasn't having any problems with going with the same request to my instances directly. I don't know if this will help you but you should double-check your headers for some stupid mistake like this one :D
I had a similar problem to this, and it was caused by ALB not accepting HTTP methods that are in lower case.
GET http://myhost.com/foo -> HTTP 200
get http://myhost.com/foo -> HTTP 400
In my case it was the headers issue.
ELB-HealthChecker was sending healthcheck request to my web server and nginx replied with 400.
The issue was that ELB-HealthChecker sends no headers with the request.
Depending on the configuration of your webserver, this might return 400 error code.
To check if this is the case, replicate "no headers" request with curl:
curl -I -H 'User-Agent:' -H 'Accept:' -H 'Host:' http://yourservice/health/
The solution is to configure nginx endpoint that will return 200 regardless of the presence of the request headers:
location = /health/ { return 200; }
In my case my target group for Port 443 was using HTTP protocol instead of HTTPs and I was getting 'Client using HTTP to connect to HTTPS server'

Capturing SOAP message on localhost using Fiddler

I am unable to capture local HTTP traffic when my Java client makes a SOAP request to my local Tomcat instance.
My current configuration is
Tomcat instance - run on localhost:8080
Local Java client - run from Windows cmd line
Fiddler - run on localhost:8888
I used Axis2 wsdl2java to create my client SOAP stub, and used my machines IP address when specifying the WSDL (hosted on Tomcat)
wsdl2java -uri http://192.168.0.5:8080/axis2/services/Version?wsdl -p sample.axisversion -d adb -s
So, the generated code has lines like this throughout:
public VersionStub(org.apache.axis2.context.ConfigurationContext configurationContext) throws org.apache.axis2.AxisFault {
this(configurationContext,"http://192.168.0.5:8080/axis2/services/Version.VersionHttpSoap12Endpoint/" );
}
My client app uses the generated stub and I set the Java proxy to Fiddler using the following code (which gets called before the SOAP stub is actually used):
System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", "localhost");
System.getProperties().put("proxyPort", "8888");
...but still I don't see any request or response traffic in Fiddler. What's missing?
Instead of localhost, try to use ipv4.fiddler, which makes sure your localhost traffic goes through fiddler. See also: http://www.fiddler2.com/Fiddler/Help/hookup.asp#Q-LocalTraffic

Resources