Snippets

SpiritLing-Team Blog - IIS进行反向代理和URL重写 - https://blog.spiritling.cn/posts/82f57ccc/

Created by Xiao Peng
<?xml version="1.0" encoding="UTF-8"?>
<!--- Origin Release:https://blog.spiritling.cn/posts/82f57ccc/ -->
<!--- Origin Develop:https://dev.blog.spiritling.pub/posts/82f57ccc/ -->
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <!-- htpt => https -->
                <rule name="demo-https" enabled="true" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="^OFF$" />
                        <add input="{HTTP_HOST}" pattern="^demo\.example\.com$" />
                    </conditions>
                    <action type="Redirect" url="https://demo.example.com/{R:1}" />
                </rule>
                <!-- https domain/4436 => https domain:4436 -->
                <rule name="demo" enabled="true" stopProcessing="true">
                    <match url="^4436/(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="^ON$" />
                        <add input="{HTTP_HOST}" pattern="^demo\.example\.com$" />
                    </conditions>
                    <action type="Rewrite" url="https://demo.example.com:4436/{R:1}" />
                </rule>
                <!-- domain => https://localhost -->
                <rule name="index" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^test\.example\.com$" />
                    </conditions>
                    <action type="Rewrite" url="https://localhost" />
                </rule>
            </rules>
        </rewrite>
        <caching enabled="false" enableKernelCache="false" />
    </system.webServer>
</configuration>

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.