Page 1 of 1 in the IIS category
# Monday, December 07, 2009
Close up blog entry

I recently upgraded to Windows 7 and while doing some IIS tinkering I noticed my HTTP 404 page was blank. I was getting a HTTP 404 header back in the response so I was a bit confused. It ends up when I turned on IIS I missed checking the HTTP Errors check box in the windows features.

image

I created a short tutorial showing what I did as well.

Hopefully this might help someone quickly figure this out :-)

Share/Bookmark
Monday, December 07, 2009 12:20:53 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, December 03, 2009
Close up blog entry

I configured SSL on this blog site and found some info on the Microsoft TechNet page Configure a Host Header for a Web Site (IIS 7). The TechNet page was a start, but it didn’t quite get me all the way there. With a bit of experimentation I successfully configured SSL on my web server. You can view a screencast of what I did at the end of this post.

For this post I’m going to use a non-existent website www.abc-test1.com.

First I added an SSL binding to the web site. In IIS Manager, with the web site selected, click on the Bindings… link.

Actions Bindings

On the Site Bindings dialog you’ll want to click the Add… button.

Site Bindings Dialog

Then select https from the Type drop list, select your IP address, and pick your installed SSL certificate. For my testing I created a self signed certificate.

Add Site Binding

Then from the command prompt you’ll want to issue the command:

appcmd set site /site.name:www.abc-test1.com /bindings.[protocol='https',bindingInformation='*:443:'].bindingInformation:*:443:www.abc-test1.com

You can go back in IIS manager to check you SSL binding’s host name. You should see the host header you configured at this point.

Site Bindings with host header

I created this tutorial describing how to configure host headers in IIS 7.5 using Windows 7. It is the same process for any version of IIS 7.x.

I hope this post helps :-)

Share/Bookmark
Thursday, December 03, 2009 2:47:00 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [1]  | 
# Saturday, September 19, 2009
Close up blog entry

This post addresses the situation in which you want to redirect all subdomains to your main domain and you are using host headers in IIS.  The main problem is the host header binding in IIS does not allow wildcards. Since you can not use wildcard host headers any subdomain requests will never reach your web site’s URL Rewrite processing. The following is the technique I use to do subdomain redirects on a web server hosting multiple sites using host headers.


For example lets say you have a web server that hosts www.abc-test1.com and xyz-test2.com. You want all subdomain requests to return 301 redirects to the main domain. 

First you’ll need to configure your DNS host to map all subdomains to your web site IP address. For www.abc-test1.com this will be something like *.abc.com.  How you accomplish the DNS configuration will depend on who handles your DNS. If your DNS provider does not provide wildcard DNS entries you’ll want to find one who does.


Create a web site without a host header defined. This web site will use URL Rewrite to redirect subdomain requests to your main domain. I chose to call this web site Redirector. It should never respond to web requests, so it is essentially an empty web site. The binding for the redirector site will look like the following:

redirector-binding

Your host header bindings for www.abc-test1.com and xyz-test2.com:

 abc-test1-binding

xyz-test2-binding


Your rewrite rules in the web.config file on the redirector site will look something like the following:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="abc-test1 Redirect" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
              <add input="{HTTP_HOST}" pattern=".*abc-test1\.com" />
              <add input="{HTTP_HOST}" negate="true" pattern="www\.abc-test1\.com" />
          </conditions>
          <action type="Redirect" url="http://www.abc-test1.com/{R:1}" redirectType="Permanent" />
        </rule>
        <rule name="xyz-test2 Redirect" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
              <add input="{HTTP_HOST}" pattern=".*xyz-test2\.com" />
              <add input="{HTTP_HOST}" negate="true" pattern="^xyz-test2\.com$" />
          </conditions>
          <action type="Redirect" url="http://xyz-test2.com/{R:1}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

The above rewrite rules will look the following in the GUI configuration:

abc-test1-redirect

xyz-test2-redirect


Given the above configuration if you request any subdomains they will be permanently redirected to the main domain. For example: test.abc-test1.com, www2.abc-test1.com, abc-test2.com, and any variation will be 301 redirected to www.abc-test1.com. Likewise test.xyz-test2.com, www2.xyz-test.com, www.xyz-test2.com, and any variation will be 301 redirected to xyz-test2.com.


There are likely other ways to accomplish subdomain redirects, but this is working out for me.  Hopefully this helps someone else as well.


	   
Share/Bookmark
Saturday, September 19, 2009 12:42:00 AM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, September 08, 2009
Close up blog entry

I created a WCF web service that I wanted to host on a web site and domain different from my main TheThoughtfulCoder.com domain. The problem is AJAX calls can not be made to different domain names, even if they are sub domains.

I'm using dasBlog to host my main blog site and I don't want to put my web services in the same project. I want to keep my web services completely separate. So making a call from thethoughtfulcoder.com to a web service hosted on the domain services.thethoughtfulcoder.com can not be done. Hmmm...bummer!

I found a way to make this work in a straight forward manner. At least I think it is :-)

IIS 7 has an addon called Application Request Routing which allows IIS to proxy calls to another web site to satisfy cross domain rewrite rules. Ah ha! Now I can rewrite a reqeust to a service on my main site and on the web server rewrite it to my services subdomain. To set this up I followed the steps listed below.


Download and install Application Request Routing from Microsoft.
Go to the web server machine home in IIS Manager. The machine home is the root node of the web site in the Connections tree panel. Go into the Application Request Routing feature. ARR Snippet

In the Application Request routing configuration, check the Enable Proxy checkbox. I'm using the default application request routing settings. ARR Enable Proxy Snippet

I created a rewrite rule on the TheThoughtfulCoder.com that treats the directory http://TheThoughtfulCoder.com/ttcservce as the place holder for the web service. The rewrite rule will rewrite any URL with /ttcservice/ to the web service http://services.thethoughtfulcoder.com/TTCService.svc. Since application request routing is enabled on the web server the rewrite rule will cause IIS to make a proxy call to the other domain! In case you're curious I'm using host headers to separate the web sites hosted on a single web server.Service proxy rewrite rule The above rewrite configuration will generate the following XML in the web.config file:
<rule name="TTC-Service Rewrite" stopprocessing="true"> 
   <match url="^ttcservice/(.*)$"> 
   <conditions logicalgrouping="MatchAll">  
   <action type="Rewrite" url="http://services.thethoughtfulcoder.com/TTCService.svc/{R:1}">
   </action> 
   </conditions> 
   </match> 
</rule>

If you have any questions or need any clarification please let me know and I'll try to clarify the steps. Of course there are likely many other ways to accomplish making cross domain AJAX calls, but this solution might be good enough :-)

Share/Bookmark
Tuesday, September 08, 2009 10:59:32 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, September 07, 2009
Close up blog entry

I was missing the *.svc IIS 7 handler mapping. I started working on adding it manually but decided to research it a bit. It ends up you can run:

%windir%\Microsoft.NET\Framework\v3.0\WindowsCommunication Foundation\ServiceModelReg.exe –i

to add all the IIS configuration for WCF services. Use the Framework64 folder if you are using a 64-bit OS.

Share/Bookmark
Monday, September 07, 2009 4:39:05 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [1]  |