WebServer listen on SSL and all addresses - asp.net

I'm implementing a signalR self-hosted service using asp.net OWIN.
My server initialization looks something like this-
string url = "https://*:443";
WebApplication.Start<MyConfigurations>(url);
and on the client side-
var hubUrl = 'https://1.mydomain.com:443';
connection = $.hubConnection(hubUrl);
On the client side, I'm getting a 404 error while negotiating connection to signalR.
If I change the url on the server side to string url = "https://mydomain.com:443";, it works fine.
how do I configure the WebApplication to listen to all requests arriving to the server on port 443 (or any other port, using SSL), regardless of the URL that the client used?

Are you sure nothing else is registered to listen on 443? 'Cause * is a "weak" wildcard and if something else is listening on that port using a "stronger" URL registration than that it would explain why it does not work.
So, first, try https://+:443 and see if that works or even specify a base path like https://+:443/SignalRTest. That's the strongest possible form of wildcard. If you're still having issues, I'd check to make sure there are no other registrations for 443 with something like:
netsh http show urlacl

Related

Redirect from localhost to external url

I want to redirect a local port door to a website. So that when I access https://localhost:8080 it actually loads (or redirects) https://www.facebook.com, or something like that.
I'm on a windows machine. I already tried changing the file C:\Windows\System32\drivers\etc\hosts but it did not work.
I only found solutions of the other way around. Does anyone know how to do this?
Thanks in advance!
You can use a reverse proxy to implement this feature. The data flow would look like:
Browser -> localhost:8080 -> proxy server that listen port 8080 on localhost -> proxy server sends request to example.com -> proxy server receives response from example.com and return to browser -> Browser
This reverse proxy can be programmed manually, or by using HTTP proxy software, such as Charles:

Nginx as TCP forward proxy

I know I could use some like this:
stream {
upstream ssh {
server X.X.X.X:22;
}
server {
listen 2222;
proxy_pass ssh;
}
}
to proxy pass incoming traffic to port 2222 to another IP's port 22.
Straightforward. But, is there a way to create a dynamic proxy that accepts final destination's hostname and port as parameters?
Something that could be used like this:
proxy_hostname:8080?destination_hostname=example.com&destination_port=1111
ngx_stream_core_module does not accept url parameters. Could nginx be used as a dymanic proxy or only for static tunneling?
I'm asking this because I need a way to hide the IP of a machine firing php mysql requests.
mysqli_connect($hostname, ...)
right now I cannot specify a proxy for the php script alone, only for the entire machine.
Maybe with a small script and fcgiwrap:
https://www.nginx.com/resources/wiki/start/topics/examples/fcgiwrap/
fcgiwrap calls a bash script where you can convert the URI to the program you want to call (mysql) and return the output to nginx as web content.
You could also alter the config of nginx and reload the service. This way you could "dynamicly" open/forward ports. Quite insecure if you make it publicly available.

how to connect nginx, 3scale and opendaylight controller?

I am using an Ubuntu machine with an Ubuntu guest OS. On the guest OS, I ran my OpenDaylight controller, making the topologies with Mininet and viewing them in the OpenDaylight GUI at localhost:8080. Next, I used Postman REST API Client extension on my Chrome Browser to make a GET request to my ODL Controller:
localhost:8080/restconf/operational/opendaylight-inventory:nodes/
I got the proper response to it in XML format. Now, I have to pass my request through NGINX proxy to 3Scale and get authentication using the app_id and app_key parameters. The request is then to be forwarded to the ODL controller so that I gan get the proper response.
I have already downloaded the proxy config files from NGINX. What modifications must be made in these files? What should be the request I enter in the Postman Client to get the same response as before?
You should only need to change the location of the nginx_.lua file in nginx_.conf
If you want to change the port that Nginx listens on, you will also need to change the listen directive in the server block, to your desired port e.g
server {
lua_code_cache off;
listen 81;
Also, you will need to ensure that there is an upstream block for your backend, e.g
upstream backend_localhost {
server localhost:8080 max_fails=5 fail_timeout=30;
}
but if you have entered this in the proxy configuration wizard that should already be there.
That should be all that you need to change/check.
The request in Postman should target Nginx instead of the ODL Controller, and pass in the application credentials e.g if Nginx is running on port 81
localhost:81/restconf/operational/opendaylight-inventory:nodes/?app_id=<YOUR_APP_ID>&app_key=<YOUR_APP_KEY>
Hopefully that should clear up any doubts. However, you can always email us at support#3scale.net if you have any further questions or add any comments here.

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.

How can i debug HTTP sessions using Fiddler, just like i did with TcpTrace?

Im trying to stop using TcpTrace and start working with Fiddler.
But i just can't setup fiddler to just start listening specified port and redirect all requests to the specified WS with another port.
All i want is just redirect and monitor all traffic from localhost:4747 -> webservice-ip:10000
Is there any solution for my problem ?
Thanks in advance.
Set Fiddler to listen on port 4747, and then edit your CustomRules.js (menu->Rules->Customize Rules). Putting something like this into the OnBeforeRequest method should help:
if (oSession.host=="localhost:4747") {
oSession.host="external:1000";
}
if you want all traffic passing through Fiddler to go to the external host, you can simply use
oSession.host="external:1000";
(where external is the hostname of the external host)

Resources