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

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.

Related

Redirect TLD (dev) to local IIS

In the office, we have already setup a redirect in the DNS to push .dev back to the localhost. The issue is when I am not in the office this does not work. I edited my host file for the websites but as I add more in the future I would prefer to not have to edit my host file.
Is there a way, within my computer, that I can force the TLD of .dev to always go back to my localhost?
I realize I may have to find a way to do this on my router so that the DNS is resolved.
Example:
- Local IIS
-- Website A (with a Host Name Binding of website-a.dev)
-- Website B (with a Host Name Binding of website-b.dev)
When I open a browser on my local box and type in website-a.dev, it should loop back to my local IIS and pull this website. Same thing for website-b.dev, of course, going to the other website. Now I know if at work we have setup the DNS to allow for this but I want to know if this can be done at home, where I do not have direct access to the DNS.
I know I can just put into my host file
127.0.0.1 website-a.dev
But I want a catch all for .Dev to go back to 127.0.0.1
Take a look at:
https://superuser.com/questions/135595/using-wildcards-in-names-in-windows-hosts-file
It explains that using Acrylic allows you to use wildcards and acts just like your host file.

Difference between setting IIS Bindings and editing Windows hosts file?

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.

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.

How to display content from another domain by editing CNAME records?

I have a site that lets people have their own e-stores, for ex- mysite.com/clientname
What I want is, if somebody opens store.clientname.com or clientname.com/store, the content is pulled from mysite.com/clientname. [ So that their users feel that they are browsing on their site ]
I know this is possible because site'e like tumblr let you do that by changing a CNAME entry for your domain to their IP address.
I do have a dedicated IP address.
Also, can this be done by editing the .htaccess file at clientname.com, and if yes, which method is better/easy?
You'll want to solve the problem in a completely different way for http://store.clientname.com/ versus http://clientname.com/store.
In the first case, you can serve the web site as a virtual host. Just set up a virtual host called store.clientname.com and set its DocumentRoot to be the existing directory that contains the files for http://mysite.com/clientname. If you have other web server configuration directives that apply to http://mysite.com/clientname then you'll also want to apply those in the virtual host. Finally, the client can set up a CNAME record in DNS for store.clientname.com pointing to your web server.
If you are using Apache, you can also use a default virtual host and mod_rewrite to dynamically translate URLs of the form http://store.{whatever}/ to http://mysite.com/{whatever}/. However, this won't work if you are using HTTPS.
In the second case, you don't want to serve the web site at http://clientname.com/ because the client presumably is already hosting that and presumably http://clientname.com/otherstuff has to continue working and come from their server. So the second case is easier for you because all the work has to be done on the client's web server. But it's simple: they will just have to configure their web server to proxy http://clientname.com/store to http://mysite.com/clientname.

Sharing single application across a 2 subdomains in IIS7

I have an application that is currently deployed (ex. www.example.com ). However, now we have a "secure" subdomain, which will take all of the requests that need to be encrypted (ex. secure.example.com). The site that is at www.example.com is currently mapped to C:\inetpub\example.com\wwwroot\, and I've mapped secure.example.com to C:\inetpub\example.com\wwwroot\secure.
However, since secure.example.com was setup as a new website within the IIS Manager, when the secure site is visited, it displays an error since there is no web.config associated with this website; however, this is the way I want it since I want this to be a part of the application that is in the parent directory.
I think what you really meant to do was just right click on the web site for example.com and edit the bindings. In there you can add host names to that site.
Make sure you add them for port 443 which is SSL.
Map both the IIS virtual directories/web sites to the same directory, and check that are both using the same IIS application name.
(Not tried this, but can't recall seeing anything to say it would not work.)

Resources