Multiple Domains to Single Site & IP in IIS7 - iis-7

The server I have at my disposal has only 1 IP available and I'm trying to host multiple domains/applications. As known DNS records will not allow sub directories, so this has to be handled through IIS. I found some information online about this topic but not anything solid for IIS 7.
From what I've read this can be achieved elegantly through the use of HTTP/Host Headers. I'd like to avoid using redirects or URL Rewriting. If you're familiar with this topic or other workaround and can provide some instructions on settings this up it would be highly appreciated.
Thanks!

You can specify a host name under the binding in IIS 7. Note that you cannot do this with HTTPS binding.
In your case, you would select the IP address (or leave it as All Unassigned), and for your host name enter it, such as "mysite1.com". In a different website, do the same thing except use that host name, such as "mysite2.com".

Related

How to make domain name to point different port not 80 in IIS?

I have a domain just bought. Say it is: myowndomain.com. I have added A record with my SERVER IP address. We have two applications on our server. One is with port 3000 and other is with port 3001.
Now I would like to access my applications through this domain. It is working now when I call it by myowndomain.com:3000 and myowndomain.com:3001.
How to setup the system to load port 3000's application if I call myowndomain.com and load 3001's application if I call my.myowndomain.com. [subdomain my.myowndomain.com is also added in godaddy]
Simple. I just have to add domain name alias in HTTP binding and save.
I think you need to do this by using URL Rewriting.
Please have a look on below link from iis, here is given complete demo how you can do this:
https://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
you can install ur rewriting from here:
https://www.iis.net/downloads/microsoft/url-rewrite
by using this on your applications you can move individual pages also to a specific url. hopefully it will resolve your problem.

Things to consider when hosting more than one websites on a server

I have two websites running on IIS 7. Both require SSL. Ports for the websites are http:8080/https:443 and http:8087/https:443 respectively. I've created self signed certificate and put them into the Trusted Root. Contents of the both websites are the same. Here are my questions:
Do I have to make some changes to the hosts file as well? If so, what changes exactly, both on
server and clients
What do I have to type in the address bar in order to be able to open them? (Like 172.16.10.1/website1?) Do I have to specify the port numbers?
For http traffic, you can have many websites which can differ by IP or Port or Host Headers or a combination.
So in your case it is simple. For website1, you have site binding on port 8080, so the url becomes http://172.16.10.1:8080. Ditto for website2: http://172.16.10.1:8087 .
To make things simple, you can do a sitebinding on host header. So, bind the IP 172.16.10.1 with default port 80 to a host header say "www.website1.com" for the first website. Simlary for the other make the same combination bind to "www.website2.com". Now you don't need to specify port in the url. You can simply open both the websites by their respective names.
However, in case of https, it becomes a bit tricky. The certificates are installed on a per server basis. So, you have to specify different IP-Port combinations and host header binding won't work.
One option you have is to use a wildcard certificate which you can then secure-bind to each host-header.
The other option is to get a SAN Certificate (Subject Alternative Name Certificate). This will allow you to do a binding on different host headers with the same IP-port combination.
This excellent article on MSDN will help you understand it better: http://blogs.msdn.com/b/varunm/archive/2013/06/18/bind-multiple-sites-on-same-ip-address-and-port-in-ssl.aspx
Regarding the first part of your question:
You don't need to do anything with the hosts file. If you have a proper third-party certificate, it only needs to be registered on the server. The Intermediate and Trusted roots are already available on the clients. So nothing to be done on the client-side. You can open up "options" in IE and then check "certificates" under the "content" tab to see that a list of publishers is already there.
However, if you are using a self-cert, then the client-part is tricky. Because, the clients will keep on getting the "certificate is invalid" warning every time. One way out of this is to manually install the certificate on each client. Another way is to deploy the certificates to all clients using group policy.

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.

Create subdomain - IIS7

Maybe some one can help me understand why i can't create sub domain. My site is working fine for
mydomain.com and www.mydomain.com
but when i added staging.mydomain.com to the bindings i can't reach to that address for some reason. i read a post here that someone mention the app.config handler setting but i don't know what.
thanks.
What is happening is that your hosting provider probably has set host names for your site for www.mydomain.com and domain.com, however you would need to ask him to add staging.mydomain.com to the list of host names.
unfortunately IIS does not support wildcard host headers, so you will need to specify the actual host names that you need (that is unless you own the IP address at which point you could just use * which will allow any Host name to be seen there and you could use URL Rewrite to do cool stuff, but owning the IP is rarely the case).

How to support custom user domains (like WordPress) in IIS/ASP.NET

I would like to know if it is possible using IIS and ASP.NET (and ideally something that might be employed on a shared hosting account, but this isn't required) to mimic WordPress.com's ability to allow end users to use their own domain names.
WordPress has users who own their own domains change the domain's DNS settings to point to WordPress's own DNS. My guess is this is not something that would be able to be done on a shared hosting account since it would involve adding an entry to the DNS server's table for each custom user domain.
However, for future reference, is this something that might be automated programmatically on perhaps a VPS?
My guess is this is not something that would be able to be done on a shared hosting account
You're nearly correct. The default site in IIS listens to all connections on port 80 for the default IP address.
You can add more sites in 3 ways:
Add new sites listening on different ports. This is not entirely practical if you want "ordinary" sites litening on port 80.
Add more IP addresses to the box (not too eaisly done) and set up new IIS sites to listen to the new IP addresses independently.
Add new sites to the server listening to different "host headers" (domain names to you and I) but on the same (default) IP address .
So called "Shared hosting" usually uses options 3, because a hosting company can get away with only using a single IP address for possibly hundreds of sites.
Therefore you would have to go through the tedious process of adding each host header to the box, and while I'm almost certian this could be done with Wscript, I'm no expert in that area.
If you really wanted to get into it, you could write an ISAPI module to intercept the calls and set up some clever (ish) database/hash table of domain names and target folders to server as the different sites.
Bottom line is, there are various ways to achieve this on Windows. Probably none quite as easy as on a *nix platform where everything is super-scriptable.
What we do is have a wildcard DNS entry set up for our domain. That way, whatever domain the user types will resolve to our website as long as it ends with ".mydomain.com". Then our .Net code just looks at the "HOST" header coming in and serves up the content that matches that domain name.

Resources