Difference between setting IIS Bindings and editing Windows hosts file? - iis-7.5

I used Visual Studio and IIS to successfully deploy a web project to the localhost. Go to localhost on port 51? Great, it pulls up. Wonderful.
Then I tried to add a binding so I could type in "example:51" and it would pull up the website. I then got the following error in chrome:
This site can’t be reached
example’s server DNS address could not be found.
ERR_NAME_NOT_RESOLVED
Looking around, some answers said to alter the hosts file in Windows. I did that, and it solved everything. I type in "example:51", I'm directed to localhost, which pulls up the website.
Then I completely removed the "example" binding from IIS, and it still worked fine. I wasn't so much adding a binding as changing the way "example" is interpreted. It also sends me to localhost on every other port as well, including 80, which I don't think a binding would have done.
So now I'm thinking I didn't solve the bindings problem correctly. Should I have done something differently?

IIS bindings tell IIS how to respond when it receives a request for a specific hostname.
You probably have IIS configured to respond with your site regardless of hostname, so that doesn't matter.
IIS bindings have nothing to do with DNS or name resolution, which is how the browser knows that example should resolve to your host.

Related

Windows server 2012, cname record returns http error 404, Is my iis blocking cname records?

I'm testing a cname record to a domain on my windows server 2012 r2 for future purposes.
I have this website => http://hiligolan.co.il/ which is already running.
This is the binding setup
Now I'm trying to set a different domain to the one I mentioned above using a cname record
When I'm surfing to http://rideme.co.il/ it returns http not found (as you can see)
Checking the ping shows no problem
So I assume that maybe the problem is at the server,
Could it be that something in the iis configuration blocking it?
note: I'm not looking for 301/2 redirect, what am I looking for is that anyone who will surf http://rideme.co.il/ will actually see http://hiligolan.co.il/ website but under rideme.co.il domain.
note 2: I'm not looking to add every other domain on my iis host binding (assuming I have thousands domain), I just want it to be "open" to all, allow every domain referring cname to => http://hiligolan.co.il/ to display it.
Thanks in advance.
You explicit ask IIS to only forward HTTP requests whose Host header contain hiligolan.co.il with that site binding.
Therefore, any request with Host header of rideme.co.il is not forwarded and 404 makes perfect sense.
The fix is also easy, to add a second site binding for the new domain.
Reference
https://docs.jexusmanager.com/tutorials/binding-diagnostics.html#background

Why can't I access my website using the IP address and port number?

I'm having a weird issue with a website I have installed on IIS. I can access it if I go to (ip address)/defaultdoc, but not if I go to (ip address):(port). I'm running a debugger on my browser, and the only thing it's doing when I try to access the site with the port is pulling a 404 error. This is really weird to me because the default document for the site is definitely the page that I go to when I pull up the site otherwise. Does anybody have any ideas why this might be happening?
Edit: I'm suddenly not so sure that the default document is working right. In IIS, it says that the default document is what I want, but when I run a list config command, I get something entirely different.

Direct a URL directly to a GlassFish application in a virtual server

We have a domain name with DNS management facility. We also have a web application developed in a GlassFish server hosted in a virtual server with a path is
http://198.98.103.233:8080/pemis/
I want to direct to the home page of that application when some one type the domain name. After navigating through the pages, we must be able to see
http://www.pemis.lk/faces/public.xhtml
in the browser rather than
http://198.98.103.233:8080/pemis/faces/public.xhtml
How can we configure that.
Thanks in advance.
You need to install your application as the root application in Glassfish, as explained here. But it's not hard:
asadmin deploy --contextroot "/" your-webapp.war
or set the context-root property in the sun-web.xml or glassfish-web.xml depending on the version of Glassfish you use.
To change the port Glassfish listens on you need to modify the HTTP Listener configuration. On default installations you'll want to change http-listener-1's port. You can do so using the console. But you can also directly edit the domain's domain.xml:
<network-listeners>
<network-listener port="80" protocol="http-listener-1" transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"></network-listener>
...
</network-listeners>
Last, to make www.pemis.lk point to that server you need a DNS entry that points to the address the server is attached to. The details of how to do that depend on the comapny that sold you the domain, quite often they have online tools that allow you to enter or modify the name-address mapping. In case of doubt it's best to contact them by phone or mail.
I'm on the same path and, as you don't posted the solution that you found (if you found it), I'll add here some future reference for anyone facing this problem.
I'll break the question in two parts: Eliminating host:port and changing how the URL behave.
I don't have a complete response to the first, however if you chose to listen at port 80, by HTML standard, you will supress the port on the URL, getting half the solution you want.
The second part, changing the URL behavior and/or shortening it can be achieved by either using mod_rewrite in apache or Tuckey's URL Rewrite Filter (http://www.tuckey.org/urlrewrite/). A google search using URL Rewrite can achieve you a more in depth explanation and there's a guide on the website.
You should, however, update your question with an answer, if you found one.

IIS: Can I create a host header for an intranet site?

This is a fairly simple question (in my opinion) but for some reason despite my Googling I cannot find a straight answer to it.
Currently I have an application running under my Default Web Site located at http://localhost/myApp. Ideally, I'd like to create a new site in IIS with a binding to 127.0.0.1:80 and a host header of http://myApp so that I can test my url rewriting rules properly (since my app will ultimately be hosted at http://www.myApp.com, not http://www.somedomain.com/myApp).
So, my question is this: will the above work? I haven't had a chance to try it yet.
If the above will not work, what are the steps to be able to access my site at http://myApp on my local network?
It should work provided you fool the OS into resolving www.myapp.com to 127.0.0.1. To do so, edit your hosts file in %systemroot%\system32\drivers\etc to contain the following:
127.0.0.1 myapp.com
I believe you could do just myapp(without the .com) as well, but that gets a bit trickier because how that is resolved depends on your node type. (hybrid, etc) To be safe, add
127.0.0.1 myapp
to BOTH the hosts and LMHosts files in the same directory. By default the lmhosts is non-existent and there is a lmhosts.sam there. You'll have to rename that to just lmhosts or create a new one.
Then create the binding as per usual in IIS7/7.5 (I assume it's 7... Site->Actions->Bindings->Add or Edit->Populate hostname accordingly).. IIS6 will work too but it's alot harder to get https working should you need it.

Handling custom errors with a port in the URL for IIS

I am trying to specify a custom (ASPX) page to handle 404 errors.
I can't seem to do this with IIS because I use a port other than the default.
I have two versions of my site, one exposed (default port) and one on another port, for testing. I'm trying to do this in testing mode first.
If I do:
http://www.mysite.com/notapage ... I get the IIS 404 error.
If I do:
http://www.mysite.com:1234/notapage ... I get a Google error (I use Google Chrome) as if it cannot resolve my site even though http://www.mysite.com/ works.
Any ideas?
On which level you configure this ASPX page for 404? If you did that on default web site, it only works for first test link you provided.
port 1234 should be monitored by another web site. Please check your IIS settings and make sure that that site was configured correctly.

Resources