我正在尝试将我的所有URL重写为HTTPS,但是遇到此错误,不确定我在做什么错了:
配置错误
此配置部分不能在此路径上使用。有时候是这样的 当节锁定在父级时。锁定是通过 默认值(overrideModeDefault =“ Deny”),或由位置明确设置 标记并带有overlayMode =“ Deny”或旧版allowOverride =“ false”。
web.config:
<rewrite>
<allowedServerVariables>
<add name="HTTPS" />
<add name="X-FORWARDED-PROTO" />
</allowedServerVariables>
<rules>
<rule name="HTTPS_AlwaysOn" patternSyntax="Wildcard">
<match url="*" />
<serverVariables>
<set name="HTTPS" value="on" />
</serverVariables>
<action type="None" />
<conditions>
<add input="{HTTP_X_FORWARDED_PROTO}" pattern="https" />
</conditions>
</rule>
</rules>
</rewrite>
我还在Docker容器上安装了重写模块和ARR
# Install Url Rewrite
ADD https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi /install/rewrite_amd64_en-US.msi
RUN msiexec.exe /i c:\install\rewrite_amd64_en-US.msi /passive
ADD https://download.microsoft.com/download/A/D/C/ADC4BAF8-A094-47B5-A6F6-CE4C5ED18BF8/ARRv3_setup_amd64_en-us.EXE /install/ARRv3_setup_amd64_en-us.exe
RUN c:\install\ARRv3_setup_amd64_en-us.exe /Q
答案 0 :(得分:0)
构建用于首先进行测试的普通IIS 10计算机,您应该注意到相同的错误,因为allowedServerVariables
不能位于web.config
中。
答案 1 :(得分:0)
<rules>
<rule name="SSL Redirect" enabled="true" stopProcessing="true">
<match url="(.*)"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="off"/>
<add input="{HTTP_HOST}" pattern="localhost" negate="true"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/>
</rule>
</rules>