When working with Microsoft Internet Information Services (IIS) Web servers, you have to know how to manage Web sites and content—but you also need to know how to customize IIS to suit the needs of your organization. Being able to get your hands dirty and get under the hood of IIS is necessary if you want to successfully manage it in today’s fast-paced world.
To help you meet this challenge, I’m going to show you how to handle these tasks:
- · Hosting multiple Web sites with one IP address through the use of host headers
- · Using custom ISAPI filters to change the behavior of IIS
- · Configuring IIS to create custom error messages
- · Using MIME to configure custom file types
Hosting multiple Web sites
IIS lets you use different combinations of IP addresses and port numbers to host multiple sites on one Web server. This allows you to buy one really fast Web server to host your company Web site, company intranet, and any other Web sites that are needed for your organization.
To host Web sites on a single server, you can:
- · Use multiple IP addresses and assign a separate IP to each Web site (Figure A).
- · Assign different port numbers to a single IP address (Figure B).
- · Use Host Header names.
Figure A |
![]() |
Figure B |
![]() |
To use a separate IP address for each Web site, configure multiple IP addresses in the TCP/IP settings of your Web server. Next, configure your DNS server so that the appropriate host names resolve to the separate IP addresses. Finally, go into the Internet Services Manager and create two separate sites in IIS (right-click on Default Web Site and then click New | Site). Configure each Web site to correspond to a different IP address.
The second approach is to assign a different port number to a single IP address. With this method, you create a new Web site in IIS by right-clicking on the icon of your Web server and choosing New | Web Site (Figure C).
Figure C |
![]() |
Next, create your Web site and enter the port number you want to use. Once you’ve created your sites, test them by entering the appropriate name and port number in your Web browser (e.g., http://companywebsite.com:8080 or http://192.168.1.1:8081).
The third method is to use Host Header names to assign multiple Web sites to a single server. What allows Host Headers to work is the proper configuration of your Domain Name Server (DNS). For example, I created two Web sites: Web Site 1 and Web Site 2. Next, I went into the DNS MMC and set up host records for Web Site 1 and Web Site 2 in which I assigned both of them to the same IP address. Finally, I tested both Web sites by entering the Host Header names in Internet Explorer. If the separate Web sites come up (assuming you’ve put content in each), you know that you have everything configured correctly.
Author’s note
Host Headers don’t work with Secure Socket Layers (SSL), and many earlier versions of browsers don’t support Host Headers.
Custom ISAPI filters
ISAPI filters let you filter requests for certain events. When a Web server requests an event that has a filter attached to it, the filter responds by performing a task or set of tasks. You can apply filters locally or globally.
To view your filters, open the Internet Services Manager, right-click on one of your sites, and choose Properties. Choose the ISAPI Filters tab to view a list of filters.
The Status column indicates whether a filter has been successfully loaded. If the filter is green, it has loaded properly; if it’s red, it has failed to load. Filters are normally created by programmers. You’re then responsible for loading them and testing them on the Web site.
Creating custom error messages
It’s almost impossible for your Web site to never generate error messages, and some of the messages can be difficult for users to decipher. Wouldn’t it be great if you could replace the 404 File Not Found error with a custom message or messages? With IIS, you can do just that. Table A shows a list of the standard error codes and messages.
Error code | Error message |
400 | Bad request |
401.1 | Login failed |
401.2 | Logon failed due to server configuration |
401.3 | Unauthorized due to ACL on resource |
401.4 | Authorization failed by filter |
401.5 | Authorization failed by ISAPI/CGI application |
403.1 | Execute access forbidden |
403.2 | Read access forbidden |
403.3 | Write access forbidden |
403.4 | SSL required |
403.5 | SSL128 required |
403.6 | IP address rejected |
403.7 | Client certificate required |
403.8 | Site access denied |
403.9 | Too many users |
403.10 | Invalid configuration |
403.11 | Password change |
403.12 | Mapper denied access |
403.13 | Client certificate revoked |
403.14 | Directory listing denied |
403.15 | Client access licenses exceeded |
403.16 | Client certificate untrusted or invalid |
403.17 | Client certificate has expired or is not yet valid |
404 | File not found |
404.1 | Site not found |
405 | Method not allowed |
406 | Not acceptable |
407 | Proxy authentication required |
412 | Precondition failed |
414 | Request-URI too long |
500 | Internal server error |
500.12 | Application restarting |
500.13 | Server too busy |
500.15 | Requests for global.asa not allowed |
500-100.asp | ASP error |
501 | Not implemented |
502 | Bad gateway |
To create your own error messages, just open an HTML editor and write them. For example, in Figure D, I opened FrontPage and created a new 404 File Not Found error page.
Figure D |
![]() |
When you finish, copy the file into the directory that holds your error messages. (The default is C:\Winnt\help\iishelp\common.) Then, open the properties of your Web site in Internet Services Manager, click on the Custom Errors tab, and change the 404 error message file to your newly created file, as shown in Figure E.
Figure E |
![]() |
Finally, test your new error message by accessing a page that doesn’t exist. Figure F shows the results.
Figure F |
![]() |
Author’s note
Not only can you create static custom error messages, but you can also create custom error messages that include ASP and other scripting languages.
Working with MIME types
Multipurpose Internet Mail Extensions (MIME) is used for creating file formats. When you transfer a file between IIS and a browser, the file has a MIME type. For example, a JPEG video file would be listed as image/jpeg, as shown in Figure G.
Figure G |
![]() |
To view available MIME types, open the IIS console, right-click on the server name, and choose Properties. Next, click Edit in the Computer Mime Map section. To edit a MIME type, simply highlight the appropriate type and change the parameters. To create a new type, choose New Type and enter the appropriate MIME type.
Table B lists the MIME types that are registered in IIS 4 and IIS 5.