次の方法で共有


既定のバインドの追加 <binding>

概要

<bindings> 要素の <binding> 要素を使用すると、要求が Web サイトと通信するために必要な情報を構成できます。

Web サイトを作成するときにバインド情報を構成することも、サイトの作成後にバインド情報を編集することもできます。 バインド情報には、クライアントがサイトとの通信に使用するプロトコル、サイトの IP アドレス、ポート番号、およびホスト ヘッダーが含まれます。

<binding> 要素には、バインド情報を構成するための 2 つの属性 (bindingInformationprotocol) が含まれます。 bindingInformation 属性には、サイトの IP アドレス、ポート番号、および必要に応じてホスト ヘッダーが含まれます。 protocol 属性は、サイトとの通信に使用するプロトコルを定義します。

互換性

バージョン メモ
IIS 10.0 <binding> 要素は IIS 10.0 では変更されませんでした。
IIS 8.5 <binding> 要素は IIS 8.5 では変更されませんでした。
IIS 8.0 Secure Sockets Layer 証明書に使用されるバインドを指定するために、sslFlags 属性が追加されました。
IIS 7.5 <binding> 要素は IIS 7.5 では変更されませんでした。
IIS 7.0 <bindings> コレクションの <binding> 要素は IIS 7.0 で導入されました。
IIS 6.0 <bindings> コレクションは、IIS 6.0 の IIsWebServer メタベース オブジェクトの ServerBindings プロパティのセクションを置き換えます。

段取り

<binding> 要素は IIS 7 以降の既定のインストールに含まれています。

操作方法

既定のバインド情報をサーバーに追加する方法

  1. 次のようにインターネット インフォメーション サービス (IIS) マネージャーを開きます。

    • Windows Server 2012 または Windows Server 2012 R2 を使用している場合:

      • タスク バーで、[サーバー マネージャー] をクリックし、[ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows 8 または Windows 8.1 を使用している場合:

      • Windows キーを押しながら文字 X を押し、[コントロール パネル] をクリックします。
      • [管理ツール] をクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
    • Windows Server 2008 または Windows Server 2008 R2 を使用している場合:

      • タスク バーで、[スタート] ボタンをクリックし、[管理ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows Vista または Windows 7 を使用している場合:

      • タスク バーで、[スタート][コントロール パネル] の順にクリックします。
      • [管理ツール] をダブルクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
  2. [接続] ウィンドウでサーバー名を選びます。

  3. [ホーム] ペインで、[構成エディター] をダブルクリックします。

  4. [セクション]system.applicationHost/sites に移動します。

  5. [サイト バインド] ダイアログ ボックスの [追加...]をクリックします。

  6. siteDefaults を展開します。

  7. bindings を選び、右側の省略記号をクリックしてコレクション エディターを開きます。

    [サイトの既定値] ノードが展開され、[バインド] が選択されている [サイト バインド] ダイアログ ボックスのスクリーンショット。

  8. [追加] をクリックし、bindingInformationprotocolsslFlags の値を入力します。

  9. コレクション エディターを閉じ、[操作] ウィンドウで [適用] をクリックします。

構成

ApplicationHost.config ファイルの <siteDefaults> セクションの <bindings> 要素内に、既定の <binding> 要素を追加できます。

属性 説明
bindingInformation 必須の文字列属性です。

サイトと通信するための情報を指定します。 たとえば、Web サイト バインドには、サイトとの通信に使用される IP アドレス (未指定の IP アドレス)、ポート番号、および省略可能なホスト ヘッダーが含まれます。
protocol 必須の文字列属性です。

サイトと通信するためのプロトコルを指定します。
sslFlags フラグの種類と同様に動作する省略可能な uint 属性で、次のフラグを指定できます。
Value 説明
0 IP/ポートの組み合わせを使用して確立されたセキュリティで保護された接続。 IP アドレスとポートの組み合わせにバインドできる証明書は 1 つだけです。
1 サーバー名表示 (SNI) を使用して取得したポート番号とホスト名を使用して確立されたセキュリティで保護された接続。
2 セキュリティで保護された接続は、一元化された SSL 証明書ストアを使用して行われます。
4 HTTP/2 を無効にします。
8 OCSP Stapling を無効にします。
16 QUIC を無効にします。
32 TCP 経由で TLS 1.3 を無効にします。
64 レガシ TLS を無効にします。
一元化された SSL 証明書のサポートにより、複数の証明書ファイルを含むことができる一元化された証明書ストアを作成できます。 証明書ファイルには、そのファイルに含まれるホスト名に対応する名前を付けることができます。 これにより、IP/ポートまたはホスト名/ポートの組み合わせではなく、ポートのみを必要とするバインディングを作成できます。 要求が着信すると、IIS はポートを照合し、要求からホスト名を決定し、集中証明書ストアで名前が一致する証明書ファイルを検索します。 見つかった証明書を使用します。

Server Name Indication (SNI) を使用すると、SSL ハンドシェイクの一環としてホスト名がやり取りされます。 SNI は、HTTPS の種類を持つバインドを追加するときに、 サイト バインドの追加 ダイアログ ボックスで有効になります。 これは、1 つのネットワーク アドレスで複数のサーバーをホストする SSL 接続に役立ちます。

4 より大きい値は、IIS 10 バージョン 1809 以降でのみサポートされます。 既定値は 0 です。

子要素

なし。

構成サンプル

次の構成サンプルでは、IIS 7 に対して既定の bindings オプションを指定します。

<system.applicationHost>
   <sites>
      <siteDefaults>
         <bindings>
            <binding protocol="http" bindingInformation="127.0.0.1:8080:" />
         </bindings>
      </siteDefaults>
   </sites>
</system.applicationHost>

サンプル コード

次のコード サンプルでは、IIS 7 に対して既定の bindings オプションを構成します。

AppCmd.exe

appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.bindings.[protocol='http',bindingInformation='*:8080:contoso.com'].bindingInformation:"127.0.0.1:8080:" /commit:apphost

Note

AppCmd.exe を使用してこれらの設定を構成するときは、commit パラメーターを必ず apphost に設定する必要があります。 これで、ApplicationHost.config ファイルの適切な場所セクションに構成設定がコミットされます。

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration config = serverManager.GetApplicationHostConfiguration();
         ConfigurationSection sitesSection = config.GetSection("system.applicationHost/sites");
         ConfigurationElement siteDefaultsElement = sitesSection.GetChildElement("siteDefaults");

         ConfigurationElementCollection bindingsCollection = siteDefaultsElement.GetCollection("bindings");
         ConfigurationElement bindingElement = bindingsCollection.CreateElement("binding");
         bindingElement["protocol"] = @"http";
         bindingElement["bindingInformation"] = @"127.0.0.1:8080:";
         bindingsCollection.Add(bindingElement);

         serverManager.CommitChanges();
      }
   }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample

   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetApplicationHostConfiguration
      Dim sitesSection As ConfigurationSection = config.GetSection("system.applicationHost/sites")
      Dim siteDefaultsElement As ConfigurationElement = sitesSection.GetChildElement("siteDefaults")

      Dim bindingsCollection As ConfigurationElementCollection = siteDefaultsElement.GetCollection("bindings")
      Dim bindingElement As ConfigurationElement = bindingsCollection.CreateElement("binding")
      bindingElement("protocol") = "http"
      bindingElement("bindingInformation") = "127.0.0.1:8080:"
      bindingsCollection.Add(bindingElement)

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST");
var siteDefaultsElement = sitesSection.ChildElements.Item("siteDefaults");

var bindingsCollection = siteDefaultsElement.ChildElements.Item("bindings").Collection;
var bindingElement = bindingsCollection.CreateNewElement("binding");
bindingElement.Properties.Item("protocol").Value = "http";
bindingElement.Properties.Item("bindingInformation").Value = "127.0.0.1:8080:";
bindingsCollection.AddElement(bindingElement);

adminManager.CommitChanges();

VBScript

Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set siteDefaultsElement = sitesSection.ChildElements.Item("siteDefaults")

Set bindingsCollection = siteDefaultsElement.ChildElements.Item("bindings").Collection
Set bindingElement = bindingsCollection.CreateNewElement("binding")
bindingElement.Properties.Item("protocol").Value = "http"
bindingElement.Properties.Item("bindingInformation").Value = "127.0.0.1:8080:"
bindingsCollection.AddElement(bindingElement)

adminManager.CommitChanges()