다음을 통해 공유


바인딩 바인딩 <>

개요

<binding> 요소의 <bindings> 요소를 사용하면 요청이 웹 사이트와 통신하는 데 필요한 정보를 구성할 수 있습니다.

웹 사이트를 만들 때 바인딩 정보를 구성하거나 사이트를 만든 후 바인딩 정보를 편집할 수 있습니다. 바인딩 정보에는 클라이언트가 사이트와 통신하는 데 사용하는 프로토콜, 사이트의 IP 주소, 포트 번호 및 호스트 헤더가 포함됩니다.

<binding> 요소에는 바인딩 정보를 구성하는 두 가지 특성인 bindingInformation프로토콜이 포함되어 있습니다. bindingInformation 특성에는 IP 주소, 포트 번호 및 선택적으로 사이트의 호스트 헤더가 포함됩니다. 프로토콜 특성은 사이트와 통신하는 데 사용할 프로토콜을 정의합니다.

사이트를 선택하고 작업 창에서 바인딩... 또는 고급 설정... 링크를 사용하거나 사이트의 바로 가기 메뉴에서 바인딩 편집...을 클릭하여 IIS 관리자를 사용하여 사이트의 바인딩 컬렉션을 구성할 수 있습니다.

IIS 8.0 이상을 사용하면 Windows Server 2012의 중앙 집중식 인증서 저장소에 있는 인증서를 사용하여 웹 사이트에 대한 보안을 제공할 수 있습니다. 자세한 내용은 IIS 8.0 중앙 집중식 SSL 인증서 지원: SSL 확장성 및 관리 가능성을 참조하세요.

바인딩 요소를 사용하면 SSL(Secure Sockets Layer) 인증서에 사용되는 바인딩 유형을 지정할 수 있습니다.

호환성

버전 참고
IIS 10.0 <binding> 요소가 IIS 10.0에서 수정되지 않았습니다.
IIS 8.5 <binding> 요소가 IIS 8.5에서 수정되지 않았습니다.
IIS 8.0 특성은 sslFlags Secure Sockets Layer 인증서에 사용되는 바인딩을 지정하기 위해 추가되었습니다.
IIS 7.5 <binding> 요소가 IIS 7.5에서 수정되지 않았습니다.
IIS 7.0 <binding> 컬렉션의 <bindings> 요소는 IIS 7.0에서 도입되었습니다.
IIS 6.0 컬렉션은 <bindings> IIS 6.0 IIsWebServer 메타베이스 개체의 ServerBindings 속성 섹션을 대체합니다.

설치 프로그램

요소는 <binding> IIS 7 이상의 기본 설치에 포함됩니다.

중앙 집중식 인증서 저장소를 설치하는 방법

IIS 8 이상에서는 중앙 집중식 인증서 저장소의 인증서를 사용하여 웹 사이트에 대한 보안을 제공할 수 있습니다. Windows Server 2012 이상 웹 서버에서 이 저장소를 사용하려면 중앙 집중식 SSL 인증서 저장소 역할을 설치해야 합니다. IIS가 이미 설치되어 있으면 다음과 같이 진행합니다.

  1. Windows 키를 누른 다음 서버 관리자 클릭합니다.
  2. 서버 관리자관리를 클릭한 다음 역할 및 기능 추가를 클릭합니다.
  3. 역할 및 기능 추가 마법사에서 시작하기 전에 페이지를 클릭하고 설치 유형을 선택한 다음 설치 유형 페이지에서 다음을 클릭하고 설치할 위치를 선택하고 서버 선택 페이지에서 다음을 클릭합니다.
  4. 서버 역할 페이지에서 웹 서버(IIS)가 선택되어 있는지 확인하고 확장합니다. 웹 서버를 확장한 다음, 보안을 선택하고 확장합니다.
  5. 중앙 집중식 SSL 인증서 저장소를 선택하고 다음을 클릭합니다.
  6. 기능 페이지에서 다음을 클릭합니다.
  7. 설치 선택 확인 페이지에서 설치를 클릭합니다.
  8. Results(결과) 페이지에서 Close(닫기)를 클릭합니다.

방법

사이트에 바인딩 정보를 추가하는 방법

  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. 사이트 바인딩 대화 상자에서 추가...를 클릭합니다.
    사이트 바인딩 대화 상자의 스크린샷

  5. 사이트 바인딩 추가 대화 상자에서 바인딩 정보를 추가하고 확인을 클릭합니다.
    사이트 바인딩 추가 대화 상자의 스크린샷.

중앙 집중식 인증서 저장소를 만드는 방법

  1. 시작 단추를 누른 다음 서버 관리자 클릭합니다. 서버 관리자 도구를 클릭한 다음 IIS(인터넷 정보 서비스) 관리자를 클릭합니다.
  2. 연결 창에서 서버 이름을 선택합니다.
  3. 페이지의 관리 영역에서 중앙 집중식 인증서를 두 번 클릭합니다.
  4. 작업 창에서 기능 설정 편집을 클릭합니다.
  5. 중앙 집중식 인증서 사용을 선택하고 실제 경로를 입력합니다. 경로에 대한 사용자 이름을 입력하고, 경로에 대한 암호를 입력하고, 암호를 확인합니다. 확인을 클릭합니다.

구성

ApplicationHost.config 파일의 <bindings> 각 사이트에 대한 요소 내에 요소를 추가할 <binding> 수 있습니다. 각 사이트에는 인터넷을 통해 볼 수 있는 HTTP 또는 HTTPS 바인딩이 하나 이상 있어야 합니다.

특성

attribute Description
bindingInformation 필수 문자열 특성입니다.

사이트와 통신할 정보를 지정합니다. 예를 들어 웹 사이트 바인딩에는 IP 주소(또는 지정되지 않은 IP 주소), 포트 번호 및 사이트와 통신하는 데 사용되는 선택적 호스트 헤더가 포함됩니다.
protocol 필수 문자열 특성입니다.

사이트와 통신하기 위한 프로토콜을 지정합니다.
sslFlags 선택적 uint 특성입니다.

SSL(Secure Sockets Layer) 인증서에 사용되는 바인딩 유형을 지정합니다.
  • 값 "0"은 IP/포트 조합을 사용하여 보안 연결을 만들 것을 지정합니다. 하나의 인증서만 IP 주소와 포트의 조합에 바인딩할 수 있습니다.
  • 값 "1"은 SNI(서버 이름 표시)를 사용하여 가져온 포트 번호와 호스트 이름을 사용하여 보안 연결을 만들 수 있도록 지정합니다.
  • 값 "2"는 서버 이름 표시기 없이 중앙 집중식 SSL 인증서 저장소를 사용하여 보안 연결을 만들도록 지정합니다.
  • 값 "3"은 서버 이름 표시기를 요구하는 동안 중앙 집중식 SSL 인증서 저장소를 사용하여 보안 연결을 만들도록 지정합니다.
중앙 집중식 SSL 인증서 지원을 사용하면 여러 인증서 파일을 포함할 수 있는 중앙 집중식 인증서 저장소를 만들 수 있습니다. 포함된 호스트 이름에 해당하는 인증서 파일의 이름을 지정할 수 있습니다. 이렇게 하면 IP/포트 또는 호스트 이름/포트 조합이 아닌 포트만 필요한 바인딩을 만들 수 있습니다. 요청이 들어오면 IIS는 포트와 일치하고, 요청에서 호스트 이름을 확인하고, 중앙 집중식 인증서 저장소에서 일치하는 이름의 인증서 파일을 검색합니다. 해당 인증서를 사용합니다.

SNI(서버 이름 표시기)를 사용하면 호스트 이름이 SSL 핸드셰이크의 일부로 교환됩니다. HTTPS 형식의 바인딩을 추가할 때 사이트 바인딩 추가 대화 상자에서 SNI를 사용할 수 있습니다. 이는 단일 네트워크 주소에서 여러 서버를 호스트하는 SSL 연결에 특히 유용합니다. 자세한 내용은 IIS 8.0 SNI(서버 이름 표시): SSL 확장성을 참조하세요.

sslFlags 특성은 프로토콜이 https일 때만 설정됩니다. 기본값은 0입니다.

자식 요소

없음

구성 샘플

다음 예제에서는 두 개의 바인딩을 사용하여 Contoso라는 사이트를 정의합니다. 첫 번째 바인딩은 192.168.0.1의 IP 주소에 대해 포트 80의 "www.contoso.com" 호스트 이름에 대한 것이며, 두 번째 바인딩은 포트 443을 통한 모든 IP 주소에 대한 HTTPS 바인딩에 대한 것입니다.

<site name="Contoso" id="2">
   <application path="/" applicationPool="Contoso">
      <virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot" />
   </application>
   <bindings>
      <binding protocol="http" bindingInformation="192.168.0.1:80:www.contoso.com" />
      <binding protocol="https" bindingInformation="*:443:" />
   </bindings>
</site>

샘플 코드

다음 예제에서는 192.168.0.1의 IP 주소에 대해 포트 80에 호스트 이름이 "www.contoso.com"인 Contoso 사이트와 포트 443을 통한 모든 IP 주소에 대한 HTTPS 바인딩을 구성합니다.

AppCmd.exe

appcmd.exe set site /site.name:Contoso /+bindings.[protocol='http',bindingInformation='192.168.0.1:80:www.contoso.com']

appcmd.exe set site /site.name:Contoso /+bindings.[protocol='https',bindingInformation='*:443:']

또는 다음을 사용할 수 있습니다.

appcmd.exe set config -section:system.applicationHost/sites /+"[name='Contoso'].bindings.[protocol='http',bindingInformation='192.168.0.1:80:www.contoso.com']" /commit:apphost

appcmd.exe set config -section:system.applicationHost/sites /+"[name='Contoso'].bindings.[protocol='https',bindingInformation='*:443:']" /commit:apphost

참고

AppCmd.exe 사용하여 이러한 설정을 구성할 때 커밋 매개 변수 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");
          ConfigurationElementCollection sitesCollection = sitesSection.GetCollection();
          ConfigurationElement siteElement = FindElement(sitesCollection, "site", "name", @"Contoso");

          if (siteElement == null) throw new InvalidOperationException("Element not found!");

          ConfigurationElementCollection bindingsCollection = siteElement.GetCollection("bindings");
          ConfigurationElement bindingElement = bindingsCollection.CreateElement("binding");
          bindingElement["protocol"] = @"http";
          bindingElement["bindingInformation"] = @"192.168.0.1:80:www.contoso.com";
          bindingsCollection.Add(bindingElement);

          ConfigurationElement bindingElement1 = bindingsCollection.CreateElement("binding");
          bindingElement1["protocol"] = @"https";
          bindingElement1["bindingInformation"] = @"*:443:";
          bindingsCollection.Add(bindingElement1);

          serverManager.CommitChanges();
      }
   }

   private static ConfigurationElement FindElement(ConfigurationElementCollection collection, string elementTagName, params string[] keyValues)
   {
      foreach (ConfigurationElement element in collection)
      {
         if (String.Equals(element.ElementTagName, elementTagName, StringComparison.OrdinalIgnoreCase))
         {
            bool matches = true;
            for (int i = 0; i < keyValues.Length; i += 2)
            {
               object o = element.GetAttributeValue(keyValues[i]);
               string value = null;
               if (o != null)
               {
                  value = o.ToString();
               }
               if (!String.Equals(value, keyValues[i + 1], StringComparison.OrdinalIgnoreCase))
               {
                  matches = false;
                  break;
               }
            }
            if (matches)
            {
               return element;
            }
         }
      }
      return null;
   }
}

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 sitesCollection As ConfigurationElementCollection = sitesSection.GetCollection
      Dim siteElement As ConfigurationElement = FindElement(sitesCollection, "site", "name", "Contoso")

      If (siteElement Is Nothing) Then
         Throw New InvalidOperationException("Element not found!")
      End If

      Dim bindingsCollection As ConfigurationElementCollection = siteElement.GetCollection("bindings")

      Dim bindingElement As ConfigurationElement = bindingsCollection.CreateElement("binding")
      bindingElement("protocol") = "http"
      bindingElement("bindingInformation") = "192.168.0.1:80:www.contoso.com"
      bindingsCollection.Add(bindingElement)

      Dim bindingElement1 As ConfigurationElement = bindingsCollection.CreateElement("binding")
      bindingElement1("protocol") = "https"
      bindingElement1("bindingInformation") = "*:443:"
      bindingsCollection.Add(bindingElement1)

      serverManager.CommitChanges()
   End Sub

   Private Function FindElement(ByVal collection As ConfigurationElementCollection, ByVal elementTagName As String, ByVal ParamArray keyValues() As String) As ConfigurationElement
      For Each element As ConfigurationElement In collection
         If String.Equals(element.ElementTagName, elementTagName, StringComparison.OrdinalIgnoreCase) Then
            Dim matches As Boolean = True
            Dim i As Integer
            For i = 0 To keyValues.Length - 1 Step 2
               Dim o As Object = element.GetAttributeValue(keyValues(i))
               Dim value As String = Nothing
               If (Not (o) Is Nothing) Then
                  value = o.ToString
               End If
               If Not String.Equals(value, keyValues((i + 1)), StringComparison.OrdinalIgnoreCase) Then
                  matches = False
                  Exit For
               End If
            Next
            If matches Then
               Return element
            End If
         End If
      Next
      Return Nothing
   End Function


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 sitesCollection = sitesSection.Collection;
var siteElementPos = FindElement(sitesCollection, "site", ["name", "Contoso"]);

if (siteElementPos == -1) throw "Element not found!";

var siteElement = sitesCollection.Item(siteElementPos);
var bindingsCollection = siteElement.ChildElements.Item("bindings").Collection;

var bindingElement = bindingsCollection.CreateNewElement("binding");
bindingElement.Properties.Item("protocol").Value = "http";
bindingElement.Properties.Item("bindingInformation").Value = "192.168.0.1:80:www.contoso.com";
bindingsCollection.AddElement(bindingElement);

var bindingElement1 = bindingsCollection.CreateNewElement("binding");
bindingElement1.Properties.Item("protocol").Value = "https";
bindingElement1.Properties.Item("bindingInformation").Value = "*:443:";
bindingsCollection.AddElement(bindingElement1);

adminManager.CommitChanges();

function FindElement(collection, elementTagName, valuesToMatch) {
   for (var i = 0; i < collection.Count; i++) {
      var element = collection.Item(i);
      if (element.Name == elementTagName) {
         var matches = true;
         for (var iVal = 0; iVal < valuesToMatch.length; iVal += 2) {
            var property = element.GetPropertyByName(valuesToMatch[iVal]);
            var value = property.Value;
            if (value != null) {
               value = value.toString();
            }
            if (value != valuesToMatch[iVal + 1]) {
               matches = false;
               break;
            }
         }
         if (matches) {
            return i;
         }
      }
   }
   return -1;
}

VBScript

Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set sitesCollection = sitesSection.Collection
siteElementPos = FindElement(sitesCollection, "site", Array("name", "Contoso"))

If siteElementPos = -1 Then
   WScript.Echo "Element not found!"
   WScript.Quit
End If

Set siteElement = sitesCollection.Item(siteElementPos)
Set bindingsCollection = siteElement.ChildElements.Item("bindings").Collection

Set bindingElement = bindingsCollection.CreateNewElement("binding")
bindingElement.Properties.Item("protocol").Value = "http"
bindingElement.Properties.Item("bindingInformation").Value = "192.168.0.1:80:www.contoso.com"
bindingsCollection.AddElement(bindingElement)

Set bindingElement1 = bindingsCollection.CreateNewElement("binding")
bindingElement1.Properties.Item("protocol").Value = "https"
bindingElement1.Properties.Item("bindingInformation").Value = "*:443:"
bindingsCollection.AddElement(bindingElement1)

adminManager.CommitChanges()

Function FindElement(collection, elementTagName, valuesToMatch)
   For i = 0 To CInt(collection.Count) - 1
      Set element = collection.Item(i)
      If element.Name = elementTagName Then
         matches = True
         For iVal = 0 To UBound(valuesToMatch) Step 2
            Set property = element.GetPropertyByName(valuesToMatch(iVal))
            value = property.Value
            If Not IsNull(value) Then
               value = CStr(value)
            End If
            If Not value = CStr(valuesToMatch(iVal + 1)) Then
               matches = False
               Exit For
            End If
         Next
         If matches Then
            Exit For
         End If
      End If
   Next
   If matches Then
      FindElement = i
   Else
      FindElement = -1
   End If
End Function