IISExpress with tunneling tool: The request hostname is invalid - asp.net

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

Related

Cannot send request from Postman via my IP

Strange thing - I have host API on localhost it works proper (via browser). It's a part of bigger project.
I use Postman for testing endpoints, and when I make request via localhost or 127:
-https://localhost:7257/esp32
-https://127.0.0.1:7257/esp32
Postman gives me Status 200 OK and fine data from API, but if I send request via my IP adress:
-https://192.168.8.xxx:7257/esp32 then I see error like this: Error: connect ECONNREFUSED 192.168.8.xxx:7257
What does it cause? Is it correct or no?
Ok, I need to host my application on the outside.

Https communication on localhost in IIS using self-signed certificate

I have 2 sites running on the same machine, a client and an API.
Let's say the computer's IP is 10.10.10.10.
The API has a default page when you browse to it, the rest of the API is under 10.10.10.10/api.
The API has HTTP binding to port 80, and HTTPS binding to port 443.
The client has HTTP binding to port 8080, and HTTPS binding to port 64300.
Both HTTPS bindings use a self signed certificate I created via IIS manager.
Both sites have a HTTP to HTTPS redirect using "URL Rewrite".
When I try to browse either one of the apps, it works fine (gives the warning in the browser that you can skip).
When I do some action in the client which involves a HTTP request to the api using one of the following calls I get an error:
http://localhost/api/someMethod
http://localhost:80/api/someMethod
https://localhost/api/someMethod
https://localhost:443/api/someMethod
https://10.10.10.10/api/someMethod
The exception includes this error:
"The remote certificate is invalid according to the validation procedure"
I tried using the method described in this link (add the self-signed certificate to the Trusted Root Certificate Authorities folder) but it won't work.
Help please :D
found the answer.. posting if anyone else will get stuck on it.
It's pretty weird but the only thing that worked was to make the localhost http(s) request using the HOST NAME.
example:
https://the_name_of_the_computer:443/api/someMethod

Logstash http input plugin - Connection Refused

Using Logstash 1.5.4 version. Http input plugin connecting to localhost with port 2099.
Tomcat is web application server. Ouput gets indexed to Elasticsearch.
Error scenario:
When Tomcat is up and logstash is down and provide a hit to localhost:2199 with a message to be indexed into ES from my application, getting connection refused error.
Question: How to verify if the localhost:2199 is already up before sending events via HTTP POST method to logstash input?
Can this verification be done with configuration change?
The http input plugin will, when running, listen to the defined port and accept events that way. If it's not running, it's up to whatever is sending data to retry/buffer/etc. What you've described is not a logstash problem.

accessing port 8443 with http in tomcat

I have a Tomcat 6.x or 7.x web application server running on a webserver listening on port 8443.
Why is it that when I access http://:8443, I am
prompted to download a file of the format application/octet-stream from any browser from any platform?
When I access http://:443 I get a 400 Bad Request.
Is there anyway to configure Tomcat to yield a 400 Bad Request error code if a user attempts to access the SSL port via http ?
It's because you need to type https:// beforehand :D I just had the same problem!
I think some forwarding is needed to ensure https is used.

Why when using SSL and Port 443 only am I getting a Socket Refused Error on Port 80?

I have a ASP.NET MVC site set up in IIS7 on Win2K8 with a single SSL binding on Port 443. The team in charge of the server only has port 443 open for security reasons, but this shouldn't be any issue because that's the only binding I have and I'm not making any regular HTTP calls on port 80.
When I call my site, my main login page (using forms authentication) comes up in the browser (over HTTPS) which looks fine. However, as soon as I try to login I get the following error:
[SocketException (0x274d): No connection could be made because the target machine actively refused it 10.x.123.123:80]
Ok that is the correct IP assigned to the site, but I'm not making any calls on port 80. Why would I get this error if all I need is a SSL binding on port 443? Am I required to have port 80 open as well? I'm not making any calls internally that use port 80, unless MVC is doing something I'm unaware of that requires port 80.
When digging into the code it turns out that our service turned around and made additional REST calls to other parts of the same service using a HTTP url, thus causing the error.
Since I configured IIS to only allow SSL traffic and I had internal calls to a HTTP URL the error was generated. The root cause was that I forgot we were making RESTful calls within the code and those URLs had to be updated to their respective HTTPS counterpart.

Resources