IIS6 Adding Rewrite URL for globalRule X-FORWARDED-PROTO

by Steve Townsend   Last Updated October 09, 2019 20:00 PM

Basically I need to find out how to put this into an appcmd command(s)

            <rule name="X-FORWADED-PROTO">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAny">
                    <add input="{HTTP_X_FORWARDED_PROTO}" pattern="https" />
                <action type="None" />
                    <set name="HTTPS" value="on" />
                    <set name="SERVER_PORT" value="443" />
            <add name="HTTPS" />
            <add name="SERVER_PORT" />
            <add name="HTTP_COOKIE" />
            <add name="RESPONSE_CACHE_CONTROL" />
            <add name="RESPONSE_SET_COOKIE" />

We're using IIS6 and the closet I have gotten is to create the rule but not being able to add the conditions etc.

This works:

.\appcmd.exe set config -section:system.webServer/rewrite/globalRules /+"[name='X-FORWARDED-PROTO',enabled='True']" /commit:apphost

But then the next lines do not

.\appcmd.exe set config -section:system.webServer/rewrite/globalRules.[name='X-FORWARDED-PROTO'] /match.url:"(.*)" /match.ignoreCase:true /commit:apphost

.\appcmd.exe set config -section:system.webServer/rewrite/globalRules.[name='X-FORWARDED-PROTO'].conditions/add /+"[input='{HTTP_X_FORWARDED_PROTO}',pattern='https']" /commit:apphost

.\appcmd.exe set config -section:system.webServer/rewrite/globalRules.[name='X-FORWARDED-PROTO'].action /+"[type='None']" /commit:apphost

It moans that it can't find the name. I'm not even sure if the above will get me what I need.

I've written a playbook in Ansible that goes and creates the website, app pool, bindings, ssl installation, module installations etc. I just need to automate this last URL Rewrite and I am done.

Look forward to hearing from somebody. Steve

Related Questions

win_update fails to update server

Updated August 24, 2017 04:00 AM

Shut down syspro 7 processes

Updated October 05, 2015 09:00 AM