I want my website to default HTTPS except the Services (*.asmx and *.svc) to work in both Http and Https.
Some restful services are to be http becasue the client is developed in jsp and uses http request, one client is Windows which uses same service as https.
I want to skip *.asmx and *.svc or specific service so that any client can request the service either in http or https.
I am using the code below :
<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 of them is working: only the /myservice.svc is working in http but when user hit with Parameter /myservice.svc?wsdl or /myservice.svc/getdata/user-name its forwarding to https. Same is happening to restserv.svc
How to skip *.svc or my specific service to be skipped with Parameters ?
you could try below rule:
<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>
if you still face issue then try to run failed request tracing in iis: