IIS(Internet Information Services)는 Windows Server의 내장 웹서버입니다. ASP.NET 기반 웹 애플리케이션이나 Windows 환경에서 웹 서비스를 운영할 때 많이 사용합니다. 이 글에서는 IIS 설치부터 기본 보안 설정까지 설명합니다.
IIS 설치
서버 관리자를 통한 설치
- 서버 관리자 실행
- 역할 및 기능 추가 클릭
- 서버 역할 단계에서 웹 서버(IIS) 선택
- 기능 선택에서 필요한 항목 추가 후 설치
PowerShell로 설치
# IIS 기본 설치
Install-WindowsFeature -name Web-Server -IncludeManagementTools
# ASP.NET 포함 설치
Install-WindowsFeature -name Web-Server, Web-Asp-Net45, Web-Net-Ext45 -IncludeManagementTools
# 설치 확인
Get-WindowsFeature | Where-Object {$_.Name -like "Web-*" -and $_.InstallState -eq "Installed"}
기본 사이트 구성
# 기본 사이트 포트 변경
Import-Module WebAdministration
Set-WebBinding -Name "Default Web Site" -BindingInformation "*:80:" `
-PropertyName Port -Value 8080
# 새 사이트 추가
New-WebSite -Name "MySite" -Port 80 -PhysicalPath "C:\inetpub\mysite" -Force
# 사이트 시작/중지
Start-WebSite -Name "MySite"
Stop-WebSite -Name "Default Web Site"
보안 설정
디렉토리 검색 비활성화
디렉토리 내용이 외부에 노출되지 않도록 합니다:
Set-WebConfigurationProperty -Filter "system.webServer/directoryBrowse" `
-Name Enabled -Value False -PSPath "IIS:\"
또는 IIS 관리자 → 사이트 선택 → 디렉터리 검색 → 오른쪽 패널에서 사용 안 함
서버 버전 정보 숨기기
C:\Windows\System32\inetsrv\config\applicationHost.config:
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
PowerShell:
# X-Powered-By 헤더 제거
Remove-WebConfigurationProperty -PSPath "IIS:\" `
-Filter "system.webServer/httpProtocol/customHeaders" `
-Name "." -AtElement @{name='X-Powered-By'}
# Server 헤더 숨기기 (URL Rewrite 모듈 필요)
Add-WebConfigurationProperty -PSPath "IIS:\" `
-Filter "system.webServer/rewrite/outboundRules" `
-Name "." -Value @{name="Remove Server Header"; enabled="True"}
보안 HTTP 헤더 추가
web.config에 추가합니다:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-Content-Type-Options" value="nosniff" />
<add name="X-Frame-Options" value="SAMEORIGIN" />
<add name="X-XSS-Protection" value="1; mode=block" />
<add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains" />
</customHeaders>
</httpProtocol>
</system.webServer>
요청 필터링
# 최대 요청 크기 제한 (10MB)
Set-WebConfigurationProperty -PSPath "IIS:\" `
-Filter "system.webServer/security/requestFiltering/requestLimits" `
-Name maxAllowedContentLength -Value 10485760
# 위험한 확장자 차단
Add-WebConfigurationProperty -PSPath "IIS:\" `
-Filter "system.webServer/security/requestFiltering/fileExtensions" `
-Name "." -Value @{fileExtension=".php"; allowed="False"}
SSL 인증서 적용
# 자체 서명 인증서 생성 (테스트용)
New-SelfSignedCertificate -DnsName "example.com" -CertStoreLocation "cert:\LocalMachine\My"
# HTTPS 바인딩 추가
New-WebBinding -Name "MySite" -Protocol "https" -Port 443 -SslFlags 0
IIS 로그 설정
# 로그 위치 확인
Get-WebConfigurationProperty -PSPath "IIS:\" `
-Filter "system.applicationHost/sites/siteDefaults/logFile" -Name directory
# 로그 형식을 W3C로 설정 (권장)
Set-WebConfigurationProperty -PSPath "IIS:\" `
-Filter "system.applicationHost/sites/siteDefaults/logFile" `
-Name logFormat -Value "W3C"
기본 로그 위치는 C:\inetpub\logs\LogFiles\입니다. 정기적으로 검토하여 비정상 접근을 확인하세요.