Configure the MIME type for IIS

Source: Internet
Author: User
Tags metabase

This article from: http://xingxing5421.blog.163.com/blog/static/119446319201141133648731? Fromdm & fromsearch & isfromsearchengine = Yes

 

 

Configure IIS

We usually do not need to configure IIS in many ways, mainly in the following aspects:

Configure IIS applicationsProgramIsolation mode;

Configure HTTP compression;

Configure the MIME type;

Configure web service extensions;

Configure the application pool.

Configure Iis Application Isolation Mode

We have introduced in one of the IIS user guide: New Features of IIS 6. By default, IIS 6 works in Working Process Isolation Mode. If your web application is not compatible with this mode, you need to configure IIS 6 to work in IIS 5 isolation mode. The configuration process is as follows:

Click Start, point to control panel, select Internet Information Service (IIS) manager, right-click the website folder on the pop-up Internet Information Service (IIS) manager, and select Properties, then, click the service tab in the pop-up website Properties dialog box and select Run WWW Service in IIS 5.0 Isolation Mode in Isolation Mode. You need to restart the entire IIS service.

Configure HTTP Compression

As shown in the configuration in, you can see that IIS 6 supports HTTP compression. HTTP compression is a function that reduces bandwidth consumption at the expense of CPU performance. If HTTP compression is enabled in IIS and the client browser supports HTTP compression, before IIS transfers files, the data is compressed before being transmitted. It works like this:

When IIS receives a request from the client browser, it checks whether the client browser supports HTTP compression. Then, IIS checks the file extension requested by the client browser, to determine whether the requested file is a static file or contains dynamic content.

If it is a static file, IIS will check whether the file has been stored in a temporary directory in a compressed format. If the file is not stored in a compressed format, IIS will send the uncompressed file to the client browser that initiates the request, compress the file, and store it in a temporary directory; if the file is already stored in a temporary directory in a compressed format, IIS will send the compressed file to the browser. IIS does not compress any file before the first request by the client browser. Before the first request by the client browser, the file is not compressed. When the client browser requests a file for the first time, the files it obtains are not compressed.

If the file contains dynamic content (application file), IIS will first generate a response for the dynamic content, compress the response, and send the compressed response to the client browser; IIS does not store this response.

Compressing static files consumes less CPU performance, and usually only needs to be compressed once, and then stored in the cache's temporary directory. compressing dynamic content requires a higher cost, because they are not stored in the temporary directory and must be regenerated each time a request is made. We recommend that you only compress static files without compressing application files. Of course, if you think that you are more concerned about the bandwidth usage than the CPU performance consumption, you can also compress Application Files. Microsoft recommends that when the CPU usage reaches 80% or more, do not compress application files.

When HTTP compression is configured, select to compress static files and application files based on your needs. To Compress Application Files, select the compressed static files check box, enter the temporary cache directory of the compressed content. The default value is % WinDir % \ IIS temporary compressed files. Then, enter the maximum size of the compressed content. The default value is unlimited.

In terms of security, IIS 6 only defines common MIME types (file extensions), but does not include wildcard mime ing like IIS 5. In this way, when a client browser requests a file from the IIS 6 web server, if the file extension is not defined in the iis mime type, IIS Returns Error 404-the file or directory is not found. For websites that use access databases, to prevent others from downloading access databasesArticleTo change the name of the Access database. ASP to prevent download, which is not safe. The best way is to change the ACCESS database extension to an undefined extension in the MIME type, so that others will not be able to access the database.

Of course, sometimes you need to add the MIME type. You can add the MIME type at three levels: IIS global, website, and single website. The default MIME type is defined in the Global attributes of IIS, the MIME type defined in website attributes can overwrite the MIME type definitions of all websites. The MIME type defined on a single website only affects this website.

The process of adding the MIME type to IIS globally is as follows:

On the IIS console, right-click the server name and select Properties;

In the displayed computer Properties dialog box, click the MIME type button;

In the MIME type dialog box, you can create, modify, and delete MIME types. Here, I create a MIME type for the ISO file and click Create;

In the extension column, type the corresponding file extension. ISO, if you do not enter ". "(for example, if you only enter ISO), IIS will automatically add it to you. If you want to add a wildcard mime ing, you can access any file without the MIME type definition, enter "*" in the extension column, but this method is not recommended. In the MIME type column, enter application/octet-stream, and click OK.

To add a MIME type definition to a website or a single website, right-click the website or a single website, select properties, and click the MIME type button in the HTTP header label.

Configure web service extensions

Web service extension is an extension component used in IIS to process dynamic content requests. It supports the following two methods of Web Service extension in IIS:

ISAPI (Internet Server Application Programming Interface) extension;

 

CGI (Common Gateway Interface) application;

 

They basically work in the same way, mainly because of different implementation mechanisms. The biggest difference between ISAPI and CGI is that ISAPI extensions basically exist in the form of dynamic link libraries, while CGI exists in the form of executable programs; web service extensions running in the ISAPI mode can stay in the memory after being activated by user requests, thus reducing the DLL loading time. Therefore, they are more efficient than CGI.

In terms of security, When IIS is installed, the following four web service extensions are installed by default but not enabled. Therefore, only static content access is supported:

Active Server Pages

 

Internet data connector

 

WebDAV

 

Include files on the server

 

You can add or delete custom web service extensions based on your needs, while web service extensions built in IIS can only be disabled or enabled.

For these built-in Web service extensions, IIS has configured application ing for the web site. You only need to enable these web service extensions, you can enable access to the corresponding dynamic content on the web site.

If you want to enable the Web service extension that comes with a system, click the Web Service Extension folder in the IIS console, click the corresponding web service extension in the window on the right, and then click Allow, for example, to enable support for ASP pages, enable Active Server Pages;

To add custom web service extensions, in addition to adding them to the Web Service Extension folder, you also need to add application mappings to the Web site. I will describe them in a later article.

Configure the application pool

The core of IIS 6 is the working process isolation mode, while the application pool defines how the working process works. Therefore, the application pool is the core of IIS 6.

Different from IIS 5, you can only use a single application pool. IIS 6, which works in work process Isolation Mode, can create multiple application pools. Different application pools are completely isolated, when an application pool stops services, it does not affect other application pools.

Before using the application pool, you should determine the number of application pools you need. Many may think that since different application pools are completely isolated, I only need to create an application pool for each web site. This method can be used when there are a small number of Web sites on the IIS server. However, if there are many web sites on the IIS server, this method is not applicable, because different application pools create their own working processes when they are accessed, a large number of working processes consume a large amount of system resources and CPU utilization when working concurrently, this reduces server performance. Based on the importance, isolation, and running of the Web siteCodeTo divide the web sites on the IIS server, and then determine the number of application pools as needed. For those very important websites, websites that need to be isolated separately, websites that run code stability and security are not reliable, they are configured to use their own independent application pool, other common web sites are configured to use a public application pool.

By default, When IIS is installed, a default website is created and an application pool named defaultapppool is created for use. The application pool under the default configuration can work well, we recommend that you configure the application pool only when necessary.

Configure application pool Properties

Expand the application pool folder in the IIS console, right-click the corresponding application pool, and click Properties. You can configure the following in the properties of the application pool:

Reclaim

In the recycle tag, you can set the recycle method of the Worker Process:

Recycle Worker Process (minutes): the number of minutes after which the worker runs to recycle the worker process. It is enabled by default and set to 1740 minutes (29 hours );

 

Reclaim A Worker Process (number of requests): The number of HTTP requests processed by the worker process before terminating the worker process. This is disabled by default. If it is enabled, the default value is 35000;

 

Recycle a worker at the following time: Recycle the worker at the specified time. disabled by default. To enable it, select the check box and click Add to add the recycle time, use 24 hours to define the time for the rollback;

 

When too much memory is consumed, recycle the Worker Process:

Maximum virtual memory (MB): The worker process is reclaimed when the virtual memory used by the worker process reaches the set value. The default value is 500 mb if enabled; we recommend that you set it to no more than 70% of the total virtual memory;

 

Maximum memory used (MB): The worker process is reclaimed when the physical memory used by the worker process reaches the set value. The default value is 192 MB if enabled; we recommend that you set it to 60% of the total physical memory size;

 

In addition, the application pool has the following two ways to recycle working processes, but neither of them will interrupt Web Services:

By default, application pools use overlapping collection methods. In this way, when the application pool needs to shut down a working process, a working process is created first until the new working process is successfully created;

 

The application pool can also shut down the old working process and then create a new working process.

 

If the web application does not support running multiple instances, you must configure the application pool to prohibit overlap collection. This configuration cannot be modified in the IIS console. You can only modify the disallowoverlappingrotation metabase attribute of the corresponding application pool in metabase. XML to true.

Performance

In the performance tag, you can set the running mode of the Worker Process:

When idle for this period of time, shut down the working process (minutes): How many minutes after the working process is idle, which reduces the consumption of idle working processes on system resources and CPU performance, enabled by default and set to 20 minutes;

 

The core Request queue is limited to (number of requests): When HTTP. when sys receives an HTTP request from a client, if the worker process of the corresponding application pool processing the request is still busy, HTTP. sys stores the received requests in the Request queue of the corresponding application pool until the worker process is idle. This option is used to set the number of requests that the request queue of this application pool can accommodate. By default, the request queue of each application pool is limited to 1000 requests, if the number exceeds 503, the system returns the 65535 error to the client. You can modify the value as needed. The maximum value is. However, setting too large will consume a lot of system resources, and setting too small will cause frequent 503 errors during client access.

 

Enable CPU monitoring: monitors the CPU usage of this application pool, which is disabled by default. If an application pool occupies too many CPU usage, you can configure this option to restrict the application pool;

Maximum CPU usage (percentage): The maximum CPU usage that can be used by the configured application pool. The default value is 100 when CPU monitoring is enabled;

 

Refresh CPU usage (minutes): interval between refresh CPU usage; default value: 5 when CPU monitoring is enabled;

 

The operation performed when the CPU usage exceeds the maximum usage: When the CPU usage of the application pool exceeds the set maximum CPU usage, the default setting is none when CPU monitoring is enabled, in this case, IIS only records the event logs without performing other operations. If you choose to disable IIS, IIS will close all worker processes in the application pool;

 

Web Garden: in the Web garden, you can configure the maximum number of worker processes used by this application pool. The default value is 1 and the maximum value is 4000000; configuring multiple worker processes can improve the performance of the application pool to process requests. However, before you configure multiple worker processes, consider the following:

Every working process consumes system resources and CPU usage. Too many working processes will lead to a sharp consumption of system resources and CPU usage;

 

Each worker process has its own status data. If a web application depends on a worker process to save status data, multiple worker processes may not be supported.

 

Running status

In the running status tab, you can configure the application pool to monitor the running status of the worker process,

Enable Ping: by default, the application pool is configured to ping the worker process every 30 seconds. When the worker process does not respond, it is deemed that the working process has a fault and is disabled by default. You can modify the ping interval, but too Long Ping interval may cause web service interruption, and too short Ping interval will consume more system resources and CPU utilization, therefore, we recommend that you retain the default configuration;

 

Enable quick failure protection: if there is a problem with writing web application code, it may cause the working process to continue to have problems. By default, the application pool is configured to enable quick failure protection. When the worker process is configured for a period of time (5 minutes by default) if the number of failures in the application exceeds the configured value (5 by default), the application pool is disabled.

 

Start time limit: IIS waits for the start time of a worker in the application pool. When the start time of a worker exceeds the set value, IIS will record it in the event log;

 

Closing time limit: When IIS detects a worker process failure, it marks the worker process as disabled. This option specifies the time limit for IIS to wait for the Worker Process to automatically close, if the worker process is not closed after the time limit is exceeded, IIS forcibly closes the worker process.

 

Identifier

In the tag, you can configure the user account that the workflow runs. In IIS 5 or When IIS 6 runs in IIS 5 Isolation Mode, the working process runs in the local system account, IIS 6 running in work process Isolation Mode runs under the network service account, which reduces the possibility of system attacks.

You can configure a workflow to run under a predefined local system, local service, or network service account, or use a Custom User Account. We recommend that you use the default network service account. For higher security, you can configure a user account. However, we recommend that you add this user to the iis_wpg user group, therefore, the iis_wpg user group has the minimum permissions to start and run a working process.

 

Create application pool

To create a new application pool, right-click the application pool folder in the IIS console, point to new, and select the application pool;

In the Add new application pool dialog box that appears, enter the application pool name in the application pool ID column, and select whether to use the default settings or inherit the existing application pool settings, click OK;

Allocate a web site to the application pool

Expand the website folder on the IIS console, right-click the corresponding website, and select properties. In the displayed website Properties dialog box, click the Home Directory tag, select different application pools in the application pool bar. By default, all applications used by the website are named default applications. If you want to use different application names for this website, in the Application name column, modify it. For example, here, I change it to winsvr, which is easy to view and click OK,

In this case, the application of the corresponding website is displayed under the corresponding application pool, as shown in:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.