IIS not connecting to remote databases - asp.net-mvc

System.ComponentModel.Win32Exception: The network path was not found
This is the error I am getting trying to visit my AWS deployed ASP MVC website. The connection string works with another shared host that I use, so I have a strong feeling that something within my AWS instance of SQL Server 2012 is blocking the connection.
I am new to AWS and IIS. Is there any sort of firewall that I need to be opening up?

The solution was adding an outgoing MS SQL rule to my security group.

Related

How do I connect an Ado.Net client to my NuoDB on Linux Docker

I created the 3 necessary containers for NuoDB using the NuoDB instructions.
My Docker environment runs on a virtual Ubuntu Linux environment (VMware).
Afterwards I tried to access the database using a console application (C# .Net Framework 4.8) and the Ado.Net technology. For this I used the Nuget "NuoDb.Data.Client" from Nuget.org.
Unfortunately the connection does not work.
If I choose port 8888, my thread disappears to infinity when I open the connection.
For this reason I tried to open the port 48004 to get to the admin container.
On this way I get an error message.
"System.IO.IOException: A connection attempt failed because the remote peer did not respond properly after a certain period of time, or the established connection was faulty because the connected host did not respond 172.18.0.4:48006, 172.18.0.4"
Interestingly, if I specify a wrong database name, it throws an error:
No suitable transaction engine found for database.
This tells me that it connects to the admin container.
Does anyone have any idea what I am doing wrong?
The connection works when I establish a connection with the tool "dbvisualizer".
This tool accesses the transaction engine directly. For this reason I have opened the port 48006 in the corresponding container.
But even with these settings it does not work with my console application.
Thanks in advance.
Port 8888 is the REST port that you would use from the administration tool such as nuocmd: it allows you to start/stop engines and perform other administrative commands. You would not use this port for SQL clients (as you discovered). The correct port to use for SQL clients is 48004.
Port 48004 allows a SQL client to connect to a "load balancer" facility that will redirect it to one of the running TEs. It's not the case that the SQL traffic is routed through this load balancer: instead, the load balancer replies to the client with the address/port of one of the TEs then the client will disconnect from the load balancer and re-connect directly to the TE at that address/port. For this reason, all the ports that TEs are listening on must also be open to the client, not just 48004.
You did suggest you opened these ports but it's not clear from your post whether you followed all the instructions on the doc page you listed. In particular, were you able to connect to the database using the nuosql command line tool as described here? I strongly recommend that you ensure that simple access like this works correctly, before you attempt to try more sophisticated client access such as using Ado.Net.

Accessing local https site over LAN

I am trying to debug my ASP.Net MVC website when hosted over https. I am hosting this via the IIS instance with Visual Studio. I need to access the website from a mobile device - so I am attempting to access the site via LAN.
I have enabled https via visual studio by going to the project properties and setting SSL Enabled to true. Now, when I debug the site, it starts two local instances; one for http (as usual) and one for https. The internal ports for these are listed when I right click the IIS icon in the task tray.
I do not have an SSL certificate installed. My browser gives me insecure connection warnings, but I just dismiss them - I don't believe these are a concern as I am just testing locally (I could be wrong).
I am using a program called Sharp Proxy to translate these internal ports to external ones, allowing my site to be accessible. 64312 is my internal port for accessing the site over http. Sharp proxy is translating this to 4567. 44300 is my internal port for accessing the site over https. Sharp proxy is translating this to 5678.
Successful permutations:
http://localhost:64312 - SUCCESS
https://localhost:44300 - SUCCESS
http://192.168.0.72:4567 - SUCCESS
Failed permutations:
https://192.168.0.72:5678 - FAIL
Bad Request - Invalid Hostname
The issue is clearly not to do with accessing my machine over LAN as I am able to successfully hit 192.168.0.72 with http.
My question is: What do I need to do to be able to access my https site over LAN via debugging with Visual Studio?
In order to verify the identity of the server you're connecting to, HTTPS needs a hostname to check the certificate against.
Therefore, you cannot connect to an IP address over HTTPS.
You need to use a domain name.

"getaddrinfo: Temporary failure in name resolution" in RoR application

I'm trying to retrieve emails from gmail using pop3 to my rails applicaiton. I get the error - "getaddrinfo: Temporary failure in name resolution" when i try to retrieve the email.
the weird thing is, it works when i try it at home but not at my university. i'm guessing it has something to do with the internet connection.
please help!
I had the same problem just started getting this error out of the blue in a RoR application that connects to an API using a RestClient running on a local virtual machine using Vagrant that I have as a development environment.
The only thing that fixed the issue was simply restarting my virtual machine. Just done a vagrant down & up command, then rackup and back in the game.
This generally means you aren't getting a response from DNS. Your university connection is probably behind a proxy preventing you from directly accessing the Internet. If so, this proxy must be specified in your code. Check your POP3 library documentation, or failing that, you may be able to use a library like socksify that redirects TCP connections through your SOCKS proxy.
Simple. You may be directed through a proxy server. Set up a new connection ,set up your college settings,restart your server and it should work.
ssh into your server and check if the machine is able to resolve the domain.
ping <your_site> should resolve the domain name to IP.
If its not resolving correctly, then there is some problem in your hosting service.
quick fix: You can manually map domain-to-ip in the etc/hosts file of your server.

Advice regarding website security

We have just finished developing a new website for my company using the .NET MVC framework. The sql server supporting our application holds some critical data such as the profiles of other web users and we would like to make sure this data is never leaked due to a reputational risk to the company.
We have a number of ideas on things to do to secure our website but I would like to get the stackoverflow take on them. We will be using SSL for login screens and we prevent against basic attach methods such as sql injection, cross site scripting attacks.
However we are worried about the physical machine being taken over using some exploit. We will be running the webserver (Windows Server 2008 SP2 with IIS7) in a DMZ with only port 80 and 443 open to the internet. Currently the sql server sits on the webserver machine but we are considering if this is a security risk. Would hosting the sql server in a machine in a second DMZ help in security?
We also considered using an Ubuntu box running Apache with mod_proxy in one DMZ that will be "redirecting" the 80 or 443 requests to separate windows machine in a second DMZ that will do the web serving and sql server hosting.
Some other suggestions we are getting is to use a product such as WatchGuard that can apparently filter the http packets for standards compliance thus blocking dodgy packets from reaching the webserver.
What other things should we be looking to secure?
Thanks
Allowing only 80 and 443 is a very good idea. DMZ stands for Demilitarized Zone, this is to define a machine on a NAT that is accessible by all traffic and this should be avoided. Allowing SQL Server and port 445 will get you hacked, after all you are running windows and its only a matter of time before yet another RPC vulnerability comes out.
The most important thing you must do is TEST YOUR SECURITY. Its not enough to say that you are preventing xss and sql injection. All secuirty systems must be proven that they can stop attacks.
How do you test your system? I like Acunetix but it is over priced, however there is a free xss tester. For SQL Injection and other vulnerabilities i recommend using Wapiti which is free. I recommend using OpenVAS which is the new open source version of Nessus which is now a commercial product. OpenVAS will tell you if your server is misconfigured or if you are running old software. You should do a full port scan of the system to test your firewall, this command will work nmap -sT -p 1-65535 domain.com, this can also be done form OpenVas.
After testing your system. Then install a Web Application Firewall, mod_secuirty is a good choice for Apache, you can use a reverse proxy to get mod_security to work with IIS. Aqtronix is an open source WAF built for IIS, but i haven't used it.
1- Critical data must be encrypted in your tables.
2- Take care from all types of SQL Injections.
3- encrypt the connection string in web.config file

Application Unable To Connect to SQL Server 2008

I've been running an ASP.NET MVC application on my IIS 7.5 localhost (on my Win7 Pro box) server with SQL Server 2005 Developer Edition.
I went to put the application on my production server (IIS 7, SQL Server 2008) and am getting SQL Server connection errors. Here is the error I get when I try to browse site root:
A network-related or instance-specific error occurred while
establishing a connection to SQL
Server. The server was not found or
was not accessible. Verify that the
instance name is correct and that SQL
Server is configured to allow remote
connections. (provider: Named Pipes
Provider, error: 40 - Could not open a
connection to SQL Server)
I have triple checked my connection string. My host's connection string was in the format XXX.XX.XX.XX,XXXX. Is it normal to have a comma following the IP Address?
Does anyone have any suggestions for something I may be missing?
Thanks.
Take a look at this resource:
http://www.connectionstrings.com/sql-server-2008
A comma after the IP address indicates the port. It should be 1433 unless you have multiple instances.
First of all, make sure that the Windows Firewall (and any other firewall software) on that machine is configured to allow incoming connections to SQL Server. See here for instructions.
Second, check that the SQL Server Browser service in the database server machine is running. This is not necessary in all the connection scenarios, so you may need to provide more details. For example, are you using default listen ports for your server?

Resources