iis urlrewrite HTTPS 除了服务(.asmx 和 .svc)或带有参数/值的特定服务
iis urlrewrite HTTPS except services (.asmx and .svc) or Specific service with parameters / values
我希望我的网站默认使用 HTTPS,但服务(*.asmx 和 *.svc)除外,以便在 Http 和 Https 中工作。
部分restful服务是http,因为客户端是jsp开发的,使用http请求,一个客户端是Windows,使用与https相同的服务。
我想跳过 *.asmx 和 *.svc 或特定服务,以便任何客户端都可以在 http 中请求该服务或 https.
我正在使用下面的代码:
<rule name="Force HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<!-- <add input="{HTTPS}" pattern="^OFF$" /> -->
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/myservice.svc$" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/myservice.svc?(.*)" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/restserv.svc$" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/restserv.svc/(.*)" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
其中 None 有效:只有 /myservice.svc 在 http 中有效,但当用户点击参数 /myservice.svc?wsdl 或 /myservice.svc/getdata/user-name 转发到 https。
同样发生在 restserv.svc
如何跳过 *.svc 或我要用参数跳过的特定服务?
您可以尝试以下规则:
<rule name="Https Except Service" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/(myservice\.svc.*)" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/(restserv\.svc.*)" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
如果您仍然遇到问题,请尝试 运行 在 iis 中跟踪失败的请求:
我希望我的网站默认使用 HTTPS,但服务(*.asmx 和 *.svc)除外,以便在 Http 和 Https 中工作。
部分restful服务是http,因为客户端是jsp开发的,使用http请求,一个客户端是Windows,使用与https相同的服务。
我想跳过 *.asmx 和 *.svc 或特定服务,以便任何客户端都可以在 http 中请求该服务或 https.
我正在使用下面的代码:
<rule name="Force HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<!-- <add input="{HTTPS}" pattern="^OFF$" /> -->
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/myservice.svc$" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/myservice.svc?(.*)" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/restserv.svc$" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/restserv.svc/(.*)" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
其中 None 有效:只有 /myservice.svc 在 http 中有效,但当用户点击参数 /myservice.svc?wsdl 或 /myservice.svc/getdata/user-name 转发到 https。 同样发生在 restserv.svc
如何跳过 *.svc 或我要用参数跳过的特定服务?
您可以尝试以下规则:
<rule name="Https Except Service" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/(myservice\.svc.*)" ignoreCase="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/(restserv\.svc.*)" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
如果您仍然遇到问题,请尝试 运行 在 iis 中跟踪失败的请求: