Search
Thursday, October 18, 2018 ..:: Home ::.. Register  Login
   Calendar  
     
  
   Search  
     
  
   Blogroll  
     
  
   Disclosure  
All blog entries are the opinions of the author and do not necessarily reflect the opinions of their employer. All the code presented is for explanation and demonstration purposes only. Any damages incurred to your site and/or data are not the responsibility of the author. Every effort is taken to ensure the code properly compiles, however sometimes there are some hiccups and you might be required to do your own debugging.
     
  
   TechTidBits (Blog)  

How do you run multiple websites on one IIS server?

Jun 3

Written by:
Wednesday, June 03, 2009 9:38 PM  RssIcon

Do you have your own server?  Are you running IIS and have one ASP or ASP.NET application?  Want to run more but can't seem to figure it out?  Read on for some help!

You could be running Apache/Tomcat/WebLogic or other J2EE servers and you might learn a bit, but it's up to you to make the leaps of logical faith to make it run (the theory is tranlatable if not the screen shots and dialogs).  Here's how you do it!

Early this year I read a blog about running your own server and how it's just asking for trouble.  Of course the title of the blog got me upset cause I've been running my own server in my basement for over ten years and love it!  I've learned so much about IT/networking/servers/RDBMSs/websites/hosting and not to mention the development that goes along with it!  I started wit..anyways, you don't care about that!  MEAT, let's get to the meat!

First, no matter what, you'll have to buy your domain name and map it to a hard coded IP which is going to be your server's IP.  If you have a domain name already bought, chances are good it's either parked or pointing to someone else's server.  If you don't know what I'm talking about, this is a good place to start.  You'll want to change the 'Host Name' called "server" which will have a 'Record Type' of 'A'.  That's DNS-speak for networking, I'm a dev guy, so bear with me, that's what it says on my DNS hosting webpage, your mileage could differ.  But the key here is to specify your IP address once, and only once with the 'A' Record Type.  Why?  Cause for ALL the other record types you're going to add (for your additional websites, email, Record Types of CNAME), you're going to point to the "server.yourARecordName.com."  That last trailing period is HUGELY important in DNS-speak, don't forget it! 

DNS Settings for PCHenry.com

So what's the BIG deal with specifying it only once?  Well, when, and it WILL HAPPEN, you're modem get's screwed up, the power goes out in your neighbourhood, or your ISP releases/renews your IP, you'll only have to respecify your IP once, and all the other places you WOULD have had to retype out your new four numbered IPs are all changed automagically without any more work!  BEAUTIFUL!  And if/when you setup multiple websites, the number of places to change will grow'n'grow'n'grow!  So changing it only once is a HUGE benefit IMHO.

If you'll notice up above there are subdomains listed there and they're also referencing the "server.pchenry.com."  What are those?  Try it out, goto http://ODNCStudyGroup.PCHenry.com, it's just another way to specify a webapp on your server.

Next, you'll want to setup your second domain name with your DNS company.  When you do that, setup the important records to point to, you guessed it "server.yourservername.com."

DNS Settings for Yabber.com

NOW!  Once you make all these changes, it'll take a few hours, sometimes up to a day for the other DNS servers to "see" your changes to the DNS for your server names.  What's that?  Something in computers doesn't take effect immediately?  You obviously haven't played with Lotus Notes!  DOH! HAHHAHAA  Anyways, ya, when you make DNS changes, it can sometimes happen immediately (if you're lucky) or a few hours.  So when you goto test your website, it could take a bit of time to completely test it.  Also, when the power goes out in your house/apartment and your modem/router power cycle, you might have make these changes and wait a bit of time for your website to come back online again.

Ok, now that you have your DNS setup, next it's time to move to your router!  This is again, dependent on your particular setup and router, but the theory is the same across the board.  Oh, if you're asking "uh...how do I GET that IP address up above?"  You get it from here, you have to go into your router's setup and look for something like status and it'll tell you what your IP is right now. 

IP Status from router

WARNING! Be careful, some ISPs will renew your IP regularly, Bell Sympatico has been known for that.  What's that mean?  Remember how you hard coded this IP into your DNS setting?  If your ISP changes/renews your IP on you, your server is no longer at that IP anymore, your ISP just pulled the rug from underneath you and you'll have to reset your IP address on your DNS again, and again, and again.....There are dynamic tools out there to help you out, but I would suggest picking a different ISP, it'll make your life sooo much easier not having to worry about renewing IPs.

Ok, next (just a few more steps, we're almost there), you'll have to find the setting for "Port Forwarding" to tell your router whenever it sees HTTP traffic to "forward" them onto your network to a specific IP.  At this point, if you haven't already done it, you'll have to set the IP address of your IIS box (your web server) to a static IP (see, I told you, you were going to learn about networking! haha) cause just like your DNS' IP address can't change, neither can your web server's internal IP address neither!  But this one's easier to control cause, well, YOU control it. HAHA

 Port Forwarding

Next we're onto IIS.  In IIS, you'll have to open up the properties for your websites.  I'm assuming you have them already installed, configured and running internally but you're not able to get to them from the outside world.  At this point, you might be surprised to learn you CAN hit the default website!  Try it out!  SHOKING!  WOW!!!!  Cool, you're on the web!  But what about that other 2nd website?!  To do that you'll have to play with headers, host headers more specifically.

Multiple Webapps on the same server, these are the property settings

Let's back up a moment.  How does IIS differentiate two requests coming in and know where to redirect them?  It looks at the Host Header information, that's the name you type out on the URL.  When you type out something that matches what's in the lists on the Advanced tabs in IIS, you'll get THAT webapp.  What happens if you don't have anything and just hit the server?  You'll get the default webapp, the one that's got an empty value for the Host Header Value. Warning, don't have two webapps with a default value!  You'll cause yourself no end of grief, SB knows what I mean, but once you do it (ok twice for me DOH! haha) you won't forget it ever again!

Please notice my two webapps from above, PCHenry and ODNCStudyGroup.  PCHenry is the default website, notice in the IIS Properties, Advanced settings dlg, there is the default, 80 and empty Host Header value?  THAT'S the website I've designated as the default one.  The ODNCStudyGroup website only have two rows and is noticibly missing that empty host header value.

Question for some smarter people out there than I!  Ten years ago, in order to hit my website, I could use http://pchenry.com and I found it it was because of that specific host header value.  HOWEVER, today when I try that, it doesn't work.  What gives?  What is going on?  Is it a problem with my DNS setup or my IIS box?  I don't think it's my IIS box, but what do I have to setup on my DNS to make that work?

Now that you know how to setup multiple websites/webapps on your server, drop me a comment with the urls so I can try them out! haha  Now it's time to go brag a coffee and get coding!

 

PS  There are a lot of advantages to running your own server in your basement for personal use (unlike the blog article above).  I wouldn't do this for a business, but for personal use, absolutely!

  • great for learning about networking and website programming
  • learn a new OS (Windows Server or Linux)
  • great to share information with other like minded people
  • ignore the naysayers, you can so do it!  and WHEN you do, it'll be awesome for your confidence!
  • great way to get excited about tech again if you find yourself in a bit of a rut
  • jump starts your learning and will eventually translate into longterm career advantages!

 

Resources

GeekDaily: Running your own server is asking for trouble

Microsoft TechNet: Hosting Multiple Web Sites on a Single Server (IIS 6.0)

Tags:
Categories:
Location: Blogs Parent Separator TechTidBits

3 comment(s) so far...


Re: How do you run multiple websites on one IIS server?


"uh...how do I GET that IP address up above?"

Instead of having to go into your router, just use a web browser from any computer in your network and surf to the following site.
http://www.whatismyip.com/

By Colin on   Thursday, June 04, 2009 8:48 AM

Re: How do you run multiple websites on one IIS server?

>>I could use http://pchenry.com and I found it it was because of that specific host header value

I looked at your DNS setup and it seems there wasn't a record for the @ record (host record for pchenry.com), I've added it for you using your IP address as using a CNAME can have ill effects on email delivery (some very old email servers use to check whether the @ record was a CNAME and try to use that as a mail server)

Ensure that you've setup a entry in IIS specifying that the host header of "pchenry.com" is used for the same website as "www.pchenry.com"

One last note... your all setup on google app engine for your email, you should checkout the google sites offering included (and setup sites.pchenry.com), it might be a useful addition to some of things your doing... similar to sharepoint.

By Colin on   Thursday, June 04, 2009 8:49 AM

Re: How do you run multiple websites on one IIS server?

Very cool! Thank you very much Colin! I'll have to check out that new @ record to see what you did. Very cool! I thought it was something on my end but it was how I had changed things on the DNS. Thanks for the change and heads up! :> And great info on that WhatIsMyIP.com site! Awesome info!

By phenry on   Thursday, June 04, 2009 9:11 AM

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 
     
  
Copyright 1999-2012 by PCHenry.com   Terms Of Use  Privacy Statement