找回密碼
 註冊
搜索
查看: 2313|回復: 0

IIS + LetsEncrypt + Redirect http to https

[複製鏈接]
發表於 2018-3-19 14:28:35 | 顯示全部樓層 |閱讀模式
  • 下載win-acme,解壓執行letsencrypt.exe
    N: Create new certificate => 1: Single binding of an IIS site => 選擇要產生SSL憑證的site,接著就會幫你設好SSL憑證,並排程自動更新SSL憑證
  • 下載並安裝URL Rewrite 2.0
  • 在site的主目錄下修改或新增web.config檔
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Allow LetsEncrypt" patternSyntax="Wildcard" stopProcessing="true">
                        <match url=".well-known/*" />
                        <action type="None" />
                    </rule>
                    <rule name="Redirect HTTP to HTTPS" patternSyntax="Wildcard" stopProcessing="true">
                        <match url="*" ignoreCase="false" />
                        <conditions>
                            <add input="{HTTPS}" pattern="off" />
                        </conditions>
                        <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>
  • 重啟IIS

Reference:
https://blog.tedd.no/2017/05/09/ ... allow-lets-encrypt/
https://weblog.west-wind.com/pos ... with-IIS-on-Windows
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|彩色筆小沛的知識庫

GMT+8, 2024-4-25 09:54 , Processed in 0.015015 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回復 返回頂部 返回列表