Server/windows

[IIS] HTTP 요청을 HTTPS 프로토콜로 변환 - URL 재작성

코딩for 2021. 1. 15. 15:34
반응형

 

윈도우 서버의 IIS 에서 URL 재작성 을 이용하여 http 요청을 https 로 모두 변경하는 방법에 대해서 알아봅니다.

 

1. IIS 의 URL 재작성 기능이 있는지 확인

 

2. URL 재작성 기능이 없으면 해당 기능의 설치가 필요

 

  2-1) 아래 사이트를 통해 웹 플랫폼 설치 관리자를 다운로드 후 설치 

 

Web Platform Installer : The Official Microsoft IIS Site

HomeDownloadsMicrosoft Supported DownloadsWeb Platform Installer Install this extension or view additional downloads  OverviewThe Microsoft Web Platform Installer - WebPI provides a simplified installation workflow for installing common open source web ap

www.microsoft.com

  2-2) 설치 후 IIS 관리자의 웹 플랫폼 설치 관리자 실행

 

 2-3) URL 재작성 모듈 검색 후 설치

 

 

 

3. URL 재작성 실행 하여 인바운드 규칙 추가하기

 

 

 

4. 인바운드 규칙 및 조건을 입력 - 적용

 

5.  결과 확인

http 요청을 httpStatus 301 로 응답 후 https 로 호출되는것을 확인 할 수 있다.

 

 

* IIS 에서 인바운드 규칙을 추가하는 것처럼 web.config 에 추가 할 수도 있다.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="Redirect to https" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

 

 

반응형