Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Windows Server

การจัดการ IIS แบบ Remote บน Windows Server 2016/2012 R2

บทนำ

Web Server Internet Information Service ใน Windows 2016 / 2012 / R2 เหมือน IIS รุ่นก่อน สามารถจัดการแบบ Remote ได้ จริงๆ แล้วสะดวกมากที่จะจัดการ Multiple IIS Servers จาก Console เดียว และเกือบเป็นวิธีเดียวจัดการ Web Server ที่รันใน Core / Nano Mode แต่โดย Default Remote IIS Management ถูก Disable หากพยายาม Add Remote Server ที่มี IIS ทำงานอยู่ เข้า IIS Management Console (Connect to a Server Menu) บน Server อื่น จะได้ Error:

Could not connect to the specified computer
Details: Unable to connect to the remote server

การติดตั้ง IIS Management Service

ระหว่างการติดตั้ง IIS แบบ Standard Service ที่รับผิดชอบ Remote Management (IIS Management Service) ไม่ได้ถูก Install ตรวจสอบด้วย PowerShell:

Get-WindowsFeature *web-mgmt*

จะเห็น Web-Mgmt-Service ไม่ได้ Install ติดตั้งด้วย PowerShell (Run as Admin):

Add-WindowsFeature Web-Mgmt-Service

หรือใช้ Cmdlet:

Install-WindowsFeature Web-Mgmt-Service

ติดตั้งจาก Server Manager Console ก็ได้ (Management Service Component)

Restart IIS Web Service: iisreset –noforce

อนุญาต Remote Connections ใน IIS Settings

เปิด Item Management Service ใน Section Management ของ IIS Manager Check Option Enable remote connections

สามารถจำกัด Connection ด้วย IP Address: Deny Connections สำหรับ Unspecified Clients และระบุ IP/Subnets ที่อนุญาต Remote Connection Service ใช้ SSL Certificate แต่สามารถใช้ Certificate อื่นได้หาก Import เข้า Server Certificate Store (สร้าง Self-signed SSL Certificate ด้วย PoSh ได้) Save Changes

หมายเหตุ: Default ใช้ Port 8172 สำหรับ Remote IIS Management เมื่อ Save Changes Port นี้จะเปิดใน Windows Firewall อัตโนมัติ
หมายเหตุ: สามารถ Enable Option นี้ผ่าน Registry บน Remote IIS Server ที่รัน Core Mode โดยตั้ง Parameter EnableRemoteManagement ใน Registry Key HKLM\Software\Microsoft\WebManagement\Server เป็น 1 คำสั่ง:
Reg Add HKLM\Software\Microsoft\WebManagement\Server /V EnableRemoteManagement /T REG_DWORD /D 1
ในกรณีนี้ต้องสร้าง Firewall Rule เอง: netsh advfirewall firewall add rule name=”Allow IIS Web Management” dir=in action=allow service=”WMSVC”

Start Web Management Service: net start wmsvc

ตั้งค่า Service ให้ Start Auto เมื่อ Boot: set-service wmsvc -StartupType Automatic หรือ sc config WMSVC start= auto

ตอนนี้ Remote IIS Web Server เพิ่มเข้า IIS Manager Console ได้ และจัดการ IIS Server, Multiple Sites บนมันเหมือน Local Web Server

อนุญาต Non-Admin Accounts จัดการ IIS Site แบบ Remote

โดย Default เฉพาะ Users ที่มี Admin Privileges เท่านั้นที่มี Permission จัดการ IIS แบบ Remote เพื่อ Grant Permission ให้ Standard Users ต้อง Grant Permissions ระดับ IIS Website แต่ละ Site เลือก Site → หา Option IIS Manager Permissions → Actions Panel → Allow User → เลือก User Account → OK

User Permissions จัดการ Sites บน IIS Server ตั้งค่าที่ Section Feature Delegation ระดับ IIS Server สามารถเลือก 3 ระดับ Access สำหรับแต่ละ Function: Read Only, Read/Write หรือ Not Delegated

จัดการ IIS Servers แบบ Remote จาก Windows 10

หากต้องการจัดการ IIS Servers แบบ Remote จาก Windows 10 (Windows 7 หรือ 8.1) ต้อง Install IIS Management Console จาก: Turn Windows features on or off → Internet Information Services → Web Management Tools → IIS Management Console

ติดตั้งด้วย PowerShell: Enable-WindowsOptionalFeature -Online -FeatureName "IIS-ManagementService"

แต่เวลา Run IIS Manager Console ใน Windows 10 Item Connect to a server ใน Menu จะหายไป

เพื่อให้ Connect ไป IIS แบบ Remote จาก Windows 10 ได้ ต้อง Download และ Install Package IIS Manager for Remote Administration (https://www.microsoft.com/en-us/download/details.aspx?id=41177)

Tip: มี Version สำหรับ x64 (inetmgr_amd64_en-US.msi) และ x86 OS (inetmgr_x86_en-US.msi)

หลัง Install Restart IIS Manager และ Connect ไป Site หาก Console Version ต่างกันระหว่าง Client และ Server จะมี Notification บอกให้ Update Console Version (Files จะ Download จาก Server อัตโนมัติ)

IIS Remote Management และ TLS 1.1 / TLS 1.2 Support

หาก Disable SSLv3 และ TLS 1.0 บน IIS ทิ้งไว้แค่ TLS 1.1/1.2 เวลา Remote Connect จะ Error:

The underlying connection was closed: An unexpected error occurred on a send.

แก้ไขโดยแก้ Registry บน Client Side เพื่อบังคับใช้ TLS 1.2 ตอน Connect Settings ขึ้นกับ Windows Version:

Windows 10 และ Windows Server 2016:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001

Windows 2012/ R2 และ Windows 8/8.1:

ต้องมี NET Framework 4.5.2 หรือใหม่กว่า

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001

Windows Server 2008 R2 / Windows 7:

ต้อง Install Update KB3154518 ก่อน เพื่อ Support TLS 1.2 ใน .NET Framework 3.5.1

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727]
"SystemDefaultTlsVersions"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727]
"SystemDefaultTlsVersions"=dword:00000001
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]
"DisabledByDefault"=dword:00000000
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server]
"DisabledByDefault"=dword:00000000
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"DisabledByDefault"=dword:00000000