Access website using server name instead of www - asp.net

I am new to IIS, setting up servers and load balancer so please do not mind my ignorance.
I have an old website, say, www.mywebsite.com.
There are 3 IIS 6.1 web servers on which my ASP.NET code is hosted.
Lets call them web01, web02 and web03.
They are identical in configuration like OS, etc.
There is a load balancer which handles the requests coming in from the clients through www and routes it to the respective server based on whatever algorithm is put in place.
However, we were able to send requests directly to individual servers like this web01.mywebsite.com for all 3 servers.
I do not have access to the load balancer.
Recently there were some problems with the web02 server so the client took it out from the load balancer.
We then reinstalled IIS and now, when we are trying to access the server using web02.mywebsite.com, it is throwing 404 - Not Found error.
I am able to open the website from inside the server using www.mywebsite.com and I am able to see that the requests is catered by the web02 server.
However, from inside the server also web02.mywebsite.com is throwing 404 - Not Found error.
I am sure I am missing something in configuration at the IIS level but not able to figure out.
I tried searching on the internet but they all gave me generic solutions.
Please help.
Thanks in advance!

I was able to get this resolved on my own.
Strangely there was not a single answer or comment to this question.
I will try to answer so that others might also benefit.
There were 2 things that were required, out of which 1 was already present in my case:
In the hosts file, the mapping of IP address of the server to the actual name of the server should be present (This was there in my case)
In IIS, under bindings, I removed the host name i.e. www.mywebsite.com.
I was able to figure this through the posts here and here although they did not give the answer directly.
Hope this helps others.

Related

Windows Azure VM SSL and Cloudapp.net

I installed an ASP.net application on a windows Azure VM (IIS 7). SSL certificate is installed, configured and the application works correctly. I have removed Http binding and http endpoints.
The issue I am having is that if I use the cloudapp.net link (using https), the application still opens with a mismatched certificate.
What can I do to deny any user from opening my application using https://xx.cloudapp.net/x?
It seems really silly that people are saying this isn't the right place for this question, since some of the solutions could be code related. ie: In your application, check the host and if it's cloudapp.net, do a URL redirect.
There's a few different options here but it sounds like what you're looking for is just the ability to prevent someone from viewing the application using that URL.
What I would do is set up a site in IIS that uses Host Header resolution to look for xx.cloudapp.net. If that URL is recognized, do a redirect using the HTTP redirect settings to the https version of your app. Don't bind the SSL port to this site or you'll run into SSL errors like you showed above.
The other option is to leave it out entirely and simply use the Host Header resolution to filter out requests for your site. I suspect what you've done is assign all incoming requests to the only IP address on the system, which is why the xx.cloudapp.net is showing your app and the cert is failing.
This would cause xx.cloudapp.net to fail to show any site at all but I think that might be what you want to do anyway.

How do I give access to another computer on my network, to my website hosted locally?

We have a local instance of IIS 7 running with a website. Instead of the default "localhost" we have something like, mysite.compname.com. This is a separate entry into IIS 7 and the default website was removed to prevent confusion.
Then in our host file we an entry like this:
127.0.0.1 mysite.compname.com
Now when I try to hit this url, http://127.0.0.1/ApplicationName/Project/AddProject.aspx technically it should work, but instead I get a 404. I can vouch that this isn't a problem with the application, because if I navigate to http://mysite.compname.com/ApplicationName/Project/AddProject.aspx it works fine.
My end goal is to be able to give someone my computer name, so that they can visit a test page, so the url above I think would get turned into this http://computername/ApplicationName/Project/AddProject.aspx. Any help or at least links to understanding would help because I'm not sure where my issue is coming from.
It sounds like the IIS site / application is configured using a Host Header.
This means that the site will only respond if the host header sent by the browser matches the one configured for the site.
This is a standard method to allow one server to host sites for many host and domain names.
If you wish to allow others to view the site on your computer you will need to either have a local DNS server which you can edit, or, probably the easiest option, get them to edit their host files to include
<your IP> mysite.compname.com.
Remember to open the requisite ports (probably only 80, maybe 443 for https) in your firewall.
Or, you can try to edit the site config to remove or modify the Host Header requirement. See the first link for details, but be careful, it's easy to break things if you don't know the entire architecture of the site.

Website accessible from everywhere except for client's network

My client has a website that is showing some strange behavior. The site is built in ASP.Net and used to be hosted on their internal network. It's now been moved to a different server outside their network. They have other sites hosted on the same server, some built using DotNetNuke, and some classic ASP. All these sites are hosted on one application server, with a database (SQL Server 2008) on a separate server (which is on the same network as the application server). They share the application server, and the database server.
Now that this site has been moved to the outside server, they can't access it. I can, and so can others that I work with (from different IPs, across the country). But the client can't from their network. They can access the landing page subsite.clientdomain.com (no db access), but nothing else. So, for instance, there's a link to subsite.clientdomain.com/folder. When they click that link, the URL changes to subsite.com/folder, which does not work. For myself and others not at the client site, the URL does not change and opens with no problems.
I didn't write the site, and didn't even know it existed before this problem cropped up, so I know very little more than this. Any help is appreciated.
I'm going to go with Martijn B's answer. There's a DNS issue on the internal network. Somewhere on of the DNS servers is a definition that maps http://companywebsite to an ip address like 192.168.1.20 or whatever.
I would open a command prompt on your PC and type
ping new_website_name.com
Take a look at the IP address that comes back. You can also do an nslookup on new_website_name.com that will give you more information. If you (person A) gets one IP address and Person B (inside the network) gets a different IP address....there is definitely a DNS issue on the internal network.
You're going to have to do some network tracing to determine exactly where any redirection is occurring. Given that the problem is only manifested in certain locations, it is likely that it is a function of network configuration in that location (as previously suggested). Without understanding exactly what redirection is occurring, it would be unwise to make configuration changes that might make the problem worse or introduce new issues.
A DNS server cannot AFAIK redirect to a different URL. So something is redirecting from subsite.clientdomain.com/folder to subsite.com/folder, which could be caused by a HTTP redirect. This can be triggered by the software/website itself or by IIS.

Getting client values of IIS Server Variables in Load Balanced Environment

I have an intranet ASP.NET web application in which I need to get the IP of the client's machine. I do this vis the following code:
HttpContext.Current.Request.ServerVariables.Item("REMOTE_HOST")
It used to work when my ASP.NET site was only hosted on a single server. However once we got the load balancer installed and migrated our apps to a web farm, the code above returns the IP of the Load Balancer device and not of the client anymore.
I am working with the networking folks to determine what can be configured differently with the load balancer, but in the meantime I was wondering if there was another way I could get the client's IP other than using that IIS Server Variable? Or any other suggestions?
Thank you!
Which load balancer are you using? It sounds as if your load balancer is acting as a proxy for the web traffic, hence the reason the source appears to come from the LB. Most hardware load balancers are built on Linux platforms and there is provision for transparency if the kernel supports it:
http://www.mjmwired.net/kernel/Documentation/networking/tproxy.txt
However, this would probably require root access to the unit and some downtime. But it is something that may be worth mentioning to the vendor's support team if they don't have any ideas.
Another (hopefully much easier) option: You may be able to configure the load balancer's proxy to write the client's source IP in the HTTP x-forwarded-for header:
http://en.wikipedia.org/wiki/X-Forwarded-For
And then you'll be able to read this header via ASP.net in a similar way:
Request.ServerVariables("X-Forwarded-For")
This may already work if the proxy is already doing this.
Really your options depend on what your load balancer is capable of, and what is configurable. Note the list of common hardware vendors at the bottom of the wiki page above.

C# and IIS - SSL dropping connections, fine over HTTP

In a testing environment, I self-signed a cert and installed it on a web site in IIS 6. This is using .NET 2.0. Cert seems fine (minus the fact that client services don't fully trust it as one would expect). I can do whatever I want to by hitting the site locally from the server on HTTPS or HTTP.
The problem is coming in when accessing this site remotely. If the page has an exception on it, the connection drops. Not return an error, but just flat-out drops, where the browser says it couldn't find the site (this is after it churns for a few seconds, where I can see TCP traffic from the client IP coming in).
The interesting part is that I can create a blank ASPX page, with nothing on it, and it's fine over HTTPS. But the minute I put throw new Exception(); on the page, it goes back to dropping. By the way, it seems to act completely normal if I hit the same page using HTTP instead.
So I'm a bit stuck. Anyone seen something like this?
My first inclination is to go after the proxy/firewall rules between my remote client machine and the server, but I want to make sure it's not something I could fix before I bug other teams.
EDIT ...looks to be a firewall whitelisting problem. Others on my subnet have the same problem, but people in other locations can hit it just fine.
This is not a proxy or firewall issue, because the Yellow Screen Of Death is just text which transmits through any firewall just fine. Here are a couple things that I would try first.
Make sure that the fact that you are using HTTPS isn't the root cause of the problem, such as the problem isn't caused in your program, by handling HTTPS. Such as some special handling of Error code.
Create a new cert and see if the same issues occures.
Try to reproduce this issue on another machine, it could just be a configuration issue.
Try getting a real cert from GoDaddy, they are only 29.99.
That is all that I can come up with right now. One thing that you didn't mention was which version of IIS you were using, which will be helpful.
Have your thrown the exception and then tested the page using regular HTTP? Is the same thing happening, or does it only happen if you throw an exception and access it using HTTPS?

Resources