Skip to content

Can't get HTTPS to work on Azure Websites #1331

Closed
@flagbug

Description

@flagbug

I've deployed my ASP.NET Core 1.0 app to Azure Websites, but for some reason, I can't get HTTPS to work.

These are the package versions I'm using:

 "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-rc2-16406",
        "Microsoft.AspNetCore.Cors": "1.0.0-rc2-16272",
        "Microsoft.AspNetCore.HttpOverrides": "1.0.0-rc2-16207",
        "Microsoft.AspNetCore.Identity": "1.0.0-rc2-16485",
        "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-16485",
        "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-rc2-16276",
        "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-17116",
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-16448",
        "Microsoft.EntityFrameworkCore.Commands": "1.0.0-rc2-16937",
        "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-16937",
        "Microsoft.Extensions.Configuration.Binder": "1.0.0-rc2-15952",
        "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc2-16100",
        "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-16100",
        "Microsoft.Extensions.Logging": "1.0.0-rc2-16119",
        "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-16119",
        "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-16119",
        "OpenIddict.Core": "1.0.0-alpha2-0148",
        "OpenIddict.EF": "1.0.0-alpha2-0148"

With DNX 1.0.0-rc2-16551

My startup class looks like this: https://gist.github.com/flagbug/3558413482511986421c

My web.config file contains the following entry to force HTTPS:

<rewrite>
      <rules>
        <clear />
        <rule name="Redirect to https" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
        </rule>
      </rules>
    </rewrite>

To determine the scheme a request is using, I'm using

app.Use(next => context =>
{
    var scheme = context.Request.Scheme;

     // Log the scheme here

     return next(context);
});

which always returns "http", even though I'm calling my site on a https address

// cc @PinpointTownes who was interested in this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions