Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Cloud Service redirect http to https not working (tried answers on many links)

I'm trying to do the 'simple' task of redirecting/rewriting traffic from http to https, I have one endpoint in a CloudService which is correctly configured for SSL.

I've tried many IIS rewrite rules, like the one below, but none are working. I've also tried setting up the rules via remote desktop on the IIS 8 server directly which also doesn't work.

When I enter any tag in the Azure web.config file the rewrite tag has a blue line under it with a message saying it is invalid under <system.webServer> :

<system.webServer>
...
      <rewrite>
          <rules>
              <rule name="RedirectToHTTPS" stopProcessing="true">
                  <match url="(.*)" />
                  <conditions>
                      <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                  </conditions>
                  <action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="SeeOther" />
              </rule>
          </rules>
      </rewrite>

  </system.webServer>

Any advice is much appreciated.

like image 649
sham Avatar asked Jan 12 '23 08:01

sham


1 Answers

In order for these rules to work you have to configure both the endpoints - HTTP and HTTPS !!

If you have not configured plain HTTP endpoint on port 80, your server will never be hit by an Internet traffic, so rewrite rules will never trigger.Thus you get the timeout when you try opening the domain over plain HTTP. There is simply no process listening on port 80 when you haven't defined endpoint for it.

like image 125
astaykov Avatar answered Jan 18 '23 23:01

astaykov