HTTP to HTTPS redirect issue with iis8.5 and Websphere7

492 Views Asked by At

We have applications hosted on WebSphere 7.0 and Jboss EAP7 which is behind IIS 8.5 Web server, we enabled ssl for iis.

our requirement is whenever users access with http it has to be redirected to https, to achieve this we configured rewrite2 module in iis below inbound rule

<rules>
    <rule name="http to https" enabled="false" stopProcessing="true">
        <match url="(.*)" />
        <conditions logicalGrouping="MatchAny">
            <add input="{HTTPS}" pattern="^OFF$" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="SeeOther" />
    </rule>

issue :- when i access http://www.example.com/login it redirects to https://www.example.com/sePlugins/iisWASPlugin_http.dll and gives 404 Status code. (only applications hosted websphere) The problem is that we have a ISAPI Websphere plugin to handle the requests and for some reason URL is getting changed by IIS.

redirect rule works fine for Applications hosted on J BOSS.

2

There are 2 best solutions below

2
Goodey On

I found that specifying {CACHE_URL} in the Redirect Url instead of https://{HTTP_HOST}{REQUEST_URI} worked. so url="{CACHE_URL}"

0
Goodey On

Not sure what happened to my registration process but I posted the original answer so reposting again after registering.

I found that specifying {CACHE_URL} in the Redirect Url instead of https://{HTTP_HOST}{REQUEST_URI} worked. so url="{CACHE_URL}"

This is how my rule is defined and it seems to work well.

<rule name="HTTP to HTTPS redirect" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_X_FORWARDED_PROTO}" pattern="^http$" />
    </conditions>
    <action type="Redirect" url="{CACHE_URL}" />
</rule>