1

We have 2 Web servers in Azure that are Load balanced. We just installed SSL in our these azure websites to convert it to HTTPS.

Now we want that any request coming in as HTTP should be changed/redirected to HTTPS connection.

So, I for testing I created a published website on my local machine, then added self signed SSL certificate to get a secure site. Then I used URL rewrite to direct my HTTP site to HTTPS. I used this in Web.config.

This works perfectly on my local published site.

But this fails on the Azure server and gives me an Internal Server Error.

Any ideas?

I used the following in Web.config for the URL rewrite

<rewrite>
<rules>     
    <rule name="HTTP to HTTPS redirect" stopProcessing="true">
        <match url="(.*)" />
            <conditions>
                <add input="{HTTPS}" pattern="Off" />
                <add input="{REQUEST_METHOD}" pattern="^get$|^head$" />
            </conditions>
            <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="SeeOther" />
    </rule>         
</rules>

0

I think we can use URL Rewrite to redirect HTTP to HTTPS. We can follow these steps to achieve this function.

  1. If you don’t have URL Rewrite, we can download it from Microsoft.You can find the links from google. When you install it successfully, you can see URL Rewrite in IIS.

  2. The site is bound by the following two protocols:443 80

  3. Configuring the URL Rewrite.

    enter image description here

    enter image description here

    The policy of the configure in the two fingures

  4. We test it.

    In Azure VM, we access http:// , it will redirect to https:// successfully.

Now, we should pay attention to configure in Azure.

  1. Web Server NSG rules.

    For Input rules, 80 and 443 should be allowed to access.

  2. Load Balance Set.

    I think we should set two load balance set, 80 and 443.

Maybe application gateway can also achieve this function.

1
  • Hey Walter, Thanks for the detailed explanation. This is Perfect and worked very well. I was missing the URL rewrite module on IIS on the server. Installing that did the trick iis.net/downloads/microsoft/url-rewrite Now the IIS server can redirect the url requests from HTTP to HTTPS :-) – ShanChat972 Oct 14 '16 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.